41 :
Network(type, name, ni, no), external_source_(nullptr), int_mode_(false) {
90 no_ = code_map.size();
122 int width = input.
Width();
133 temp_lines[i].Init(
no_, scratch);
134 curr_input[i].Init(
ni_, scratch);
137 #pragma omp parallel for num_threads(kNumThreads) 138 for (
int t = 0; t < width; ++t) {
140 int thread_id = omp_get_thread_num();
142 for (
int t = 0; t < width; ++t) {
146 double* temp_line = temp_lines[thread_id];
187 FuncInplace<GFunc>(
no_, output_line);
189 FuncInplace<FFunc>(
no_, output_line);
191 FuncInplace<ClipFFunc>(
no_, output_line);
193 FuncInplace<ClipGFunc>(
no_, output_line);
195 FuncInplace<Relu>(
no_, output_line);
199 ASSERT_HOST(
"Invalid fully-connected type!" ==
nullptr);
204 int t,
double* output_line) {
213 int t,
double* output_line) {
228 for (
int i = 0; i <
kNumThreads; ++i) errors[i].Init(
no_, scratch);
232 for (
int i = 0; i <
kNumThreads; ++i) temp_backprops[i].Init(
ni_, scratch);
234 int width = fwd_deltas.
Width();
236 errors_t.
Init(
no_, width, scratch);
238 #pragma omp parallel for num_threads(kNumThreads) 239 for (
int t = 0; t < width; ++t) {
240 int thread_id = omp_get_thread_num();
242 for (
int t = 0; t < width; ++t) {
245 double* backprop =
nullptr;
247 double* curr_errors = errors[thread_id];
249 if (backprop !=
nullptr) {
258 back_deltas->
Print(10);
281 fwd_deltas.ReadTimeStep(t, curr_errors);
283 ASSERT_HOST(
"Invalid fully-connected type!" ==
nullptr);
299 float adam_beta,
int num_samples) {
307 double* changed)
const {
bool DeSerialize(TFile *fp) override
FullyConnected(const STRING &name, int ni, int no, NetworkType type)
void Print(int num) const
void ConvertToInt() override
bool Serialize(TFile *fp) const override
void CountAlternators(const WeightMatrix &other, double *same, double *changed) const
const char * string() const
void BackwardTimeStep(const NetworkIO &fwd_deltas, int t, double *curr_errors, TransposedArray *errors_t, double *backprop)
void Forward(bool debug, const NetworkIO &input, const TransposedArray *input_transpose, NetworkScratch *scratch, NetworkIO *output) override
void Init(int size1, int size2, NetworkScratch *scratch)
void SoftmaxInPlace(int n, T *inout)
void CopyTimeStepFrom(int dest_t, const NetworkIO &src, int src_t)
void DisplayBackward(const NetworkIO &matrix)
int InitWeights(float range, TRand *randomizer) override
int RemapOutputs(const std::vector< int > &code_map)
virtual void SetRandomizer(TRand *randomizer)
void VectorDotMatrix(const double *u, double *v) const
bool Backward(bool debug, const NetworkIO &fwd_deltas, NetworkScratch *scratch, NetworkIO *back_deltas) override
int RemapOutputs(int old_no, const std::vector< int > &code_map) override
void WriteTimeStep(int t, const double *input)
void Update(double learning_rate, double momentum, double adam_beta, int num_samples)
const int8_t * i(int t) const
bool Serialize(bool training, TFile *fp) const
void ResizeNoInit(int size1, int size2, int pad=0)
int InitWeightsFloat(int no, int ni, bool use_adam, float weight_range, TRand *randomizer)
void Resize(const NetworkIO &src, int num_features)
void Debug2D(const char *msg)
void ZeroInvalidElements()
virtual bool Serialize(TFile *fp) const
void init_to_size(int size, const T &t)
void DebugWeights() override
void SetEnableTraining(TrainingState state) override
TransposedArray * get() const
void DisplayForward(const NetworkIO &matrix)
const TransposedArray * external_source_
StaticShape OutputShape(const StaticShape &input_shape) const override
DLLSYM void tprintf(const char *format,...)
void MatrixDotVector(const double *u, double *v) const
void set_loss_type(LossType value)
void ForwardTimeStep(int t, double *output_line)
void FinishBackward(const TransposedArray &errors_t)
void FuncMultiply(const NetworkIO &v_io, int t, double *product)
void set_depth(int value)
bool DeSerialize(bool training, TFile *fp)
void CountAlternators(const Network &other, double *same, double *changed) const override
void ReadTimeStep(int t, double *output) const
void WriteStrided(int t, const float *data)
bool TestFlag(NetworkFlags flag) const
void Update(float learning_rate, float momentum, float adam_beta, int num_samples) override
TransposedArray source_t_
void ResizeFloat(const NetworkIO &src, int num_features)
void SumOuterTransposed(const TransposedArray &u, const TransposedArray &v, bool parallel)
void SetupForward(const NetworkIO &input, const TransposedArray *input_transpose)