0

I am working on self driving car in nfs using neural network.

I have training data in hdf5 format. Using tensorflow to train model.

At first I thought it will take 100 but it is not stopping after 100.

Do I have to stop it manually (ctrl+C)?

import h5py 
import numpy as np 
import tensorflow as tf 
from googlenet import googlenet
#from alexnet import alexnet

# Training Parameters
learning_rate = 0.001
WIDTH = 200
HEIGHT = 150
EPOCHS = 100
MODEL_NAME = "draj_mod"

f = h5py.File("wasd_training_data.hdf5", "r")
print("File loaded")
model = googlenet(WIDTH, HEIGHT, learning_rate)

DATASET_COUNTER = 0 
for dataset in f.keys():
    DATASET_COUNTER+=1

DATASET_COUNTER = int(DATASET_COUNTER/2) 

for i in range(EPOCHS):
    for counter in range(DATASET_COUNTER):
        #HDF5 data is stored as dataset_#_X or dataset_#_Y
        label_X = "dataset" + str(counter) + "_X"
        label_Y = "dataset" + str(counter) + "_Y"

        data_X = np.array(f[label_X])
        data_Y = np.array(f[label_Y])

        train_data_X = data_X[:-500].reshape(-1, WIDTH, HEIGHT, 3)
        train_data_Y = data_Y[:-500]

        test_data_X = data_X[-500:].reshape(-1, WIDTH, HEIGHT, 3)
        test_data_Y = data_Y[-500:]

        model.fit({'input' : train_data_X}, {'targets' : train_data_Y}, n_epoch = 1, validation_set=({'input': test_data_X}, {'targets': test_data_Y}), snapshot_step = 1000, show_metric=True, run_id=MODEL_NAME)
    if(i%5 == 0):
        model.save(MODEL_NAME)

    # tensorboard --logdir=foo:F:/Workspace/nfssd/log
    #model.fit(X, Y, n_epoch=1000, validation_set=0.1, shuffle=True,
    #        show_metric=True, batch_size=64, snapshot_step=200,
    #        snapshot_epoch=False, run_id='googlenet_oxflowers17')
1
  • EPOCHS * DATASET_COUNTER Commented Feb 24, 2018 at 8:22

1 Answer 1

1

As you are calling the below-mentioned lines inside nested loop hence it will be called EPOCHS*DATASET_COUNTER times.

model.fit({'input' : train_data_X}, {'targets' : train_data_Y}, n_epoch = 1, validation_set=({'input': test_data_X}, {'targets': test_data_Y}), snapshot_step = 1000, show_metric=True, run_id=MODEL_NAME)

If you wish to run it only hundred times, please accumulate all your dataset in one and then call it outside the second loop (DATASET-COUNTER) and directly inside the first loop (EPOCH one).

Sign up to request clarification or add additional context in comments.

1 Comment

can you please tell me which line of code i should directly write inside first loop? is that the one you mentioned?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.