) if batch_nr % 1500 == 0: with open(txt_log_name, 'a') as txt_file: txt_file.write("Batch: " + str(batch_nr) + "/" + str(num_training_batches) + " batch_loss: " + str(batch_loss) + "\n") batch_nr += 1 with open(txt_log_name, 'a') as txt_file: txt_file.write("Epoch loss: " + str(epoch_loss / batch_nr) + "\n") # ***********************************************Testing************************************************************ if epoch_nr == MAX_EPOCHS - 1: with open(txt_log_name) as f: f.write("**************************Testing*********************\n") datahandler.reset_user_batch_data_test() items, item_targets, session_lengths, session_reps, session_rep_lengths, user_list, sess_time_reps, time_targets, first_rec_targets = datahandler.get_next_test_batch( ) model.eval_mode() batch_nr = 0 while len(items) > int(BATCHSIZE / 2): batch_start_time = time.time() predictions = model.predict_on_batch(items, session_reps, sess_time_reps, user_list, time_targets, session_lengths, session_rep_lengths, True) tester.evaluate_batch(predictions[:, 1:], item_targets, session_lengths, predictions[:, 0], first_rec_targets) items, item_targets, session_lengths, session_reps, session_rep_lengths, user_list, sess_time_reps, time_targets, first_rec_targets = datahandler.get_next_test_batch( ) batch_nr += 1