fixed Linear.Forward with bias is nil and clean up
This commit is contained in:
parent
b3d821d34e
commit
1cffab577c
|
@ -245,7 +245,7 @@ func (k *kaimingUniformInit) InitTensor(dims []int64, device gotch.Device, dtype
|
|||
retVal.Uniform_(-bound, bound)
|
||||
*/
|
||||
|
||||
// For now, just make a random norm
|
||||
// NOTE. For now, just make a random norm
|
||||
retVal = ts.MustRandn(dims, dtype, device)
|
||||
|
||||
return retVal
|
||||
|
|
|
@ -100,7 +100,11 @@ func NewLinear(vs *Path, inDim, outDim int64, c *LinearConfig) *Linear {
|
|||
// 1 1 1 ]
|
||||
func (l *Linear) Forward(xs *ts.Tensor) (retVal *ts.Tensor) {
|
||||
mul := xs.MustMatmul(l.Ws, false)
|
||||
return mul.MustAdd(l.Bs, true)
|
||||
if l.Bs != nil {
|
||||
return mul.MustAdd(l.Bs, true)
|
||||
} else {
|
||||
return mul
|
||||
}
|
||||
}
|
||||
|
||||
// ForwardT implements ModuleT interface for Linear layer.
|
||||
|
|
|
@ -129,7 +129,9 @@ func freeCTensor(ts *Tensor) error {
|
|||
|
||||
// Just return if it has been deleted previously!
|
||||
if unsafe.Pointer(ts.ctensor) == nil {
|
||||
log.Printf("INFO: ctensor is nil. Nothing to delete here...\n")
|
||||
if gotch.Debug {
|
||||
log.Printf("INFO: ctensor is nil. Nothing to delete here...\n")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user