Skip to content

Commit

Permalink
Added negative inf check
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanNaren committed Dec 2, 2016
1 parent 2975947 commit e453440
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function Network:trainNetwork(epochs, optimizerParams)
sizes = self.calSize(sizes)
local predictions = self.model:forward(inputs)
local loss = criterion:forward(predictions, targets, sizes)
if loss == math.huge then loss = 0 print("Recieved an inf cost!") end
if loss == math.huge or loss == -math.huge then loss = 0 print("Recieved an inf cost!") end
self.model:zeroGradParameters()
local gradOutput = criterion:backward(predictions, targets)
self.model:backward(inputs, gradOutput)
Expand Down

0 comments on commit e453440

Please sign in to comment.