tf-slim

How to use evaluation_loop with train_loop in tf-slim

元气小坏坏 提交于 2019-12-02 23:37:35
I'm trying to implement a few different models and train them on CIFAR-10, and I want to use TF-slim to do this. It looks like TF-slim has two main loops that are useful during training: train_loop and evaluation_loop. My question is: what is the canonical way to use these loops? As a followup: is it possible to use early stopping with train_loop? Currently I have a model and my training file train.py looks like this import ... train_log_dir = ... with tf.device("/cpu:0"): images, labels, dataset = set_up_input_pipeline_with_fancy_prefetching( subset='train', ... ) logits, end_points = set_up

Tensorflow Slim restore model and predict

≡放荡痞女 提交于 2019-12-01 07:29:53
问题 I'm currently trying to learn how to use TF-Slim and I'm following this tutorial: https://github.com/mnuke/tf-slim-mnist. Assuming that I already have a trained model saved in a checkpoint, how do I now use that model and apply it? Like, in the tutorial how do I use my trained MNIST model and feed in a new set of MNIST images, and print the predictions? 回答1: You can try a workflow like: #obtain the checkpoint file checkpoint_file= tf.train.latest_checkpoint("./log") #Construct a model as such

Decoding tfrecord with tfslim

蹲街弑〆低调 提交于 2019-11-30 15:31:50
I use Python 2.7.13 and Tensorflow 1.3.0 on CPU. I want to use DensNet( https://github.com/pudae/tensorflow-densenet ) for regression problem. My data contains 60000 jpeg images with 37 float labels for each image. I saved my data into tfrecords files by: def Read_Labels(label_path): labels_csv = pd.read_csv(label_path) labels = np.array(labels_csv) return labels[:,1:] ` def load_image(addr): # read an image and resize to (224, 224) img = cv2.imread(addr) img = cv2.resize(img, (224, 224), interpolation=cv2.INTER_CUBIC) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) img = img.astype(np.float32)

TensorFlow: does tf.train.batch automatically load the next batch when the batch has finished training?

♀尐吖头ヾ 提交于 2019-11-28 22:47:27
问题 For instance, after I have created my operations, fed the batch data through the operation and run the operation, does tf.train.batch automatically feed in another batch of data to the session? I ask this because tf.train.batch has an attribute of allow_smaller_final_batch which makes it possible for the final batch to be loaded as a size lesser than the indicated batch size. Does this mean even without a loop, the next batch could be automatically fed? From the tutorial codes I am rather