Skip to content

Commit

Permalink
fc_layer: scale initial weights and bias by 1/sqrt(inputsize)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSallermann committed Oct 28, 2023
1 parent 201a8c1 commit 0912f2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/fc_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class FCLayer : public Layer<scalar>

const auto random_lambda = [&]( [[maybe_unused]] scalar x ) { return dist( gen ); };

weights = weights.array().unaryExpr( random_lambda );
bias = bias.array().unaryExpr( random_lambda );
weights = weights.array().unaryExpr( random_lambda ) / std::sqrt( input_size );
bias = bias.array().unaryExpr( random_lambda ) / std::sqrt( input_size );
}

std::string name() override
Expand Down

0 comments on commit 0912f2e

Please sign in to comment.