2
Tensorflow 모델을 교육하고 출력 레이어의 텐서를 저장했습니다. 복원 할 때 출력 레이어의 텐서를 복원하고 예측을 시도했지만 자리 표시 자에 할당하지 않았다는 오류가 발생했습니다. 내 코드가 아래에 있습니다. 도와주세요.Tensorflow 복원 모델 및 예측
with tf.Session() as sess:
model_saver = tf.train.import_meta_graph(model_save_folder + '/my-model.meta')
model_saver.restore(sess, model_save_folder + '/my-model')
x = tf.placeholder('float')
output = tf.get_collection("output")[0] #output will be the tensor for model's last layer
print("Model restored.")
print('Initialized')
#print(sess.run(tf.get_default_graph().get_tensor_by_name('w_conv1:0')))
#collect list of preprocessed data on submission set
inputData = []
with open('stage1_sample_submission.csv') as f:
reader = csv.reader(f)
num = 0
for row in reader:
if num > 0:
patient = row[0]
#print(patient)
inputData.append(process_data(patient, img_px_size=IMG_SIZE_PX, hm_slices=SLICE_COUNT))
num += 1
#prediction!
prediction = sess.run(output, feed_dict={x: inputData})
print(prediction)
난 당신이 자리를 같은 방법으로 복원 할 필요가 있다고 생각에와 자리를 바꿉니다. x = tf.get_collection ("placeholder") [0] 자리 표시자를 원래 그래프에있는 이름으로 바꿉니다. – Steven
감사합니다. 작동합니다. –
답변을 게시하기 만하면되므로 질문을 닫을 수 있습니다. – Steven