47 {
49 Series *bottom_series = nullptr;
50 StaticShape input_shape;
51 if (append_index >= 0) {
52
54 auto *series = static_cast<Series *>(*network);
55 Series *top_series = nullptr;
56 series->SplitAt(append_index, &bottom_series, &top_series);
57 if (bottom_series == nullptr || top_series == nullptr) {
58 tprintf(
"Yikes! Splitting current network failed!!\n");
59 return false;
60 }
61 input_shape = bottom_series->OutputShape(input_shape);
62 delete top_series;
63 }
64 *network = builder.BuildFromString(input_shape, &network_spec);
65 if (*network == nullptr) {
66 return false;
67 }
68 (*network)->SetNetworkFlags(net_flags);
69 (*network)->InitWeights(weight_range, randomizer);
70 (*network)->SetupNeedsBackprop(false);
71 if (bottom_series != nullptr) {
72 bottom_series->AppendSeries(*network);
73 *network = bottom_series;
74 }
75 (*network)->CacheXScaleFactor((*network)->XScaleFactor());
76 return true;
77}
NetworkBuilder(int num_softmax_outputs)