I’m facing this error while training my model :
AttributeError: ‘list’ object has no attribute ‘relu2_2’
Code :
for epoch in range(1, epochs+1):
transformer.train()
print(‘No of Epochs:’, epoch)
for batch_i, (images, _) in enumerate(train_loader):
optimizer.zero_grad()
images_original = images.to(device)
generated = transformer(images_original)
features_original = vgg(images_original)
features_transformed = vgg(generated)
content_loss = content_weight*l2_loss(features_transformed.relu2_2, features_original.relu2_2)
style_loss = 0
for ft_y, gm_s in zip(features_transformed, gram_style):
gm_y = gram_matrix(ft_y)
style_loss += l2_loss(gm_y, gm_s[: images.size(0), :, :])
style_loss *= style_weight
total_loss = content_loss + style_loss
total_loss.backward(retain_graph=True)
optimizer.step()
train_metrics['content'] += [content_loss.item()]
train_metrics['style'] += [style_loss.item()]
train_metrics['total'] += [total_loss.item()]
print('Train Metrics Total:',train_metrics['total'])
Can anyone figure out why this error is coming as when I checked with other github repos on fastnst they worked perfectly with somewhat similar code. Thanks in advance for help!