摘要:(一)训练集loss不下降 1. 初始化方案有问题 神经网络在训练之前,我们需要给其赋予一个初值,常用的初始化方案有全零初始化、随机正态分布初始化和随机均匀分布初始化等。 建议无脑xaiver normal初始化或者 he normal /xavier用在权重初始化上,constant用在偏置初始化
阅读全文
摘要:https://blog.csdn.net/leo_95/article/details/89946318 matmul 可以进行张量乘法, 输入可以是高维. mat 矩阵对应位相乘,两个tensor输入维度相同,(m×n)和(m×n),返回(m×n) mm 只能进行矩阵乘法,也就是输入的两个ten
阅读全文
摘要:torch.squeeze() 对数据的维度进行压缩,去掉维数为1的的维度,默认是将a中所有为1的维度删掉。 也可以通过dim指定位置,删掉指定位置的维数为1的维度。torch.unsqueeze()对数据维度进行 import torch x = torch.zeros(3, 2, 4, 1, 2, 1) # dimension of 3*2*4*1*2 print(x.size()) # to
阅读全文
摘要:均匀分布nn.init.uniform(tensor,a=0,b=1)tensor -n维的torch.Tensora 均匀分布的下界,默认值为0b 均匀分布的上界,默认值为1 正态分布torcn.nn.init.normal(tensor,mean=0,std=1)tensor n维的torch.Tensormean 正太分布的均值std 正太分布的标准差 import torch import
阅读全文
摘要:torch.nn.init.calculate_gain(nonlinearity,param=None) 对于给定的非线性函数,返回推荐的增益值。这些值如下所示:
阅读全文
摘要:w tensor([[6.5103e-38, 0.0000e+00, 5.7453e-44, 0.0000e+00, nan],[0.0000e+00, 1.3733e-14, 6.4076e+07, 2.0706e-19, 7.3909e+22],[2.4176e-12, 1.1625e+33,
阅读全文
摘要:''' torch.nn torch.nn.functional (F)CrossEntropyLoss cross_entropy LogSoftmax log_softmax NLLLoss nll_loss''' import torch import torch.nn.functional as F input=torch.randn(3,4) label=torch.tensor([0,
阅读全文
摘要:import torch import torch.autograd as autograd import torch.nn as nn import torch.nn.functional as F import torch.optim as optim import numpy as np data=autograd.Variable(torch.FloatTensor([1.0,2.0...
阅读全文
摘要:首先定义:待优化参数: ,目标函数: ,初始学习率 。 而后,开始进行迭代优化。在每个epoch : SGD SGD with Momentum AdaGrad AdaDelta / RMSProp Adam
阅读全文
摘要:AdaGrad (Adaptive Gradient,自适应梯度) 对每个不同的参数调整不同的学习率, 对频繁变化的参数以更小的步长进行更新,而稀疏的参数以更大的步长进行更新。 gt表示第t时间步的梯度(向量,包含各个参数对应的偏导数,gt,i表示第i个参数t时刻偏导数) gt2表示第t时间步的梯度
阅读全文
摘要:import torch as th import dgl g=dgl.DGLGraph() g.add_nodes(3) g.ndata["x"]=th.ones(3,4) #number of features to match number of nodes print("nodes",g.nodes()) print("ndata",g.ndata["x"]) #increment...
阅读全文
摘要:'''class torch.nn.Linear(in_features,out_features,bias = True )[来源] 参数: in_features - 每个输入样本的大小out_features - 每个输出样本的大小bias - 如果设置为False,则图层不会学习附加偏差。默认值:True''' import torch x = torch.randn(3,...
阅读全文
摘要:'''Send messages through all edges >>> update all nodes.DGLGraph.update_all(message_func='default', reduce_func='default', apply_node_func='default')message_func --message function on the edgesreduce_...
阅读全文
摘要:(一)清除图 g.clear() (二)节点和边得数量 (二)类型和维度 (三)删除节点和边特征 (四)增加节点 (五)增加边 1.g.add_edge(i,j) 2.g.add_edges(src_list,dst_list) 3.g.add_edges(src_tensors,dst_tenso
阅读全文