37 int stack_size =
stack_.size();
38 for (
int i = 0; i < stack_size; ++i) {
39 result =
stack_[i]->OutputShape(result);
49 tprintf(
"Num outputs,weights in Series:\n");
50 for (
int i = 0; i <
stack_.size(); ++i) {
51 int weights =
stack_[i]->InitWeights(range, randomizer);
64 tprintf(
"Num (Extended) outputs,weights in Series:\n");
65 for (
int i = 0; i <
stack_.size(); ++i) {
66 int weights =
stack_[i]->RemapOutputs(old_no, code_map);
81 for (
int i = 0; i <
stack_.size(); ++i)
83 return needs_backprop;
94 for (
int i = 0; i <
stack_.size(); ++i)
102 stack_[0]->CacheXScaleFactor(factor);
110 int stack_size =
stack_.size();
117 stack_[0]->Forward(debug, input, input_transpose, scratch, buffer1);
118 for (
int i = 1; i < stack_size; i += 2) {
119 stack_[i]->Forward(debug, *buffer1,
nullptr, scratch,
120 i + 1 < stack_size ? buffer2 : output);
121 if (i + 1 == stack_size)
return;
122 stack_[i + 1]->Forward(debug, *buffer2,
nullptr, scratch,
123 i + 2 < stack_size ? buffer1 : output);
133 int stack_size =
stack_.size();
140 if (!
stack_.back()->IsTraining() ||
141 !
stack_.back()->Backward(debug, fwd_deltas, scratch, buffer1))
143 for (
int i = stack_size - 2; i >= 0; i -= 2) {
145 !
stack_[i]->Backward(debug, *buffer1, scratch,
146 i > 0 ? buffer2 : back_deltas))
150 !
stack_[i - 1]->Backward(debug, *buffer2, scratch,
151 i > 1 ? buffer1 : back_deltas))
163 if (last_start < 0 || last_start >=
stack_.size()) {
164 tprintf(
"Invalid split index %d must be in range [0,%d]!\n",
165 last_start,
stack_.size() - 1);
170 for (
int s = 0; s <= last_start; ++s) {
179 for (
int s = last_start + 1; s <
stack_.size(); ++s) {
183 *start = master_series;
184 *end = boosted_series;
193 for (
int s = 0; s < src_series->stack_.size(); ++s) {
195 src_series->stack_[s] =
nullptr;
int InitWeights(float range, TRand *randomizer) override
void ChangeType(NetworkType type)
void AppendSeries(Network *src)
bool Backward(bool debug, const NetworkIO &fwd_deltas, NetworkScratch *scratch, NetworkIO *back_deltas) override
StaticShape OutputShape(const StaticShape &input_shape) const override
void SplitAt(int last_start, Series **start, Series **end)
PointerVector< Network > stack_
virtual void AddToStack(Network *network)
STRING spec() const override
void CacheXScaleFactor(int factor) override
void Forward(bool debug, const NetworkIO &input, const TransposedArray *input_transpose, NetworkScratch *scratch, NetworkIO *output) override
int XScaleFactor() const override
DLLSYM void tprintf(const char *format,...)
int RemapOutputs(int old_no, const std::vector< int > &code_map) override
bool SetupNeedsBackprop(bool needs_backprop) override
Series(const STRING &name)