Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 如何从训练lstm单元中读取每个特征的权重_Tensorflow - Fatal编程技术网

Tensorflow 如何从训练lstm单元中读取每个特征的权重

Tensorflow 如何从训练lstm单元中读取每个特征的权重,tensorflow,Tensorflow,我在TF1.1.0上使用了几个时间序列作为特征(3个特征作为输入)到LSTM模型(1个回归输出)。主要功能启动了一个会话,如下所示: model = SKCompat(learn.Estimator(model_fn=lstm_model, model_dir=LOG_DIR, params={'learning_rate': Learning_rate})) model.fit(trainX, trainY, steps=steps)

我在TF1.1.0上使用了几个时间序列作为特征(3个特征作为输入)到LSTM模型(1个回归输出)。主要功能启动了一个会话,如下所示:

model = SKCompat(learn.Estimator(model_fn=lstm_model, 
              model_dir=LOG_DIR,
              params={'learning_rate': Learning_rate}))
model.fit(trainX, trainY, steps=steps)
lstm_模型的主要功能如下:

lstm_cell = tf.contrib.rnn.LSTMCell(hidden, state_is_tuple=True)
lstm_cell = tf.contrib.rnn.DropoutWrapper(cell=lstm_cell, output_keep_prob=0.1)
(output, state) = tf.nn.dynamic_rnn(cell=lstm_cell, inputs=features, dtype=tf.float32)
在训练和保存模型(由默认tf函数本身自动保存)后,我可以通过主函数中的“导入元图”和“恢复”读取LSTM单元的权重。权重看起来像(131512)数组

问题是如何从这样的权重数组中知道每个特征的权重,即每个特征对输出的权重


顺便说一句,如果您使用默认的tf功能,我可以在培训时保存自定义模型吗?如何做?非常感谢。

我认为重量[131512]可以这样解释:

因为有128个隐藏层,所以有3个功能

  • D-131变量是3个特征、128个隐藏层的权重(仍然不确定)
  • D-512变量是每个隐藏层中输入门、遗忘门、单元状态和输出门的权重,4*128=512。 我说得对吗

  • 解释:如果我向输入中添加一个以上的特征,权重将是(132512)数组。批处理大小=1