我导入了 tensorflow 模块,但无法使用 tf.contrib。我不知道是什么问题。我尝试在不同版本中运行它,但我一直得到相同的输出。
模块导入:
import tensorflow.compat.v1 as tf1
tf1.disable_v2_behavior()
import tensorflow as tf2
Run Code Online (Sandbox Code Playgroud)
代码:
tf2.contrib.rnn.LSTMCell(num_units=num_nodes[li],
state_is_tuple=True,
initializer= tf.contrib.layers.xavier_initializer()
)
Run Code Online (Sandbox Code Playgroud)
输出:
AttributeError: module 'tensorflow' has no attribute 'contrib'
Run Code Online (Sandbox Code Playgroud)