batch_data = np.empty([batch_size, N_IN_DATA], np.float32) batch_desi = np.empty([batch_size, N_OUT_DATA], np.float32) for i in range(batch_size): x = randint(1, len(in_data)) - 1 batch_imgs[i], batch_data[i], batch_desi[i] = in_data[x].load_data() return batch_imgs, batch_data, batch_desi #---------------------------------------------# # Running the Network #---------------------------------------------# # Load the network and the data data = ld.load_data() nn = Network() if LOAD_NETWORK: nn.load_network(LOAD_LOCATION) # Main loop for i in tqdm(range(4000, 10000000)): # Generate the batch and train img_batch, data_batch, desired_batch = get_batch(data, BATCH_SIZE) loss = nn.train(img_batch, data_batch, desired_batch, USE_WEIGHTED_LOSS) # Print the loss if i % 20 == 0: print i, loss, CHECKPOINT_END # Save the network if SAVE_NETWORK and (i + 1) % 1000 == 0: nn.save_network(os.path.join(SAVE_LOCATION, str(i + 1) + CHECKPOINT_END))