首页 > 解决方案 > 循环神经网络 (RNN) 代码中的错误

问题描述

代码:

from IPython.display import clear_output
from random import sample

s.run(tf.global_variables_initializer())

batch_size = 32
history = []

for i in range(1000):
    batch = to_matrix(sample(names, batch_size), max_len=MAX_LENGTH)
    loss_i, _ = s.run([loss, optimize], {input_sequence: batch})
    
    history.append(loss_i)
    
    if (i + 1) % 100 == 0:
        clear_output(True)
        plt.plot(history, label='loss')
        plt.legend()
        plt.show()

assert np.mean(history[:10]) > np.mean(history[-10:]), "RNN didn't converge"

错误:

InvalidArgumentError (see above for traceback): Input to reshape is a tensor with 30720 values, but the requested shape requires a multiple of 56

标签: tensorflowmachine-learningdeep-learningneural-networkrecurrent-neural-network

解决方案


推荐阅读