MCPcopy Create free account
hub / github.com/AllentDan/LibtorchTutorials / MLP

Method MLP

lesson3-BasicModels/MLP.cpp:3–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include<MLP.h>
2
3MLP::MLP(int in_features, int out_features){
4 ln1 = LinearBnRelu(in_features, mid_features[0]);
5 ln2 = LinearBnRelu(mid_features[0], mid_features[1]);
6 ln3 = LinearBnRelu(mid_features[1], mid_features[2]);
7 out_ln = torch::nn::Linear(mid_features[2], out_features);
8
9 ln1 = register_module("ln1", ln1);
10 ln2 = register_module("ln2", ln2);
11 ln3 = register_module("ln3", ln3);
12 out_ln = register_module("out_ln",out_ln);
13}
14
15torch::Tensor MLP::forward(torch::Tensor x){
16 x = ln1->forward(x);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected