steerSampleSTD=steer.std() np.savez("steerstats.npz", [steerSampleMean, steerSampleSTD]) from testmodel import model model.load_weights('Nweights.h5') img_files=glob.glob(os.path.join(data_dir, 'imgs*.npz')) imgs=np.zeros((100*len(img_files), 78, 128, 3)).astype('float32') i=0 for imgfile in sorted(img_files): imdata=np.load(imgfile)['arr_0'].astype('float32') j=0 for tim in imdata: im=tim[0:78, :] immean=im.mean() imdev=im.std() imgs[i*100+j]=(im-immean)/imdev j+=1 i+=1 for n in range(num_epochs): print("starting epoch {0}".format(n)) h=model.fit([imgs], [(steer-steerSampleMean)/steerSampleSTD], batch_size=25, epochs=1, verbose=1, validation_split=0.1, shuffle=True) if n%save_epochs ==0 : print("Saving epoch {0} to {1}".format(n, weightfile)) model.save_weights(weightfile, overwrite=True) model.save_weights(weightfile, overwrite=True)
steerSampleMean = steer.mean() steerSampleSTD = steer.std() print(steerSampleMean) print(steerSampleSTD) from testmodel import model img_files = glob.glob(os.path.join(data_dir, 'imgs*.npz')) command_files = glob.glob(os.path.join(data_dir, 'commands*.npz')) imgs = np.array((100, 96, 128, 3)) commands = np.array((100, 2)) for n in range(num_epochs): print("starting epoch {0}".format(n)) for i, c in zip(sorted(img_files), sorted(command_files)): print(i, c) imgs = np.load(i)['arr_0'] commands = np.load(c)['arr_0'] h = model.fit([imgs], [(commands[:, 0] - steerSampleMean) / steerSampleSTD], batch_size=32, epochs=1, verbose=1, validation_split=0.1, shuffle=True) if n % save_epochs == 0: print("Saving epoch {0} to {1}".format(n, weightfile)) model.save_weights(weightfile, overwrite=True) model.save_weights(weightfile, overwrite=True)