【发布时间】:2016-10-05 12:44:35
【问题描述】:
我正在尝试在“纯”TensorFlow 中使用 Keras 的模型(我想在 Android 应用中使用它)。我已成功将 Keras 模型导出到 protobuf 并将其导入到 Tensorflow。但是运行 tensorflow 模型需要提供输入和输出张量的名称,我不知道如何找到它们。我的模型如下所示:
seq = Sequential()
seq.add(Convolution2D(32, 3, 3, input_shape=(3, 15, 15), name="Conv1"))
....
seq.add(Activation('softmax', name="Act4"))
seq.compile()
当我在 TensorFlow 中打印张量时,我可以找到:
Tensor("Conv1_W/initial_value:0", shape=(32, 3, 3, 3), dtype=float32)
Tensor("Conv1_W:0", dtype=float32_ref)
Tensor("Conv1_W/Assign:0", shape=(32, 3, 3, 3), dtype=float32_ref)
Tensor("Conv1_W/read:0", dtype=float32)
Tensor("Act4_sample_weights:0", dtype=float32)
Tensor("Act4_target:0", dtype=float32)
但是,没有形状为 (3,15,15) 的张量。
我已经看到 here 我可以添加“my_input_tensor”作为输入,但是我不知道它是哪种类型 - 我已经尝试过 TensorFlow 和 Keras 的占位符,他们给了我这个错误:
/XXXXXXXXX/lib/python2.7/site-packages/keras/engine/topology.pyc in __init__(self, input, output, name)
1599 # check that x is an input tensor
1600 layer, node_index, tensor_index = x._keras_history
-> 1601 if len(layer.inbound_nodes) > 1 or (layer.inbound_nodes and layer.inbound_nodes[0].inbound_layers):
1602 cls_name = self.__class__.__name__
1603 warnings.warn(cls_name + ' inputs must come from '
AttributeError: 'NoneType' object has no attribute 'inbound_nodes'
【问题讨论】:
-
您找到解决方案了吗?目前面临同样的问题。
-
这个链接可能对你有用stackoverflow.com/questions/62092966/…
标签: machine-learning tensorflow keras