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

194
Views
¿Hay alguna manera de reducir el conv2d_Conv2D1_input esperado de 4 dimensiones a 3?

Problema :

  • un ValueError dice que conv2d_Conv2D1_input espera tener 4 dimensiones, pero obtuvo una matriz con forma [475,475,3]

Sin embargo:

  • La forma de entrada se establece en [475,475,3]
  • cuando se registran, los tensores tienen la forma [475,475,3]

Error: ValueError: Error when checking : expected conv2d_Conv2D1_input to have 4 dimension(s), but got array with shape [475,475,3]

Tensor:

 Tensor { kept: false, isDisposedInternal: false, shape: [ 475, 475, 3 ], dtype: 'int32', size: 676875, strides: [ 1425, 3 ], dataId: {}, id: 8, rankType: '3', scopeId: 4 }

Código completo:

 var tf = require('@tensorflow/tfjs'); var tfnode = require('@tensorflow/tfjs-node'); var fs = require(`fs`) const main = async () => { const loadImage = async (file) => { const imageBuffer = await fs.readFileSync(file) const tensorFeature = await tfnode.node.decodeImage(imageBuffer, 3) return tensorFeature; } const tensorFeature = await loadImage(`./1.png`) const tensorFeature2 = await loadImage(`./4.png`) const tensorFeature3 = await loadImage(`./7.png`) console.log(tensorFeature) console.log(tensorFeature2) console.log(tensorFeature3) tensorFeatures = [tensorFeature, tensorFeature2, tensorFeature3] labelArray = [0, 1, 2] tensorLabels = tf.oneHot(tf.tensor1d(labelArray, 'int32'), 3); const model = tf.sequential(); model.add(tf.layers.conv2d({ inputShape: [475, 475, 3], filters: 32, kernelSize: 3, activation: 'relu', })); model.add(tf.layers.flatten()); model.add(tf.layers.dense({units: 3, activation: 'softmax'})); model.compile({ optimizer: 'sgd', loss: 'categoricalCrossentropy', metrics: ['accuracy'] }); model.summary() model.fit(tf.stack(tensorFeatures), tensorLabels) const im = await loadImage(`./2.png`) model.predict(im) } main()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La dimensión del lote es la misión. Se puede agregar usando expandDims()

 const im = await loadImage(`./2.png`).expandDims() model.predict(im)
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!