tensorflow - 循环神经网络 (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
解决方案
推荐阅读
- javascript - 我是否必须在 useState 中设置每个属性的初始值?
- ios - 主线程检查时UILabel类别块属性崩溃
- python-3.x - 难以理解每个变量存储在内存中的位数
- nginx - 如何使用 nginx 将 Next.js 应用程序部署到子路径?
- flutter - Flutter Firebase 注册在模拟器上工作,但不能在真正的 apk 上工作
- ios - SwiftUI WebKit WKWebView:如何支持多 url
- javascript - 如何处理未捕获的错误:对象作为 React 子错误无效
- android - Android - Kotlin - Firebase Google 登录在发布应用后无法正常工作
- python - numpy - 给定二维矩阵的按列和按行求和
- python - 如何将大型数据集拆分为块并执行 fit_transform / fit_resample 和联合结果?