Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
Array of Tensors you are passing to your model is not the size the model expected. Expected to see 1 Tensor(s), but instead got 0 Tensors(s)

I'm trying to pass in an array of strings and integers as training data, with a single boolean (0 or 1) as the label. However, after creating the training array and passing it to Tensorflow's fitDataset function, it complains that there are 0 tensors found.

csvTransform2 =
  ((val: any) => {
    const {xs, ys} = val
  
    console.log(xs)
    const values = Object.values(xs) as any[]
    return {xs: values, ys: ys.winner};
  })

async predict () {
    // Train a simple model:
    let trainingData = tf.data.csv('file://file.csv', {columnConfigs: {winner: {isLabel: true}}})
    const numOfColumns =  (await trainingData.columnNames()).length - 1;

    let newTrainingData = trainingData.map(this.csvTransform2);

    const model = tf.sequential();
    model.add(tf.layers.dense({units: 64, activation: 'relu', inputShape: [numOfColumns]}));
    model.add(tf.layers.dense({units: 32, activation: 'relu'}));
    model.add(tf.layers.dense({units: 8, activation: 'relu'}));
    model.add(tf.layers.dense({units: 1, activation: 'softmax'}));
    model.compile({
      optimizer: 'sgd', 
      loss: 'sparseCategoricalCrossentropy',
      metrics: ['accuracy']
    });

    model.fitDataset(newTrainingData, {
      epochs: 10,
      callbacks: {
        onEpochEnd: async (epoch, logs) => {
          console.log(epoch + ':' + logs.loss);
        }
      }
    });
  }

The full error is

ValueError: Error when checking model : the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see 1 Tensor(s), but instead got 0 Tensors(s).

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda