Skip to content Skip to sidebar Skip to footer

Tensorflow Training Cnn On Custom Images

All the tensorflow tutorials do a great job, however, they all use preprocessed downloadable datasets that work out of the box. Their tutorial on MNIST is the perfect example. For

Solution 1:

classifier.train function expects numpy arrays, but not tensors. Hence you need to convert example_batch, label batch by evaluating them with a session, but not wrapping them using np.array() function. (Explanation)

sess.run(tf.initialize_all_variables())

tf.train.start_queue_runners(sess)

classifier = tf.estimator.Estimator(
    model_fn=cnn_model_fn, model_dir="./test")

train_input_fn = tf.estimator.inputs.numpy_input_fn(
      x={'x':getTrainImages().eval()},
      y=getLabels().eval(),
      batch_size=10,
      num_epochs=None,
      shuffle=True)

classifier.train(
      input_fn=train_input_fn,
      steps=20,
      )

Solution 2:

I recommended to apply tools on top of tensorflow. You might consider to code it through roNNie, Theano, Keras, Torch or Caffe.

Post a Comment for "Tensorflow Training Cnn On Custom Images"