随笔分类 -  Pytorch

摘要:第一种:vocab = dict(Counter(text).most_common(MAX_VOCAB_SIZE-1)) 举例: from collections import Counter colors = ['red', 'blue', 'red', 'green', 'blue', 'bl 阅读全文
posted @ 2020-08-25 17:17 kpwong 阅读(989) 评论(0) 推荐(0)
摘要:一、softmax函数 softmax用于多分类过程中,它将多个神经元的输出,映射到(0,1)区间内,可以看成概率来理解,从而来进行多分类! 假设我们有一个数组,V,Vi表示V中的第i个元素,那么这个元素的softmax值就是 tensorflwo中举例: 二 信息熵: 在tensorflow中: 阅读全文
posted @ 2020-08-14 17:00 kpwong 阅读(576) 评论(0) 推荐(0)
摘要:import torchfrom torch import nnlstm = nn.LSTM(input_size=100,hidden_size=20,num_layers=2)print(lstm)x = torch.randn(10,3,100)out,(h,c) = lstm(x)print 阅读全文
posted @ 2020-08-08 15:51 kpwong 阅读(201) 评论(0) 推荐(0)
摘要:import numpy as npimport torchimport torch.nn as nnimport torch.optim as optimfrom matplotlib import pyplot as pltnum_time_steps = 50input_size = 1hid 阅读全文
posted @ 2020-08-08 15:42 kpwong 阅读(4227) 评论(0) 推荐(1)
摘要:nn.RNN(input_size, hidden_size, num_layers=1, nonlinearity=tanh, bias=True, batch_first=False, dropout=0, bidirectional=False) 参数说明 input_size输入特征的维度, 阅读全文
posted @ 2020-08-08 12:20 kpwong 阅读(1866) 评论(0) 推荐(1)
摘要:'''导入库'''import torchimport torch.nn as nnimport torchvisionimport torch.utils.data as Datafrom torch.utils import model_zooimport mathfrom torch.auto 阅读全文
posted @ 2020-08-08 09:08 kpwong 阅读(224) 评论(0) 推荐(0)