Estoy siguiendo un tutorial de tensorflow.js, en el que estoy cargando una red móvil como red troncal
<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> y en js se llama net
net = await mobilenet.load();Luego, el tutorial continúa agregando una capa "K-Nearest Neighbors Classifier"
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/knn-classifier"></script> y luego llamarlo por classifier
const classifier = knnClassifier.create();después de agregar muestras al Clasificador, para hacer predicciones, se debe inferir toda la tubería
// 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); Ahora quiero descargar todo el modelo ( net + classifier ) como un archivo .hdf o similar. ¿Cómo hago esto? ¿Todavía tengo que fusionar estos dos?
Conozco las funcionalidades de model.save dentro de python tensorflow y keras, pero no sé cómo se hace mejor en tensorflow.js
Actualización: actualmente estoy intentando algo similar a
// 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.'); };pero estoy recibiendo un error en la función de agregar
TypeError: Cannot read properties of undefined (reading 'length')