小编Luc*_*oni的帖子

无效的参数:在图表中找不到在feed_devices或fetch_devices中指定的参数

我正在尝试使用C ++ API在Tensorflow中运行从Keras导出的模型。该模型已正确导出和导入,但是当我尝试在C ++中运行会话时,我在get Run成员中传递的变量名称tensorflow::Session被修改,从而导致错误:

Invalid argument: Tensor Output0:0, specified in either feed_devices or fetch_devices was not found in the Graph
Run Code Online (Sandbox Code Playgroud)

这是我在Keras中建立的模型:

Invalid argument: Tensor Output0:0, specified in either feed_devices or fetch_devices was not found in the Graph
Run Code Online (Sandbox Code Playgroud)

遵循https://github.com/amir-abdi/keras_to_tensorflow中实现的方法,使用tensorflow.python.framework.graph_util 和导出模型tensorflow.python.framework.graph_io

然后使用C ++ API将模型导入Tensorflow:

S = Input(shape=[state_size], name='Input')
h0 = Dense(self.HIDDEN1_UNITS, name='Hidden1', kernel_initializer=keras.initializers.RandomUniform())(S)
h0_a = Activation('relu')(h0)
h1 = Dense(self.HIDDEN2_UNITS, name='Hidden2', kernel_initializer=keras.initializers.RandomUniform())(h0_a)
h1_a = Activation('relu')(h1)
output = Dense(1)(h1_a)
output_a = Activation('tanh', name='Output0')(output)
model = Model(S,output_a) …
Run Code Online (Sandbox Code Playgroud)

c++ python keras tensorflow

7
推荐指数
0
解决办法
1179
查看次数

标签 统计

c++ ×1

keras ×1

python ×1

tensorflow ×1