bfs_params.append(pht.rbfweights.detach().clone().numpy()) pht.train() train_indices_batch = train_indices[b * batch_size:(b + 1) * batch_size] optimizer_filter.zero_grad() loss = pht([data[i] for i in train_indices_batch]) loss.backward() optimizer_filter.step() lss += float(loss) loss_func.append(float(lss) / len(train_indices)) pht.eval() test_lss = pht([data[i] for i in test_indices]) test_loss.append(float(test_lss) / len(test_indices)) run_fold_index = str(run) + '_' + str(fold) pickle.dump( test_loss, open(result_dump + 'test_loss_' + run_fold_index + '.pkl', 'wb')) pickle.dump( loss_func, open(result_dump + 'train_loss_' + run_fold_index + '.pkl', 'wb')) pickle.dump( bfs_params, open(result_dump + 'theta_' + run_fold_index + '.pkl', 'wb')) del bfs_params, test_lss, loss_func, pht