class DNN::Layers::SimpleRNN
Attributes
activation[R]
Public Class Methods
new(num_units, stateful: false, return_sequences: true, activation: Layers::Tanh.new, weight_initializer: Initializers::RandomNormal.new, recurrent_weight_initializer: Initializers::RandomNormal.new, bias_initializer: Initializers::Zeros.new, weight_regularizer: nil, recurrent_weight_regularizer: nil, bias_regularizer: nil, use_bias: true)
click to toggle source
@param [DNN::Layers::Layer] activation Activation function to use in a recurrent network.
Calls superclass method
DNN::Layers::RNN::new
# File lib/dnn/core/layers/rnn_layers.rb, line 175 def initialize(num_units, stateful: false, return_sequences: true, activation: Layers::Tanh.new, weight_initializer: Initializers::RandomNormal.new, recurrent_weight_initializer: Initializers::RandomNormal.new, bias_initializer: Initializers::Zeros.new, weight_regularizer: nil, recurrent_weight_regularizer: nil, bias_regularizer: nil, use_bias: true) super(num_units, stateful: stateful, return_sequences: return_sequences, weight_initializer: weight_initializer, recurrent_weight_initializer: recurrent_weight_initializer, bias_initializer: bias_initializer, weight_regularizer: weight_regularizer, recurrent_weight_regularizer: recurrent_weight_regularizer, bias_regularizer: bias_regularizer, use_bias: use_bias) @activation = activation end
Public Instance Methods
build(input_shape)
click to toggle source
Calls superclass method
DNN::Layers::RNN#build
# File lib/dnn/core/layers/rnn_layers.rb, line 199 def build(input_shape) super num_prev_units = input_shape[1] @weight.data = Xumo::SFloat.new(num_prev_units, @num_units) @recurrent_weight.data = Xumo::SFloat.new(@num_units, @num_units) @bias.data = Xumo::SFloat.new(@num_units) if @bias init_weight_and_bias end
load_hash(hash)
click to toggle source
# File lib/dnn/core/layers/rnn_layers.rb, line 216 def load_hash(hash) initialize(hash[:num_units], stateful: hash[:stateful], return_sequences: hash[:return_sequences], activation: Layers::Layer.from_hash(hash[:activation]), weight_initializer: Initializers::Initializer.from_hash(hash[:weight_initializer]), recurrent_weight_initializer: Initializers::Initializer.from_hash(hash[:recurrent_weight_initializer]), bias_initializer: Initializers::Initializer.from_hash(hash[:bias_initializer]), weight_regularizer: Regularizers::Regularizer.from_hash(hash[:weight_regularizer]), recurrent_weight_regularizer: Regularizers::Regularizer.from_hash(hash[:recurrent_weight_regularizer]), bias_regularizer: Regularizers::Regularizer.from_hash(hash[:bias_regularizer]), use_bias: hash[:use_bias]) end
to_hash()
click to toggle source
Calls superclass method
DNN::Layers::RNN#to_hash
# File lib/dnn/core/layers/rnn_layers.rb, line 212 def to_hash super(activation: @activation.to_hash) end