TypeError:如果启用了Tensor相等,则Tensor无法散列。而是使用tensor.experimental_ref()作为键。 + Colab中的keras错误

时间:2020-02-18 09:12:09

标签: keras tensorflow2.0

运行以下代码的最后一行时,出现错误-

TypeError:如果启用了Tensor相等,则Tensor无法散列。相反,请使用tensor.experimental_ref()作为键。

我正在Tensorflow 2.0版的Colab中运行代码

input_data = Input(name='the_input', shape=(208, 224,224, 3), dtype=dtype)
layer1 =        TimeDistributed(MobileNet(weights='imagenet',include_top=False))(input_data)
layer2 =  TimeDistributed(GlobalAveragePooling2D())(layer1)
##********************************* Create Bidirectional LSTM*************************************
for i in range(0, n_layers):
     x = Bidirectional(CuDNNLSTM(20, kernel_initializer=kernel_init_rnn, bias_initializer=bias_init_rnn,
                                        unit_forget_bias=True, return_sequences=True),
                              merge_mode='sum', name='CuDNN_bi_lstm'+str(i+1))(layer2)
 # 1 fully connected layer DNN ReLu with default 20% dropout
x = TimeDistributed(Dense(units=20, kernel_initializer=kernel_init_dense, bias_initializer=bias_init_dense,
                              activation='relu'), name='fc_4')(x)
x = TimeDistributed(Dropout(dropout), name='dropout_4')(x)

    # Output layer with softmax
y_pred = TimeDistributed(Dense(units=30, kernel_initializer=kernel_init_dense,                                   bias_initializer=bias_init_dense,activation='softmax'),name='softmax')x)
Model(inputs=input_data, outputs=y_pred).summary()

我尝试安装和卸载以下内容并重新启动运行时,但徒劳无功。

!pip install tensorflow-probability==0.8.0rc0
!pip uninstall -y tf-nightly tensorflow
!pip install tf-nightly-2.0-preview --quiet
!pip install "tensorflow-hub>=0.4"

0 个答案:

没有答案