Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python tensorflow 2中的ConvLSTMCell_Python_Tensorflow_Tensorflow2.0_Tf.keras - Fatal编程技术网

Python tensorflow 2中的ConvLSTMCell

Python tensorflow 2中的ConvLSTMCell,python,tensorflow,tensorflow2.0,tf.keras,Python,Tensorflow,Tensorflow2.0,Tf.keras,从1升级到tensorflow版本2后,tf.contrib中的所有模块都被折旧 为了应用,我需要每个单元格的状态 最初,我在tf版本1中所做的是: #ConvLSTMCell convlstm_layer = tf.contrib.rnn.ConvLSTMCell( conv_ndims = 2, input_shape = [10, 10, 32], output_channels =

从1升级到tensorflow版本2后,tf.contrib中的所有模块都被折旧

为了应用,我需要每个单元格的状态

最初,我在tf版本1中所做的是:


#ConvLSTMCell
convlstm_layer = tf.contrib.rnn.ConvLSTMCell(
                conv_ndims = 2,    
                input_shape = [10, 10, 32],
                output_channels = 32,
                kernel_shape = [2, 2],
                use_bias = True,
                skip_connection = False,
                forget_bias = 1.0,
                initializers = None,
                )


# Run RNN with ConvLSTMCell
outputs, state = tf.compat.v1.nn.dynamic_rnn(convlstm_layer, conv1_out, time_major = False, dtype = input.dtype)
现在,我正在尝试将其转换为tf版本2中的代码

然而,正如我前面提到的,这两个模块(tf.contrib和tf.compat)都被折旧了

我找到了tf.compat.v1.nn.dynamic的替代品,它是tf.keras.layers.rnn


但是没有这样的函数来创建ConvLSTMCell。有什么建议吗

我想你要找的是:

您可以在代码中导入它,如下所示:

import tensorflow as tf
conv_lstm_layer = tf.keras.layers.ConvLSTM2D(my_parameters)

我想你要找的是:

您可以在代码中导入它,如下所示:

import tensorflow as tf
conv_lstm_layer = tf.keras.layers.ConvLSTM2D(my_parameters)

我看到了这个错误
ValueError:RNN单元格应该有一个属性
state\u size`(整数元组,每个RNN状态一个整数)。`好吧,你需要检查参数,不要期望复制粘贴TF1.X版本中的所有参数并从头开始工作。我的意思是,tf.keras.layers.ConvLSTM2D应具有要传递到tf.keras.layers.RNN的“状态大小”属性。此层中缺少了一组要在tf.kears.layers.RNNI中实现的单元属性。请参见此错误
ValueError:RNN单元格应该有一个属性
state\u size`(整数元组,每个RNN状态一个整数)。`好吧,你需要检查参数,不要期望复制粘贴TF1.X版本中的所有参数并从头开始工作。我的意思是,tf.keras.layers.ConvLSTM2D应具有要传递到tf.keras.layers.RNN的“状态大小”属性。此层中缺少一组要实现到tf.kears.layers.rnn中的单元格属性。实际上,您仍然可以在TF2中获取此单元格,方法是从tensorflow.python.keras.layers.convolutional\u Recurrentive import ConvLSTM2DCell或从tensorflow import keras执行
;从keras.layers import ConvLSTM2DCell
实际上,通过从tensorflow.python.keras.layers.convolutional\u导入ConvLSTM2DCell或从tensorflow import keras执行
操作,您仍然可以在TF2中获取此单元格;从keras.layers导入ConvLSTM2DCell