diff --git a/tasks/adding_task.py b/tasks/adding_task.py index ca0dbd2..ebc8d59 100644 --- a/tasks/adding_task.py +++ b/tasks/adding_task.py @@ -99,7 +99,9 @@ def generate_data(length, size): sums = np.array(sums) sums = sums.reshape(1, 1, 1) - return cudavec(x_seq_list, gpu_id=args.cuda).float(), cudavec(sums, gpu_id=args.cuda).float(), sums_text + return cudavec(x_seq_list.astype(np.float32), gpu_id=args.cuda).float(), \ + cudavec(sums.astype(np.float32), gpu_id=args.cuda).float(), \ + sums_text def cross_entropy(prediction, target): @@ -221,7 +223,7 @@ if __name__ == '__main__': T.nn.utils.clip_grad_norm_(rnn.parameters(), args.clip) optimizer.step() - loss_value = loss.data[0] + loss_value = loss.item() # detach memory from graph mhx = { k : (v.detach() if isinstance(v, var) else v) for k, v in mhx.items() } diff --git a/tasks/argmax_task.py b/tasks/argmax_task.py index 711a017..398c487 100644 --- a/tasks/argmax_task.py +++ b/tasks/argmax_task.py @@ -227,7 +227,7 @@ if __name__ == '__main__': T.nn.utils.clip_grad_norm_(rnn.parameters(), args.clip) optimizer.step() - loss_value = loss.data[0] + loss_value = loss.item() # detach memory from graph mhx = { k : (v.detach() if isinstance(v, var) else v) for k, v in mhx.items() } diff --git a/tasks/copy_task.py b/tasks/copy_task.py index 8be5984..0ca5a8c 100755 --- a/tasks/copy_task.py +++ b/tasks/copy_task.py @@ -214,7 +214,7 @@ if __name__ == '__main__': T.nn.utils.clip_grad_norm_(rnn.parameters(), args.clip) optimizer.step() - loss_value = loss.data[0] + loss_value = loss.item() summarize = (epoch % summarize_freq == 0) take_checkpoint = (epoch != 0) and (epoch % check_freq == 0)