Class: DNN::Models::LayersList
- Inherits:
-
Array
- Object
- Array
- DNN::Models::LayersList
- Defined in:
- lib/dnn/core/models.rb
Overview
This class is used to hold multiple layers in an array.
Class Method Summary collapse
Instance Method Summary collapse
-
#layers ⇒ Array
Get the all layers.
- #to_hash_list ⇒ Object
Class Method Details
.from_hash_list(hash_list) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dnn/core/models.rb', line 6 def self.from_hash_list(hash_list) layers_list = new hash_list.each do |hash| obj_class = DNN.const_get(hash[:class]) obj = obj_class.allocate if obj.is_a?(Chain) obj = obj_class.new obj.load_hash(hash) else obj = Layers::Layer.from_hash(hash) end layers_list << obj end layers_list end |
Instance Method Details
#layers ⇒ Array
Get the all layers.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dnn/core/models.rb', line 28 def layers layers_array = [] each do |layer| if layer.is_a?(Layers::Layer) layers_array << layer elsif layer.is_a?(Chain) || layer.is_a?(LayersList) layers_array.concat(layer.layers) end end layers_array end |
#to_hash_list ⇒ Object
22 23 24 |
# File 'lib/dnn/core/models.rb', line 22 def to_hash_list map(&:to_hash) end |