我正在使用OpenAI基准来构建deepq模型。我通过修改baselines/common/tf_util.py
中的代码将模型导出为原始buff格式,如下所示:
def save_state(fname, sess=None):
from baselines import logger
logger.warn('save_state method is deprecated, please use save_variables instead')
sess = sess or get_session()
dirname = os.path.dirname(fname)
if any(dirname):
os.makedirs(dirname, exist_ok=True)
tf.global_variables_initializer()
tf.local_variables_initializer()
saver = tf.train.Saver()
saver.save(tf.get_default_session(), fname)
tf.train.write_graph(sess.graph_def, './model', 'deepq_0515.pb', as_text=False)
tf.train.write_graph(sess.graph_def, './model', 'deepq_0515.pbtxt')
然后我在C ++中加载模型以执行推理。模型很好,很好。但是,当我这样做时:
tensorflow::Status status =
session_->Run({{"deepq/observation", input_tensor}}, {"deepq/Select"}, {}, &output_tensor);
我遇到以下错误。知道我错过了什么吗?
precondition:Attempting to use uninitialized value deepq/q_func/action_value/fully_connected/biases
[[{{node deepq/q_func/action_value/fully_connected/biases/read}}]]
:
precondition: Attempting to use uninitialized value deepq/q_func/action_value/fully_connected_1/weights
[[{{node deepq/q_func/action_value/fully_connected_1/weights/read}}]]