Я обучил модель в Tensorflow 1.14 и сохранил контрольную точку и метафору. Теперь я хочу использовать эту модель, чтобы оценить, как она работает с новыми данными.
restorer = tf.train.import_meta_graph(meta_path)
graph = tf.get_default_graph()
with graph.as_default() as default_graph:
train_files = [join(TRAIN_DIR, f) for f in listdir(TRAIN_DIR) if isfile(join(TRAIN_DIR, f))]
eval_image_batch, eval_target_batch = input_fn(train_files)
tf.add_to_collection("eval_image_batch", eval_image_batch)
tf.add_to_collection("eval_target_batch", eval_target_batch)
restorer.restore(sess, check_path)
print(sess.run(['NeuralNet/CNN/conv_0/weights:0']))
print(sess.run(['NeuralNet/CNN/conv_0/weights']))
with tf.variable_scope('NeuralNet', reuse=True):
eval_output = network.inference(eval_image_batch)
tf.add_to_collection('eval_output0_image', eval_output_image)
Когда я ее запускаю, я получаю следующую ошибку:
ValueError: Variable NeuralNet/CNN/conv_0/weights does not exist, or was not created with tf.get_variable(). Did you mean to set reuse=tf.AUTO_REUSE in VarScope?
Я могу распечатать "NeuralNet/CNN/conv_0/weights:0"
и получите значения. Когда я распечатываю "NeuralNet/CNN/conv_0/weights"
, я получаю None.
Как я могу объединить все веса: 0 к весам и использовать их повторно?