class DNN::Layers::InputLayer
Public Class Methods
new(input_dim_or_shape)
click to toggle source
@param [Array] input_dim_or_shape Setting the shape or dimension of the input data.
Calls superclass method
DNN::Layers::Layer::new
# File lib/dnn/core/layers/basic_layers.rb, line 143 def initialize(input_dim_or_shape) super() @input_shape = input_dim_or_shape.is_a?(Array) ? input_dim_or_shape : [input_dim_or_shape] end
Public Instance Methods
build(input_shape)
click to toggle source
Calls superclass method
DNN::Layers::Layer#build
# File lib/dnn/core/layers/basic_layers.rb, line 148 def build(input_shape) super(@input_shape) end
forward(x)
click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 152 def forward(x) unless x.shape[1..-1] == @input_shape raise DNNShapeError, "The shape of x does not match the input shape. input shape is #{@input_shape}, but x shape is #{x.shape[1..-1]}." end x end
load_hash(hash)
click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 167 def load_hash(hash) initialize(hash[:input_shape]) end
to_hash()
click to toggle source
Calls superclass method
DNN::Layers::Layer#to_hash
# File lib/dnn/core/layers/basic_layers.rb, line 163 def to_hash super(input_shape: @input_shape) end
to_proc()
click to toggle source
# File lib/dnn/core/layers/basic_layers.rb, line 159 def to_proc method(:call).to_proc end