Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
How to get value of tensor2d in tensorflow.js model which corresponds to a numpy array

So I have h5 Keras Tensorflow Deep Learning model which accepts a NumPy array as an input and gives the desired numerical result in a form of a NumPy array (Python)

input of a numpy array in model.predict function

Now I want to do the same in tensorflow.js so I converted the model and imported it and used the model.predict function (JavaScript)

    const x = tf.tensor2d([company_name])
    const output = model.predict(x)
    console.log(output)

And I get this as the output

Tensor {
  kept: false,
  isDisposedInternal: false,
  shape: [ 1, 1 ],
  dtype: 'float32',
  size: 1,
  strides: [ 1 ],
  dataId: { id: 35 },
  id: 52,
  rankType: '2',
  scopeId: 0
}

I would like to get the actual value of the tensor2d like 38.340986 that I got in the NumPy array. I tried using

model.predict(x.get(0,0));

But it returns a type error

Help is appreciated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You will need to download the tensors when using Tensorflow.js

const output = model.predict(x).dataSync()
about 4 years ago · Juan Pablo Isaza Report

0

Tensors are the core datastructure of TensorFlow.js They are a generalization of vectors and matrices to potentially higher dimensions.

model.predict(np.array([value1], [value2])))
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!