Closed Rivendellad closed 1 year ago
Please post a minimal working example that reproduces your problem.
X_train=torch.from_numpy(X_train) X_train=X_train.reshape([7699,2,128]).unsqueeze(dim=1) X_test=torch.from_numpy(X_test) X_test=X_test.reshape([3301,2,128]).unsqueeze(dim=1)
x_train, x_test = torch.Tensor(X_train), torch.Tensor(X_test) y_train, y_test = torch.Tensor(Y_train), torch.Tensor(Y_test) x_train=x_train[0:1000,:] y_train=y_train[:1000] x_train=x_train.to(device) y_train=y_train.to(device) print(y_train.dtype) print(x_train.shape) print(x_test.shape) print(y_train.shape) print(y_test.shape) train_dataset = TensorDataset(x_train, y_train.type(torch.LongTensor)) test_dataset = TensorDataset(x_test, y_test.type(torch.LongTensor)) batch_size = 128 TrainLoader = DataLoader(train_dataset, batch_size=batch_size, shuffle=False) TestLoader = DataLoader(test_dataset, batch_size=batch_size, shuffle=False)
model = torch.load('VTCNN2_9c.pth').eval() # fmodel = PyTorchModel(model,bounds=(-1,1)) attack = LinfFastGradientAttack() clean_acc = accuracy(fmodel, x_train, y_train,) print(f"clean accuracy: {clean_acc * 100:.1f} %")
raw_advs, clipped_advs, success = attack(fmodel, x_train, y_train, epsilons=0.3)
Layer (type) Output Shape Param #
clean accuracy: 73.1 %
Traceback (most recent call last):
File "D://code/advsamples.py", line 89, in
I found the problem, the data type of the sample and the tag is not correct, the sample should be float32, and the tag should be int64 Thank you very much for your help
I've had a similar issue in close, but after I use the latest version, I still get an error like this "nll_loss_forward_no_reduce_cuda_kernel_index" not implemented for 'Float' Please help me