Class: Tensorflow::Keras::Models::Sequential
- Inherits:
-
Object
- Object
- Tensorflow::Keras::Models::Sequential
- Defined in:
- lib/tensorflow/keras/models/sequential.rb
Instance Method Summary collapse
- #add(layer) ⇒ Object
- #compile(optimizer: nil, loss: nil, metrics: nil) ⇒ Object
- #evaluate(x, y) ⇒ Object
- #fit(x, y, epochs: nil) ⇒ Object
-
#initialize(layers = []) ⇒ Sequential
constructor
A new instance of Sequential.
- #summary ⇒ Object
Constructor Details
#initialize(layers = []) ⇒ Sequential
Returns a new instance of Sequential.
5 6 7 8 9 10 11 |
# File 'lib/tensorflow/keras/models/sequential.rb', line 5 def initialize(layers = []) @layers = [] layers.each do |layer| add(layer) end end |
Instance Method Details
#add(layer) ⇒ Object
13 14 15 |
# File 'lib/tensorflow/keras/models/sequential.rb', line 13 def add(layer) @layers << layer end |
#compile(optimizer: nil, loss: nil, metrics: nil) ⇒ Object
17 18 19 |
# File 'lib/tensorflow/keras/models/sequential.rb', line 17 def compile(optimizer: nil, loss: nil, metrics: nil) raise "Not implemented" end |
#evaluate(x, y) ⇒ Object
25 26 27 |
# File 'lib/tensorflow/keras/models/sequential.rb', line 25 def evaluate(x, y) raise "Not implemented" end |
#fit(x, y, epochs: nil) ⇒ Object
21 22 23 |
# File 'lib/tensorflow/keras/models/sequential.rb', line 21 def fit(x, y, epochs: nil) raise "Not implemented" end |
#summary ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tensorflow/keras/models/sequential.rb', line 29 def summary sep = "_________________________________________________________________\n" output_shape = nil @layers.each do |layer| layer.build(output_shape) if layer.respond_to?(:build) output_shape = layer.output_shape end total_params = @layers.map(&:count_params).sum summary = String.new("") summary << "Model: \"sequential\"\n" summary << sep summary << "Layer (type) Output Shape Param # \n" summary << "=================================================================\n" summary << @layers.map { |l| "%-28s %-25s %-10s\n" % [l.class.name.split("::").last, ([nil] + l.output_shape[1..-1]).inspect, l.count_params] }.join(sep) summary << "=================================================================\n" summary << "Total params: #{total_params}\n" summary << "Trainable params: #{total_params}\n" summary << "Non-trainable params: 0\n" summary << sep puts summary end |