如何解决如何解决KNIME和Python集成错误TensorFlow Error
我是 KNIME 的新手,在尝试执行“KNIME 深度学习 - 训练 MNIST 分类器”示例时收到错误消息。 我已经安装了 Anaconda、Python 3.7、TensorFlow 2.0.0 和 KNIME 扩展。
第一个是:
模块 'tensorflow' 没有属性 'placeholder' 回溯(大多数 最近通话最后一次):文件“”,第 21 行,在 AttributeError: 模块“tensorflow”没有属性“placeholder”
在那之后,我找到了一些教程,我在“DL Python Network Creator”中编辑了代码,如下所示: (我在注释第 3 行添加了一个 #,并添加了从 4 到 9 的行)
1 # variable name of the output network: output_network
2
3 # import tensorflow as tf
4 import tensorflow.compat.v1 as tf
5 from TFModel import TFModel
6
7 tf.compat.v1.disable_eager_execution()
8 tf.disable_v2_behavior()
9 sess = tf.compat.v1.Session()
input_shape = (None,28,1)
num_classes = 10
# Create a graph
graph = tf.Graph()
# Set the graph as default -> Create every tensor in this graph
with graph.as_default():
# Create an input tensor
x = tf.placeholder(tf.float32,shape=input_shape,name='input')
# Define the graph
# Convolutional Layer #1
conv1 = tf.layers.conv2d(inputs=x,filters=32,kernel_size=[5,5],padding="same",activation=tf.nn.relu)
# Pooling Layer #1
pool1 = tf.layers.max_pooling2d(inputs=conv1,pool_size=[2,2],strides=2)
# Convolutional Layer #2 and Pooling Layer #2
conv2 = tf.layers.conv2d(inputs=pool1,filters=64,activation=tf.nn.relu)
pool2 = tf.layers.max_pooling2d(inputs=conv2,strides=2)
# Dense Layer
pool2_flat = tf.reshape(pool2,[-1,7 * 7 * 64])
dense = tf.layers.dense(inputs=pool2_flat,units=512,activation=tf.nn.relu)
# Create an output tensor
y = tf.layers.dense(dense,num_classes,activation=tf.nn.softmax,name='output')
# Create the output network
output_network = TFModel(inputs={'input': x},outputs={'output': y},graph=graph)
然后我收到了第二条错误消息(第 44 行 = 代码的最后一行):
回溯(最近一次调用最后一次):文件“”,第 44 行,在 文件“C:\程序 Files\KNIME\plugins\org.knime.dl.tensorflow_4.2.0.v202006241028\py\TFModel.py",第 110 行,在 init 中 self._save_saved_model(self._sm_path) 文件“C:\Program Files\KNIME\plugins\org.knime.dl.tensorflow_4.2.0.v202006241028\py\TFModel.py”, 第 130 行,在 _save_saved_model 中 使用 tf.Session(graph=self.graph) 作为 sess: AttributeError: module 'tensorflow' has no attribute 'Session'
我的问题是:我可以做些什么来解决这个问题,因为我已经尝试重新安装、更新、降级 tensorflow(以及许多其他操作),但没有任何帮助?
我还尝试通过 KERAS(使用 Keras Network Learner)执行示例,而不是将示例与 TensorFlow(使用 DL Python Network Learner)结合使用。
你有什么建议吗?
谢谢!!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。