July 2019
Intermediate to advanced
512 pages
19h 39m
English
Start the TensorFlow session and initialize all the variables:
session = tf.Session()session.run(tf.global_variables_initializer())
Set the number of epochs:
epochs = 100
Then, for each iteration, perform the following:
for i in range(epochs): train_predictions = [] index = 0 epoch_loss = []
Then sample a batch of data and train the network:
while(index + batch_size) <= len(X_train): X_batch = X_train[index:index+batch_size] y_batch = y_train[index:index+batch_size] #predict the price and compute the loss predicted, loss_val, _ = session.run([y_hat, loss, optimizer], feed_dict={input:X_batch, target:y_batch}) #store the loss in the epoch_loss list epoch_loss.append(loss_val) #store the predictions in the train_predictions ...Read now
Unlock full access