Giter Site home page Giter Site logo

Comments (9)

j3nsykes avatar j3nsykes commented on May 27, 2024

I have narrowed this down to the model.json array structure being structured differently on .save() with latest alpha releases. I have to step back to version [email protected] to get the model load() function to work but of course this is not compatible with the latest ml5.hand.pose
Is there a fix that can be made to the json array structure so load() will work with the later alpha versions of ml5?

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

JSON structure for version 0.4.3

{"modelTopology":{
  "class_name":"Sequential",
  "config":[{"class_name":"Dense","config":{"units":16,"activation":"sigmoid","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense1","trainable":true,"batch_input_shape":[null,2],"dtype":"float32"}},{"class_name":"Dense","config":{"units":1,"activation":"sigmoid","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_avg","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense2","trainable":true}}],"keras_version":"tfjs-layers 1.2.2","backend":"tensor_flow.js"},"weightsManifest":[{"paths":["./model.weights.bin"],"weights":[{"name":"dense_Dense1/kernel","shape":[2,16],"dtype":"float32"},{"name":"dense_Dense1/bias","shape":[16],"dtype":"float32"},{"name":"dense_Dense2/kernel","shape":[16,1],"dtype":"float32"},{"name":"dense_Dense2/bias","shape":[1],"dtype":"float32"}]}]}

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

model.JSON for later versions

{
  "modelTopology": {
    "class_name": "Sequential",
    "config": {
      "name": "sequential_1",
      "layers": [
        {
          "class_name": "Dense",
          "config": {
            "units": 16,
            "activation": "relu",
            "use_bias": true,
            "kernel_initializer": {
              "class_name": "VarianceScaling",
              "config": {
                "scale": 1,
                "mode": "fan_avg",
                "distribution": "normal",
                "seed": null
              }
            },
            "bias_initializer": { "class_name": "Zeros", "config": {} },
            "kernel_regularizer": null,
            "bias_regularizer": null,
            "activity_regularizer": null,
            "kernel_constraint": null,
            "bias_constraint": null,
            "name": "dense_Dense1",
            "trainable": true,
            "batch_input_shape": [null, 42],
            "dtype": "float32"
          }
        },
        {
          "class_name": "Dense",
          "config": {
            "units": 1,
            "activation": "sigmoid",
            "use_bias": true,
            "kernel_initializer": {
              "class_name": "VarianceScaling",
              "config": {
                "scale": 1,
                "mode": "fan_avg",
                "distribution": "normal",
                "seed": null
              }
            },
            "bias_initializer": { "class_name": "Zeros", "config": {} },
            "kernel_regularizer": null,
            "bias_regularizer": null,
            "activity_regularizer": null,
            "kernel_constraint": null,
            "bias_constraint": null,
            "name": "dense_Dense2",
            "trainable": true
          }
        }
      ]
    },
    "keras_version": "tfjs-layers 4.8.0",
    "backend": "tensor_flow.js"
  },
  "weightsManifest": [
    {
      "paths": ["./model.weights.bin"],
      "weights": [
        {
          "name": "dense_Dense1/kernel",
          "shape": [42, 16],
          "dtype": "float32"
        },
        { "name": "dense_Dense1/bias", "shape": [16], "dtype": "float32" },
        { "name": "dense_Dense2/kernel", "shape": [16, 1], "dtype": "float32" },
        { "name": "dense_Dense2/bias", "shape": [1], "dtype": "float32" }
      ]
    }
  ]
}

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

So you can see config is structured differently.

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

Although to note: the newer JSON structure works fine with classification and can be saved and loaded without issue. Its only regression i am seeing this error

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

This is definitely specific to
https://unpkg.com/[email protected]/dist/ml5.js

I can now run the regression training, saving and loading with
'https://unpkg.com/ml5@latest/dist/ml5.min.js'

from ml5-library.

lindapaiste avatar lindapaiste commented on May 27, 2024

Looks like the 0.4.3 version stores the array of layers as the modelTopology.config property, whereas in the newer version it is modelTopology.config.layers. This may have been a change in how TFJS saves the file. We would want to support legacy files which were trained under the old version.

The specific error message "modelTopology field is missing from file model.json" is odd though. It makes me wonder if we are passing it to TFJS incorrectly. Like passing a portion of the object rather than the whole object. Or passing model_meta.json instead of model.json or something like that.

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

So I have tried to see if editing the array structure from how the modelTopology.config is formatted to the newer version of modelTopology.config.layers matters and is doesn't matter to https://unpkg.com/ml5@latest/dist/ml5.min.js versions (eg: it accepts both old and new array structures / old and new ways the file is saved) but neither array structure works for https://unpkg.com/[email protected]/dist/ml5.js which makes me think it isn't directly the array structure but more the way the model.json or model_meta.json file is loaded in load() function in the alpha versions of ML5 as you suspect.

from ml5-library.

j3nsykes avatar j3nsykes commented on May 27, 2024

It is also unrelated to handpose.js as this error persists even on a simple mouse position regression example.

from ml5-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.