Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scalar multiplication of tensors

In TensorFlow Core for Python there is an operation called tf.math.scalar_mul.

I would like to scale tensors in TensorFlow.js. By trying for instance a * 0.1 I get an error message (at least from Typescript):The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.ts(2362).

Is scaling tensors applicable without making them arrays, scale elementwise then transform back to tensors?

like image 716
G. Debailly Avatar asked Jan 22 '26 21:01

G. Debailly


1 Answers

Though, tf.scalar can be used, one can also use direclty tensor.mul(number) like the following

tf.tensor([1, 2, 3, 4]).mul(5).print(); // [5, 10, 15, 20]
like image 88
edkeveked Avatar answered Jan 27 '26 00:01

edkeveked



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!