Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda