After a while I came back to working with Pytoch I updated
I use VS 2022 for it everything worked fine but I got now an error
from torchmetrics import R2Score
def train(model, optimizer, x1,x2, y):
# Reset gradient
optimizer.zero_grad()
# Forward
fx = model.forward(x1,x2)
#loss = model.N1L(fx, y)
loss = 0
r2 = 0
count = 0
count2 = 0
for i,result in enumerate(fx):
loss += model.r2_dd_loss(result, y[i], 3)
count += 1
#loss= model.r3_loss(fx,y)
#print(count)
loss /= count
for i,result in enumerate(fx):
r2 += model.r2(result,y[i])
count2 += 1
# Backward
r2 /= count2
loss.backward()
# Update parameters
optimizer.step()
basically the model.r2(result,y[i]) which is the R2 function gives the error: R2Score’ object has no attribute ‘_backward_pre_hooks’. I actually don’t need any backwards tracking because its just collecting data so not sure what going on here