Skip to content

Commit

Permalink
logger and loss visualizer for training
Browse files Browse the repository at this point in the history
  • Loading branch information
robotsorcerer committed Jul 4, 2016
1 parent d2d567d commit 6d3d1d5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions linear-regression/example-linear-regression.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
--

-- note: to run this script, simply do:
-- torch script.lua
-- th example-linear-regression.lua

-- to run the script, and get an interactive shell once it terminates:
-- torch -i script.lua
-- th -i example-linear-regression.lua

-- we first require the necessary packages.
-- note: optim is a 3rd-party package, and needs to be installed
Expand All @@ -21,6 +21,8 @@ require 'torch'
require 'optim'
require 'nn'

-- We will write the loss to a text file and read from there to plot the loss as training proceeds
logger = optim.Logger('loss_log.txt')

----------------------------------------------------------------------
-- 1. Create the training data
Expand Down Expand Up @@ -209,10 +211,12 @@ for i = 1,1e4 do
-- report average error on epoch
current_loss = current_loss / (#data)[1]
print('current loss = ' .. current_loss)


logger:add{['training error'] = current_loss}
logger:style{['training error'] = '-'}
logger:plot()
end


----------------------------------------------------------------------
-- 5. Test the trained model.

Expand Down

0 comments on commit 6d3d1d5

Please sign in to comment.