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
class PriceNet(nn.Module):
def __init__(self):
super().__init__()
def forward(self, vec1, vec2):
x1=torch.sum(vec1,dim=1)
x2=torch.sum(vec2,dim=1)
x = torch.add(x1, x2)
return x
if __name__ == "__main__":
device = torch.device("cpu")
data_len1 = 1178
data_len2 = 1243
model = PriceNet()
x1 = torch.rand((1,data_len1 - 2))
x2 = torch.rand((1,data_len2 - data_len1))
model.eval()
g = model(x1, x2)
traced_script_module = torch.jit.trace(model, (x1, x2))
traced_script_module.save("C:/work/project/wzry2/model1")
model = torchvision.models.resnet18(pretrained=True)
model.eval()
example = torch.rand(1, 3, 224, 224)
traced_script_module = torch.jit.trace(model, example)
traced_script_module.save("C:/work/project/wzry2/model2")
java code is :
Model model = Model.newInstance("wzry_model", Device.cpu());
ClassPathResource modelfile = new ClassPathResource("models/model1");
InputStream inputStream = modelfile.getInputStream();
System.out.println(inputStream.available());
model.load(inputStream);
ai.djl.pytorch pytorch-engine 0.23.0 ai.djl.pytorch pytorch-native-cpu 1.13.1 ai.djl.pytorch pytorch-jni 1.13.1-0.23.0
Looking forward to your answer ,model1 is not ok ,but model2 is ok
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
python code is :
java code is :
ai.djl.pytorch pytorch-engine 0.23.0 ai.djl.pytorch pytorch-native-cpu 1.13.1 ai.djl.pytorch pytorch-jni 1.13.1-0.23.0
Looking forward to your answer ,model1 is not ok ,but model2 is ok
Beta Was this translation helpful? Give feedback.
All reactions