Closed
Description
TensorFlow.js version
0.12.3
Browser version
Node.js 10.6.0 (no browser)
Typescript 2.7.1
Describe the problem or feature request
I'm trying to use tf.sum()
and tf.squaredDifference()
(see below). Two issues -- some or all might be my fault:
- According to the docs, I can pass a
tf.scalar
totf.squaredDifference
; however, I get a Typescript error when passing atf.scalar
unless I cast toany
. Seems it's expecting aTensor
. Are the docs wrong, or is the Typescript definition too restrictive here? - When I run the below code to sum my tensor (vector), I get the error
tensor1d() requires values to be a flat/TypedArray
. This already should be a 1D tensor/vector, so why is tfjs complaining here? But moreover, the docs suggest I can sum with higher-order tensors as well, so not sure what the 1D restriction is about. Any ideas would be welcome!
Thanks in advance!
Code to reproduce the bug / link to feature request
// state is a tf.Tensor1D
console.log(state.squaredDifference(tf.scalar(0) as any).sum());
Metadata
Metadata
Assignees
Labels
No labels