我已经尝试过:
saver = tf.train.import_meta_graph(tf.train.latest_checkpoint(model_path)+".meta")
sess = tf.Session()
if(tf.train.checkpoint_exists(tf.train.latest_checkpoint(model_path))):
saver.restore(sess, tf.train.latest_checkpoint(model_path))
print(tf.train.latest_checkpoint(model_path) + "Session Loaded for Testing")
graph = tf.get_default_graph()
X = graph.get_tensor_by_name('input:0')
y = graph.get_tensor_by_name('output:0')
loss = tf.reduce_mean(tf.square(outputs - y)) # loss function = mean squared error
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate)
training_op = optimizer.minimize(loss))
我遇到以下错误:
ValueError: Duplicate node name in graph: 'rnn/multi_rnn_cell/cell_0/layer0/kernel/Adam'
我尝试使用错误中提到的名称:
optimizer = graph.get_operation_by_name("rnn/multi_rnn_cell/cell_0/layer0/kernel/Adam")
然后我收到此错误:
AttributeError: 'Operation' object has no attribute 'minimize'
请让我知道如何从模型访问training_op
?