Initialize the session and call the optimize() function for num_iterations=1:
session = tf.Session()session.run(tf.global_variables_initializer())batch_size = 2train_batch_size = batch_sizeoptimize(num_iterations = 1, data=data, train_batch_size=train_batch_size, x=x, y_true=y_true,session=session, optimizer=optimizer, cost=cost, accuracy=accuracy)
Here, the optimize() function is defined in the following block:
def optimize(num_iterations, data, train_batch_size, x, y_true, session, optimizer, cost, accuracy): # Ensure we update the global variable rather than a local copy. global total_iterations # Start-time used for printing time-usage below. start_time = time.time() best_val_loss = float("inf") patience = 0 for i in range(total_iterations, ...