Closed wzzhu closed 4 years ago
The problem occurs when multiplying a true scalar with a scalar tensor, correct? For example, if you put "a" in a tensor, does it works as expected?
The problem occurs when multiplying a true scalar with a scalar tensor, correct? For example, if you put "a" in a tensor, does it works as expected?
It still fails if changing "a" as
a := tensor.NewDense(tensor.Float64, tensor.Shape{1}, tensor.WithBacking([]float64{2}))
This bug is serious since it affects gorgonia's solvers (Affecting AdamSolver, VanillaSolver and others, but not RMSPropSolver!) when using
if _, err = tensor.Mul(eta, g, tensor.UseUnsafe()); err != nil {
where eta is a {}interface {float value}
Note that RMSPropSolver uses "tensor.Mul(g, eta, ...) and avoids the problem.
I made a fix, I hope that will solve your problems.
The tenor.Mul has bug in multiplying tensor with shape(1, 1). See the test code below. This might be caused by https://github.com/gorgonia/tensor/pull/54
The reason is that e.E.Mul(typ, dataA, retVal.hdr()) always assuming the result would be kept in dataA.