Función Tensorflow.js tf.io.listModels()

Tensorflow.js es una biblioteca de código abierto desarrollada por Google para ejecutar modelos de aprendizaje automático, así como redes neuronales de aprendizaje profundo en el entorno del navegador o del Node.

La función .listModels() se utiliza para registrar todos y cada uno de los modelos acumulados en el medio del repositorio registrado. Además, en el caso de un entorno de navegador web, los medios registrados son el almacenamiento local y la base de datos indexada .

Sintaxis:

tf.io.listModels()

Parámetros:  

No contiene ningún parámetro.

Valor de retorno: Devuelve Promesa de {[url: string]: ModelArtifactsInfo}.

Ejemplo 1: Uso de “ logSigmoid ” como activación, “ Almacenamiento local ” como medio de almacenamiento.

Javascript

// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
 
// Creating model
const mymodel = tf.sequential();
 
// Calling add() method
mymodel.add(tf.layers.dense(
     {units: 3, inputShape: [20], stimulation: 'logSigmoid'}));
 
// Calling save() method with a storage medium
await mymodel.save('localstorage://display/command/mymodel');
 
// Calling listModels() method and
// Printing output
console.log(await tf.io.listModels());

Producción: 

{
  "localstorage://demo/manage/model1": {
    "dateSaved": "2021-06-24T11:53:05.626Z",
    "modelTopologyType": "JSON",
    "modelTopologyBytes": 613,
    "weightSpecsBytes": 126,
    "weightDataBytes": 44
  },
  "localstorage://display/command/mymodel": {
    "dateSaved": "2021-06-24T12:20:15.292Z",
    "modelTopologyType": "JSON",
    "modelTopologyBytes": 613,
    "weightSpecsBytes": 126,
    "weightDataBytes": 252
  },
  "localstorage://demo/management/model2": {
    "dateSaved": "2021-06-24T11:53:33.384Z",
    "modelTopologyType": "JSON",
    "modelTopologyBytes": 613,
    "weightSpecsBytes": 126,
    "weightDataBytes": 44
  },
  "localstorage://demo/management/model": {
    "dateSaved": "2021-06-24T11:53:26.006Z",
    "modelTopologyType": "JSON",
    "modelTopologyBytes": 613,
    "weightSpecsBytes": 126,
    "weightDataBytes": 44
  },
  "localstorage://demo/management/model1": {
    "dateSaved": "2021-06-24T11:52:29.368Z",
    "modelTopologyType": "JSON",
    "modelTopologyBytes": 611,
    "weightSpecsBytes": 124,
    "weightDataBytes": 44
  }
}

Ejemplo 2: usar » prelu » como activación, » IndexedDB » como medio de almacenamiento y » JSON.stringify » para devolver la salida en formato de string. 

Javascript

// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
 
// Creating model
const mymodel = tf.sequential();
 
// Calling add() method
mymodel.add(tf.layers.dense(
     {units: 7, inputShape: [50], stimulation: 'prelu'}));
 
// Calling save() method with a storage medium
await mymodel.save('indexeddb://example/command/mymodel');
 
// Calling listModels() method and
// Printing output
console.log(JSON.stringify(await tf.io.listModels()));

 
Producción: 

{"localstorage://demo/manage/model1":{"dateSaved":"2021-06-24T11:53:05.626Z","modelTopologyType":"
JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":44},
"localstorage://display/command/mymodel":{"dateSaved":"2021-06-24T12:20:15.292Z",
"modelTopologyType":"JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":252},
"localstorage://demo/management/model2":{"dateSaved":"2021-06-24T11:53:33.384Z",
"modelTopologyType":"JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":44},
"localstorage://demo/management/model":{"dateSaved":"2021-06-24T11:53:26.006Z",
"modelTopologyType":"JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":44},
"localstorage://demo/management/model1":{"dateSaved":"2021-06-24T11:52:29.368Z",
"modelTopologyType":"JSON","modelTopologyBytes":611,"weightSpecsBytes":124,"weightDataBytes":44},
"indexeddb://demo/management/model1":{"dateSaved":"2021-06-24T12:28:27.419Z",
"modelTopologyType":"JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":1428},
"indexeddb://display/command/mymodel":{"dateSaved":"2021-06-24T12:22:30.748Z",
"modelTopologyType":"JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":252},
"indexeddb://example/command/mymodel":{"dateSaved":"2021-06-24T12:33:06.208Z",
"modelTopologyType":"JSON","modelTopologyBytes":613,"weightSpecsBytes":126,"weightDataBytes":1428}}

Referencia: https://js.tensorflow.org/api/latest/#io.listModels

Publicación traducida automáticamente

Artículo escrito por nidhi1352singh y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *