【发布时间】:2021-09-02 05:50:08
【问题描述】:
我正在运行直接取自谷歌示例之一的示例代码,用于创建 RNN,但运行时出现错误。我在 VisualStudio 2019、带有 i7-10510U 和 mx230 的 Windows 10 x64 上运行它
代码:
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
model = keras.Sequential()
# Add an Embedding layer expecting input vocab of size 1000, and
# output embedding dimension of size 64.
model.add(layers.Embedding(input_dim=1000, output_dim=64))
# Add a LSTM layer with 128 internal units.
model.add(layers.SimpleRNN(128))
# Add a Dense layer with 10 units.
model.add(layers.Dense(10))
model.summary()
model.add(layers.SimpleRNN(128)) 上的错误:
无法将符号张量 (simple_rnn/strided_slice:0) 转换为 numpy 数组。此错误可能表明您正在尝试通过 不支持 NumPy 调用的张量
【问题讨论】:
标签: python tensorflow deep-learning recurrent-neural-network