moving epsilon outside softplus

I think you intended this to be outside the softplus. The reason is that it should be applied just before the log to avoid `log(0)=inf`.e.g.

- `log(softplus(-1000+1e-5))=log(0)=inf`. 
- `log(softplus(-1000)+1e-5)=log(1e-5)!=inf`. 

Also this fixes a NaN I had.
This commit is contained in:
Mike Clark
2017-11-01 10:52:23 +08:00
committed by GitHub
parent 55ae92619a
commit 212ff0bc70
+1 -1
View File
@@ -145,7 +145,7 @@ class GaussianActorNet(nn.Module, BasicNet):
log_std = self.action_log_std.expand_as(mean)
std = log_std.exp()
else:
std = F.softplus(self.action_std(phi) + 1e-5)
std = F.softplus(self.action_std(phi)) + 1e-5
log_std = std.log()
return mean, std, log_std