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

Method forward

lesson6-Segmentation/ResNet.cpp:36–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36torch::Tensor BlockImpl::forward(torch::Tensor x) {
37 torch::Tensor residual = x.clone();
38
39 x = conv1->forward(x);
40 x = bn1->forward(x);
41 x = torch::relu(x);
42
43 x = conv2->forward(x);
44 x = bn2->forward(x);
45
46 if (!is_basic) {
47 x = torch::relu(x);
48 x = conv3->forward(x);
49 x = bn3->forward(x);
50 }
51
52 if (!downsample->is_empty()) {
53 residual = downsample->forward(residual);
54 }
55
56 x += residual;
57 x = torch::relu(x);
58
59 return x;
60}
61
62ResNetImpl::ResNetImpl(std::vector<int> layers, int num_classes, std::string model_type, int _groups, int _width_per_group)
63{

Callers 1

featuresMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected