Class: CooCoo::Trainer::BatchStats

Inherits:
Object
  • Object
show all
Defined in:
lib/coo-coo/trainer/batch_stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trainer, batch, batch_size, total_time, total_loss) ⇒ BatchStats

Returns a new instance of BatchStats.



10
11
12
13
14
15
16
# File 'lib/coo-coo/trainer/batch_stats.rb', line 10

def initialize(trainer, batch, batch_size, total_time, total_loss)
  @trainer = trainer
  @batch = batch
  @batch_size = batch_size
  @total_time = total_time
  @total_loss = total_loss
end

Instance Attribute Details

#batchObject (readonly)

Returns the value of attribute batch.



5
6
7
# File 'lib/coo-coo/trainer/batch_stats.rb', line 5

def batch
  @batch
end

#batch_sizeObject (readonly)

Returns the value of attribute batch_size.



6
7
8
# File 'lib/coo-coo/trainer/batch_stats.rb', line 6

def batch_size
  @batch_size
end

#total_lossObject (readonly)

Returns the value of attribute total_loss.



8
9
10
# File 'lib/coo-coo/trainer/batch_stats.rb', line 8

def total_loss
  @total_loss
end

#total_timeObject (readonly)

Returns the value of attribute total_time.



7
8
9
# File 'lib/coo-coo/trainer/batch_stats.rb', line 7

def total_time
  @total_time
end

#trainerObject (readonly)

Returns the value of attribute trainer.



4
5
6
# File 'lib/coo-coo/trainer/batch_stats.rb', line 4

def trainer
  @trainer
end

Instance Method Details

#average_lossObject



22
23
24
# File 'lib/coo-coo/trainer/batch_stats.rb', line 22

def average_loss
  total_loss / batch_size.to_f
end

#average_timeObject



18
19
20
# File 'lib/coo-coo/trainer/batch_stats.rb', line 18

def average_time
  total_time / batch_size.to_f
end