Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.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
Python softmax之前的Tensorflow NaN_Python_Machine Learning_Tensorflow_Deep Learning_Lstm - Fatal编程技术网

Python softmax之前的Tensorflow NaN

Python softmax之前的Tensorflow NaN,python,machine-learning,tensorflow,deep-learning,lstm,Python,Machine Learning,Tensorflow,Deep Learning,Lstm,我正在使用Tensorflow来训练一个基于神经的强化学习代理。想法如下,首先我训练一个LSTM(基于真实数据,从人类偏见开始)来预测人类未来的行为。然后我使用我的LSTM的细胞状态作为强化学习的状态 然而,我注意到内部状态有随时间变化的趋势,因此,内部状态并不直接适用于强化学习。显然,这是一个常见的问题,可通过标准化层LSTM解决。我尝试了NL LSTM的tensorflow实现,但现在,我无法对其进行训练,因为TF将NaN权重置于其输出 我使用ADAM优化并尝试了不同的权重,没有任何变化,我

我正在使用Tensorflow来训练一个基于神经的强化学习代理。想法如下,首先我训练一个LSTM(基于真实数据,从人类偏见开始)来预测人类未来的行为。然后我使用我的LSTM的细胞状态作为强化学习的状态

然而,我注意到内部状态有随时间变化的趋势,因此,内部状态并不直接适用于强化学习。显然,这是一个常见的问题,可通过标准化层LSTM解决。我尝试了NL LSTM的tensorflow实现,但现在,我无法对其进行训练,因为TF将NaN权重置于其输出

我使用ADAM优化并尝试了不同的权重,没有任何变化,我还尝试增加我的LSTM中的单位数量,但没有任何改进

有人看到我代码中的问题吗

with tf.variable_scope("system_lstm") as scope:
    no_units_system=128
    _seq_system = tf.placeholder(tf.float32, [batch_size, max_length_system, system_inputShapeLen], name='seq_')
    _seq_length_system = tf.placeholder(tf.int32, [batch_size], name='seq_length_')

    cell_system = tf.contrib.rnn.LayerNormBasicLSTMCell(
            no_units_system)

    output_system, hidden_states_system = tf.nn.dynamic_rnn(
        cell_system,
        _seq_system,
        sequence_length=_seq_length_system,
        dtype=tf.float32
    )

    out2_system = tf.reshape(output_system, shape=[-1, no_units_system])
    out2_system =  tf.layers.dense(out2_system, system_outputShapeLen)

    out_final_system = tf.reshape(out2_system, shape=[-1, max_length_system, system_outputShapeLen])
    y_system_ = tf.placeholder(tf.float32, [None, max_length_system, system_outputShapeLen])

    softmax_system = tf.nn.softmax(out_final_system, dim=-1)  
    loss_system = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=out_final_system, labels=y_system_))
    optimizer = tf.train.AdamOptimizer(learning_rate=1e-10)
    minimize_system = optimizer.minimize(loss_system)

输出中出现NAN的一个可能原因是您有NAN输入。确保输入中没有NAN。你试过剪裁渐变吗。您所说的“基于神经的强化学习代理”是指使用LSTM而不是NN的DQN/DDQN吗?您的网络是否可能由于大梯度而爆炸?