|
|
|
|
|
by natly
1461 days ago
|
|
Wow the source code is kind of blowing my mind. I had no idea this was possible (only in theory). import * as torch from "./torch.mjs";
...
const w0 = torch.tensor(weights["conv1.0.weight"]);
const b0 = torch.tensor(weights["conv1.0.bias"]);
const w1 = torch.tensor(weights["conv2.0.weight"]);
const b1 = torch.tensor(weights["conv2.0.bias"]);
const lw = torch.tensor(weights["out.weight"]);
const lb = torch.tensor(weights["out.bias"]);
const convs = nn.Sequential(
nn.Conv2d(w0, b0, 1, 2),
nn.MaxPool2d(2),
nn.ReLU(),
nn.Conv2d(w1, b1, 1, 2),
nn.MaxPool2d(2),
nn.ReLU()
);
...
Looks like near identical python torch code except apparantely running in local js! |
|