You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The operator 'aten::lerp.Scalar_out' is not currently supported on the DML backend and will fall back to run on the CPU. This may have performance implications.
#675
Open
lovelyallen opened this issue
Dec 8, 2024
· 1 comment
The developers basically have to implement this function in the back-end, really hope they fix it soon. Adam optimizer is a very basic and fundamental part of AI/ML workloads and is really important for students like us.
I've encountered this warning when programming a resnet.
my torch-directml version is 0.2.5.dev20240914
this is the code:
import torch
import torch_directml
from torch import *
from torch import nn
import polars
import numpy as np
from PIL import Image
from torch import optim
from torch.optim.nadam import NAdam
from torch.optim.adam import Adam
dml=torch_directml.device()
torch.set_default_device(dml)
X=polars.read_csv("tr_x.csv").to_numpy()
X=np.delete(X,[0],1)
X=np.reshape(X,[-1,30,1,28,28])
print(X.shape)
X=tensor(X,dtype=uint8)
Y=polars.read_csv("tr_y.csv").to_numpy()
Y=np.delete(Y,[0],1)
Y=np.reshape(Y,[-1,30])
Y=tensor(Y,device="cpu")
Y=nn.functional.one_hot(Y,26).to(dml)
class Block(nn.Module):
def init(self):
super(Block,self).init();
self.conv1=nn.Conv2d(32,32,3,padding=1)
self.conv2=nn.Conv2d(32,32,3,padding=1)
self.relu=nn.ReLU()
def forward(self,x):
r=clone(x)
x=self.conv1(x)
x=self.conv2(x)
x=self.relu(x)
x=r+x
return x
mod=nn.Sequential(
nn.Conv2d(1,32,5),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
Block(),
nn.Flatten(),
nn.Linear(322424,128),
nn.ReLU(),
nn.Linear(128,26),
nn.Sigmoid()
).to(dml)
epoches=100
opt=NAdam(mod.parameters())
los=nn.CrossEntropyLoss().to(dml)
for _ in range(0,epoches):
total_loss=0
total_acc=0
for i in range(0,X.shape[0]):
x=X[i.item().int()].type(float32)
y=Y[i.item().int()].type(float32)
#print(y.shape)
pred=mod(x)
opt.zero_grad()
loss:Tensor=los(pred,y)
loss.backward()
opt.step()
if (i%100==0):
print(i)
any solutions?
(I am new to here and i dont know what to do with coping. sorry for that)
The text was updated successfully, but these errors were encountered: