@smth Thanks for the quick reply!
I am encountering an issue when I attempt to run the line that you suggested. I assume that when you are referring to model, you are referring to a ‘Net’ object. I am trying to run the following code segment, in which I am attempting to:

Load a pre-trained MNIST model
Execute a forward pass with a single image (batch_size=1) to get activations
Create a dummy gradient (custom_grad = 0.5)
Backpropagate the dummy gradient through the network
Access the artificial gradient w.r.t. the input

# Load model for testing
model = Net()
SoftmaxWithXent = nn.CrossEntropyLoss()
model = torch.load('./mnist_saved_model.pth')
model.eval()

# Construct the testing dataset
test_dataset = MNIST_Dataset(mnist_test_data, mnist_test_labels)

for img,lbl in test_dataset.read(batch_size=1, shuffle=True):
    # Create the data and label variables so we can use them in the computation
    img = Variable(torch.FloatTensor(img), requires_grad=True)
    lbl = Variable(torch.LongTensor(lbl))
    # Normalize RGB [0,255] to [0,1]
    img = torch.div(img, 255.0)
    # Call a forward pass on the data
    output = model(img)
    custom_grad = torch.FloatTensor(np.asarray([0.5]))
    model.backward(custom_grad)
    print("img.grad.data", img.grad)

When I run this, I get the following error:
AttributeError: 'Net' object has no attribute 'backward'
** As a side note, when I get the gradient w.r.t. a loss function (as usual), and attempt to extract the gradient w.r.t. the input image, I either get None or gradient values that are nearly zero (on order of 10^-30). Why might this be?
I am new to PyTorch so please excuse my ineptitude. Thanks again!