我的代码是:
import tensorflow as tf
keras_model = tf.keras.Sequential([
tf.keras.layers.Embedding(1000, 16),
tf.keras.layers.LSTM(32),
])
我有一个错误:
NotImplementedError:无法转换符号张量
(lstm/strided_slice:0) 到 numpy 数组。此错误可能表明
您正在尝试将张量传递给 NumPy 调用,但该调用不受支持
调用堆栈:
Tensor.__array__ in ops line 848 Python
_wrapreduction in fromnumeric line 90 Python
prod in fromnumeric line 2962 Python
prod in C:\Users\FA\Google Drive\Colab Notebooks\PoetryTransformer\Accentizer\<__array_function__ internals> line 6 Python
_constant_if_small in array_ops line 2732 Python
zeros in array_ops line 2794 Python
wrapped in _tag_zeros_tensor in array_ops line 2747 Python
wrapper in add_dispatch_support in dispatch line 201 Python
create_zeros in _generate_zero_filled_state in recurrent line 2981 Python
<listcomp> in nest line 635 Python
map_structure in nest line 635 Python
_generate_zero_filled_state in recurrent line 2984 Python
_generate_zero_filled_state_for_cell in recurrent line 2968 Python
LSTMCell.get_initial_state in recurrent line 2524 Python
RNN.get_initial_state in recurrent line 646 Python
RNN._process_inputs in recurrent line 862 Python
LSTM.call in recurrent_v2 line 1108 Python
Layer._functional_construction_call in base_layer line 1117 Python
Layer.__call__ in base_layer line 926 Python
RNN.__call__ in recurrent line 663 Python
Sequential.add in sequential line 221 Python
_method_wrapper in no_automatic_dependency_tracking in base line 457 Python
Sequential.__init__ in sequential line 142 Python
_method_wrapper in no_automatic_dependency_tracking in base line 457 Python
ragged module line 5 Python
我无法使用顺序 API 或功能 API 添加 LSTM 层。
定制模型效果很好。
这可能是什么原因?
张量流版本是2.3.0。
Python 版本 3.6。
该错误与 Visual Studio 有关(当我运行没有 VS 时没有错误)。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)