【发布时间】:2022-01-13 17:23:51
【问题描述】:
我遇到了这个错误,我该如何解决?
NotImplementedError: Cannot convert a symbolic Tensor (lstm_2/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported
# train the model
model = define_model(vocab_size, max_length)
# train the model, run epochs manually and save after each epoch
epochs = 20
steps = len(train_descriptions)
for i in range(epochs):
# create the data generator
generator = data_generator(train_descriptions, train_features, tokenizer, max_length)
# fit for one epoch
model.fit_generator(generator, epochs=1, steps_per_epoch=steps, verbose=1)
# save model
model.save('model_' + str(i) + '.h5')
【问题讨论】:
-
您是否使用带有 numpy 调用的自定义层?如果是,请检查此 numpy 函数是否有 tensorflow 对应部分,通常必须为 tensorflow 适配函数
-
你读过this thread吗?
-
@MohanRadhakrishnan 是的,现在我通过更改 ops.py 文件解决了这个问题,谢谢
标签: python numpy tensorflow tensorflow-datasets