48 {
50 Series* bottom_series = nullptr;
51 StaticShape input_shape;
52 if (append_index >= 0) {
53
55 auto* series = static_cast<Series*>(*network);
56 Series* top_series = nullptr;
57 series->SplitAt(append_index, &bottom_series, &top_series);
58 if (bottom_series == nullptr || top_series == nullptr) {
59 tprintf(
"Yikes! Splitting current network failed!!\n");
60 return false;
61 }
62 input_shape = bottom_series->OutputShape(input_shape);
63 delete top_series;
64 }
65 char* str_ptr = &network_spec[0];
66 *network = builder.BuildFromString(input_shape, &str_ptr);
67 if (*network == nullptr) return false;
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)