def write_predictions(): pred_list = [] prediction = tf.argmax(y_conv,1) length = int(len(validation) / test_batch) for i in range(length): a = i*test_batch pred_list = pred_list + prediction.eval(feed_dict={x: validation[a:a + test_batch],y_: v_labels[a:a + test_batch],keep_prob: 1.0}, session=sess).tolist() pred_list += prediction.eval(feed_dict={x: validation[length * test_batch:],y_: v_labels[length * test_batch:],keep_prob: 1.0}, session=sess).tolist() # print(len(validation)) # print(len(pred_list)) class_acc = {} class_amount = {} for i, pred in enumerate(pred_list): class_amount[val_labels[i]] = 0 class_acc[val_labels[i]] = 0 for i, pred in enumerate(pred_list): class_amount[val_labels[i]] += 1 if pred == val_labels[i]: class_acc[val_labels[i]] += 1 write_file = str(save_location + run_number + '_predictions.txt') with open(write_file, 'w') as f: for i, pred in enumerate(pred_list): string = str(str(pred) + ' ' + str(val_labels[i]) + ' ' + str(class_acc[val_labels[i]]) + '/' + str(class_amount[val_labels[i]]) + '=' + str(float(class_acc[val_labels[i]] / class_amount[val_labels[i]])) + '\n') f.write(string) error_gen.make_html(str(net_name + '_0'), write_file, 'kanji_dictionary_32_distort2.json', 'validation_32_distort2.json')
def write_predictions(): pred_list = [] prediction = tf.argmax(y_conv,1) length = int(len(validation) / test_batch) for i in range(length): a = i*test_batch pred_list = pred_list + prediction.eval(feed_dict={x: validation[a:a + test_batch],y_: v_labels[a:a + test_batch],keep_prob: 1.0}, session=sess).tolist() write_file = str(save_location + run_number + '_predictions.txt') with open(write_file, 'w') as f: for i, pred in enumerate(pred_list): string = str(str(pred) + ' ' + str(val_labels[i]) + '\n') f.write(string) error_gen.make_html(net_name, write_file, 'kanji_dictionary.json', 'validation.json')