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

203
Vistas
Merge and Save model in tensorflow.js after training in browser

I am following a tensorflow.js tutorial, in which I am loading a mobilenet as a backbone

<html>
  <head>
    <!-- Load the latest version of TensorFlow.js -->
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet"></script>
  </head>

and in js it is called as net

 net = await mobilenet.load();

Then the tutorial continuous by adding a "K-Nearest Neighbors Classifier"-Layer

<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/knn-classifier"></script>

and later call it by classifier

const classifier = knnClassifier.create();

after then adding samples to the Classifier, for making predictions the whole pipeline has to be inferred

// Get the activation from mobilenet.
const activation = net.infer(img, 'conv_preds');
// Then feed the activation to the custom output layer
const result = await classifier.predictClass(activation);

Now I want to download the whole model (net + classifier) as a .hdf file or similar. How do I do this? Do I still have to merge these two?

I know the model.save functionalities within python tensorflow and keras, but am lost as to how this is best done in tensorflow.js

Update - Currently I am trying something along the lines of

  // merging the model and then downloading it
  const merge_models = async (backbone, outputlayer) => {
      console.log('Downloading your model..');
    const model = tf.sequential();
    model.add(backbone);
    model.add(outputlayer);
    
    // download
    await model.save('downloads://my-model');
    console.log('..is completed.');
  };

but I am getting an error in the add function

TypeError: Cannot read properties of undefined (reading 'length')
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