Class: DNN::Models::Chain
- Inherits:
-
Object
- Object
- DNN::Models::Chain
- Defined in:
- lib/dnn/core/models.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#call(input_tensors) ⇒ Tensor
Forward propagation and create a link.
-
#forward(input_tensors) ⇒ Tensor
Forward propagation.
-
#initialize ⇒ Chain
constructor
A new instance of Chain.
-
#layers ⇒ Array
Get the all layers.
Constructor Details
#initialize ⇒ Chain
Returns a new instance of Chain.
42 43 44 |
# File 'lib/dnn/core/models.rb', line 42 def initialize @layers_cache = nil end |
Instance Method Details
#call(input_tensors) ⇒ Tensor
Forward propagation and create a link.
56 57 58 |
# File 'lib/dnn/core/models.rb', line 56 def call(input_tensors) forward(input_tensors) end |
#forward(input_tensors) ⇒ Tensor
Forward propagation.
49 50 51 |
# File 'lib/dnn/core/models.rb', line 49 def forward(input_tensors) raise NotImplementedError, "Class '#{self.class.name}' has implement method 'forward'" end |
#layers ⇒ Array
Get the all layers.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dnn/core/models.rb', line 62 def layers return @layers_cache if @layers_cache layers_array = [] instance_variables.sort.each do |ivar| obj = instance_variable_get(ivar) if obj.is_a?(Layers::Layer) layers_array << obj elsif obj.is_a?(Chain) || obj.is_a?(LayersList) layers_array.concat(obj.layers) end end @layers_cache = layers_array end |