I'm running this code to classify house numbers from Google Streetview, it runs and then goes into some sort of loop in the first step, I don't know why.
I have narrowed down the problem to be from the input pipeline.
def convert_labels(labels):
for i in range(len(labels)):
if len(labels[i])==2:
labels[i].append(10)
elif len(labels[i])==1:
labels[i].append(10)
labels[i].append(10)
return labels
with open('whole_data.pickle','rb') as f:
data_obj=pickle.load(f)
train_images=np.asarray(data_obj['train_data'][0],np.float32)
train_labels=np.asarray(convert_labels(data_obj['train_data'][1]),np.int32)
whole_train=[train_images,train_labels]
whole_train[0]=np.reshape(whole_train[0][:],[whole_train[0].shape[0],32,32,1])
graph = tf.Graph()
with graph.as_default():
with tf.name_scope('Pipelines'):
image_batch,label_batch=tf.train.shuffle_batch([whole_train[0],
batch_size=64,capacity=50000,enqueue_many=True,min_after_dequeue=100,
name='train_pipe')
with tf.Session(graph=graph) as sess:
tf.global_variables_initializer().run()
writer=tf.summary.FileWriter('/tmp/Mark2_logs',graph=graph)
step=1
print('hi')
for step in range(100):
print('step %d' %(step))
batch_images,batch_labels=sess.run([image_batch,label_batch])
plt.imshow(batch_images[0])
I've attached a link to my Google Drive where I've stored my data and code:
https://drive.google.com/open?id=0B-hAFmA-zmGdTndyaHJzWEdQaFE
It contains three files.
- model.ipynb - it's the main file which has CNN and session,
- preprocess.ipynb - it's the code I used to process my data and
- data.pickle - I've already processed and stored my data in this file so you don't have to run preprocess.ipynb.