#print(pred_probs.shape) test_df = pd.DataFrame(data=pred_probs.T, columns=breeds) test_df.index = ids if agg_test_df is None: agg_test_df = test_df else: agg_test_df = agg_test_df.append(test_df) except tf.errors.OutOfRangeError: print('End of the dataset') agg_test_df.to_csv(paths.TEST_PREDICTIONS, index_label='id', float_format='%.17f') print('predictions saved to %s' % paths.TEST_PREDICTIONS) if __name__ == '__main__': with tf.Graph().as_default(): x = tf.placeholder(dtype=tf.float32, shape=(consts.INCEPTION_CLASSES_COUNT, None), name="x") _, output_probs, _, _ = denseNN.denseNNModel(x, consts.HEAD_MODEL_LAYERS, gamma=0.01) infer_test(consts.CURRENT_MODEL_NAME, output_probs, x)
print(one_hot_decoder(features['inception_output'])) print(features['label']) print(features['inception_output'].shape) if __name__ == '__main__': with tf.Graph().as_default() as g, tf.Session().as_default() as sess: tensors = unfreeze_into_current_graph( paths.IMAGENET_GRAPH_DEF, tensor_names=[ consts.INCEPTION_INPUT_TENSOR, consts.INCEPTION_OUTPUT_TENSOR ]) _, output_probs, y, _ = denseNN.denseNNModel(tf.reshape( tensors[consts.INCEPTION_OUTPUT_TENSOR], shape=(-1, 1), name=consts.HEAD_INPUT_NODE_NAME), consts.HEAD_MODEL_LAYERS, gamma=0.01) tf.global_variables_initializer().run() saver = tf.train.Saver() saver.restore( sess, os.path.join(paths.CHECKPOINTS_DIR, consts.CURRENT_MODEL_NAME)) freeze_current_model(consts.CURRENT_MODEL_NAME, output_node_names=consts.OUTPUT_NODE_NAME) if __name__ == '__main__': convert(consts.CURRENT_MODEL_NAME, export_dir='/tmp/dogs_1')
batch_size=BATCH_SIZE, train_sample_size=consts.TRAIN_SAMPLE_SIZE) dev_set = sess.run(get_dev_ds) dev_set_inception_output = dev_set[consts.INCEPTION_OUTPUT_FIELD] dev_set_y_one_hot = dev_set[consts.LABEL_ONE_HOT_FIELD] train_sample = sess.run(get_train_sample_ds) train_sample_inception_output = train_sample[ consts.INCEPTION_OUTPUT_FIELD] train_sample_y_one_hot = train_sample[consts.LABEL_ONE_HOT_FIELD] x = tf.placeholder(dtype=tf.float32, shape=(consts.INCEPTION_CLASSES_COUNT, None), name="x") cost, output_probs, y, nn_summaries = denseNN.denseNNModel( x, consts.HEAD_MODEL_LAYERS, gamma=0.001) optimizer = tf.train.AdamOptimizer( learning_rate=LEARNING_RATE).minimize(cost) dev_error_eval = error(x, output_probs, name='test_error') train_error_eval = error(x, output_probs, name='train_error') nn_merged_summaries = tf.summary.merge(nn_summaries) tf.global_variables_initializer().run() writer = tf.summary.FileWriter( os.path.join(paths.SUMMARY_DIR, model_name)) bar = pyprind.ProgBar(EPOCHS_COUNT, update_interval=1, width=60) saver = tf.train.Saver()