I am running a python code on jupyter notebook and encounter the error "AttributeError: 'numpy.int64' object has no attribute 'read'". I have already searched it a lot but there is nothing available related to "read". I am attaching the code and the SS of the error. Anyone who can help will be really appreciated.
model = models.resnet18(pretrained = True)
num_ftrs = model.fc.in_features
model.fc = nn.Linear(num_ftrs, 2)
model.load_state_dict(torch.load('2_stage_model.pt'))
model.eval()
classes = ('Flowers', 'No_Flowers')
class_probs = []
class_preds = []
with torch.no_grad():
for data in testloader:
images = data
output = model(images)
images = data
output = model(images)
class_probsbatch = [F.softmax(el, dim=0) for el in output]
, class_preds_batch = torch.max(output, 1)
I am running a python code on jupyter notebook and encounter the error "AttributeError: 'numpy.int64' object has no attribute 'read'". I have already searched it a lot but there is nothing available related to "read". I am attaching the code and the SS of the error. Anyone who can help will be really appreciated. model = models.resnet18(pretrained = True) num_ftrs = model.fc.in_features model.fc = nn.Linear(num_ftrs, 2) model.load_state_dict(torch.load('2_stage_model.pt')) model.eval() classes = ('Flowers', 'No_Flowers') class_probs = [] class_preds = []
with torch.no_grad(): for data in testloader: images = data output = model(images) images = data output = model(images) class_probsbatch = [F.softmax(el, dim=0) for el in output] , class_preds_batch = torch.max(output, 1)
test_probs = torch.cat([torch.stack(batch) for batch in class_probs]) test_preds = torch.cat(class_preds)