19 Example model with 2 different input tensors
23 Intialize with a single Linear layer
32 Run the forward pass - a and b are concatenated and b is flattened
34 return self.
linear(torch.cat([a, b.reshape(-1, 6).float()], axis=1))
37if __name__ ==
"__main__":
39 model.load_state_dict({
40 "linear.weight": torch.tensor(
41 [[0.0040, -0.1127, -0.0641, 0.0129, -0.0216, 0.2783, -0.0190, -0.0011],
42 [-0.0772, -0.2133, -0.0243, 0.1520, 0.0784, 0.1187, -0.1681, 0.0372]]
44 "linear.bias": torch.tensor([-0.2196, 0.1375]),
46 a = torch.tensor([[0.5309, 0.4930]])
47 b = torch.tensor([[[1, 0, 1], [1, -1, 0]]])
49 torch.set_printoptions(precision=10)
50 print(
"Outputs to test against:", model(a, b))
55 "ModelForStandalone.onnx",
56 input_names=[
"a",
"b"],
57 output_names=[
"output"],
linear
linear Layer with 8 inputs, 2 outputs