Property 'print' does not exist on type 'Tensor<Rank>[]'.
See original GitHub issueIf you would like to get help from the community, our Google group might be a better fit.
TensorFlow.js version
0.6.1
Browser version
Describe the problem or feature request
I use Typescript environment (Angular 5)
I trying to run this code from thehttps://js.tensorflow.org/#getting-started
import * as tf from '@tensorflow/tfjs';
// Define a model for linear regression.
const model = tf.sequential();
model.add(tf.layers.dense({units: 1, inputShape: [1]}));
// Prepare the model for training: Specify the loss and the optimizer.
model.compile({loss: 'meanSquaredError', optimizer: 'sgd'});
// Generate some synthetic data for training.
const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]);
const ys = tf.tensor2d([1, 3, 5, 7], [4, 1]);
// Train the model using the data.
model.fit(xs, ys).then(() => {
// Use the model to do inference on a data point the model hasn't seen before:
model.predict(tf.tensor2d([5], [1, 1])).print();
});
ERROR in src/app/app.component.ts(29,47): error TS2339: Property 'print' does not exist on type 'Tensor<Rank> | Tensor<Rank>[]'.
Property 'print' does not exist on type 'Tensor<Rank>[]'.
I think is the model.d.ts file please add the print
method inside this file
Code to reproduce the bug / link to feature request
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Tensorflow.js print() and dataSync methods on model.predict ...
Property 'dataSync' does not exist on type 'Tensor<Rank> | Tensor<Rank>[]'. or proptery 'print' ... – Happy Machine. Oct 1, 2018 at 14:24. Is...
Read more >Introduction to Tensors | TensorFlow Core
Tensor 's data type use the Tensor.dtype property. When creating a tf.Tensor from a Python object you may optionally specify the datatype. If...
Read more >Source code for hottbox.algorithms.decomposition.cpd
Computed via alternating least squares (ALS) Parameters ---------- init : str Type of factor matrix initialisation. Available options are `svd` and `random` ...
Read more >Tensor Decompositions and Applications
There are many other tensor decompositions, including INDSCAL, ... This type of result does not hold true for higher-order tensors. For instance,.
Read more >The Complexity of Tensor Rank
the tensor rank problem remains NP-hard over R and C; this is not immediate, since, ... There are many computational problems related to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @George35mk
We wrote that example for es6 javascript. For typescript, since predict() can return either a
Tensor
, orTensor[]
, depending on how many outputs your model has, you have to notify the compiler which one it is:Hope this helps!
const result = model.predict(tf.tensor2d(input, [1, 1])) as tf.Tensor; // this is a tensor
const data = await result.data(); // will return a promise with the Y value ( result )