赞
踩
dynamic computation graph(DCG)
PyTorch autograd looks a lot like TensorFlow: in both frameworks we define a computational graph, and use automatic differentiation to compute gradients. The biggest difference between the two is that TensorFlow’s computational graphs are static and PyTorch uses dynamic computational graphs.
符号主义的计算首先定义各种变量,然后建立一个“计算图”,计算图规定了各个变量之间的计算关系。建立好的计算图需要编译以确定其内部细节,然而,此时的计算图还是一个“空壳子”,里面没有任何实际的数据,只有当你把需要运算的输入放进去后,才能在整个模型中形成数据流,从而形成输出值。
编写一个深度网络需要关注的地方是:
一个典型的神经网络的训练过程是这样的:
* __init__(self, 构造参数1, 构造参数2, 构造参数3)
* 初始化网络参数
* bulid(self)
* 初始化网络模块
* init_weight(self)
* 初始化网络参数
* forward(self)
* 组织网络结构
*
pass
>>> rnn = nn.RNN(10, 20, 2)input_size, hidden_size, num_layers
>>> input = torch.randn(5, 3, 10) seq_len, batch, input_size
>>> h0 = torch.randn(2, 3, 20) num_layers * num_directions, batch, hidden_size
>>> output, hn = rnn(input, h0)
如何加载预训练的embedding?
原理
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。