如何解决在Visual Studio 2017中使用LSTM层创建keras模型时出现NotImplementedError
我的代码是:
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
我既不能使用Sequentional API也不能使用Functional API添加LSTM层。 自定义模型效果很好。 这可能是什么原因?
Tensorflow版本为2.3.0。 Python版本3.6。
该错误与Visual Studio有关(当我不使用VS运行时没有错误)。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。