Giter VIP home page Giter VIP logo

ml4f's Introduction

ML4F - Machine Learning model compiler for Cortex-M4F

ML4F takes a Keras sequential model as an input and compiles it directly to ARM Thumb machine code for Cortex-M4F and better (M7, M33 etc.). The performance (latency) is typically an order of magnitude better than the Tensorflow Lite for Microcontrollers interpreter (with float32 models).

The input model generally needs to be in Tensorflow.js format, but the command line tool can invoke Python scripts to convert from .h5 or .pb models. Once compiled, weights can be stored as float32 or float16.

The following operators are supported:

  • Conv1D
  • Conv2D
  • DepthwiseConv1D
  • DepthwiseConv2D
  • MaxPooling1D
  • MaxPooling2D
  • AveragePooling1D
  • AveragePooling2D
  • Dense
  • Softmax
  • Activation
  • BatchNormalization

Plus some no-ops:

  • InputLayer
  • Dropout
  • Flatten
  • Reshape

Feel free to report what other operators might be useful (along with example models) via GitHub Issues.

Usage

npm i -g ml4f
ml4f my-model

Typical invocation might look like this:

ml4f           --basename model-float32 my-model.h5
ml4f --float16 --basename model-float16 built/converted.tfjs

First line compiles my-model.h5 using float32 weights, with results in built/model-float32.*. The second line compiles with float16 weights, using temporary file created by the first line to speed things up (Python TensorFlow is really slow to load). Results are in built/model-float16.*.

Run ml4f --help for more info.

You can also use it as a library from a browser (in which case it can only take TF.js models).

Evaluating models

You can pass --eval test.json option to evaluated the model on given input data - this will print confusion matrix and accuracy. The test.json has two fields x and y. The field x contains a batch of input tensors, and y a batch of output tensors, with proper nesting. For example, for input of shape 2x3 and output of shape 4:

{ 
  "x": [
    [ [ 0.1, 0.2, -0.3 ], [ 0.2, -0.22, 0 ] ],
    [ [ -0.1, 0.3, 0.1 ], [ 0.32, 0.2, 1 ] ]
  ],
  "y": [
      [ 0, 1, 0, 0 ],
      [ 1, 0, 0, 0 ]
  ]
}

If you have data as NumPy arrays, you can use the following snippet to save it as JSON:

import json
class NumpyEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, np.ndarray):
            return obj.tolist()
        return json.JSONEncoder.default(self, obj)

with open('test.json', 'w') as outfile:
    json.dump({"x": xs_test, "y": ys_test}, outfile, cls=NumpyEncoder)

Evaluation stats look like the following:

Accuracy: 0.9560
  245    0    1    2
    6   84    4    0
    3    2   73    0
    4    0    0   76

model: 12.75k; code: 2.46k (19.3%); arena: 4.38k; test 0.00k
total cycles: 225149 (2.680ms at 84MHz)

Architecture

The models are loaded using TensorFlow.js library. Each layer is first compiled separately, and the generated code is run in simulation (a JavaScript function is generated, where each line corresponds to a single assembly instruction). The results are compared with running the same layer in TensorFlow.js. This process can be disabled with --no-validate option. Then layers are composed and the final binary code is generated.

The binary is position-independent and can be loaded from any word-aligned address in flash or RAM. Look in sample/ folder for example invocation from C, or check out our MakeCode extension.

Compiling

yarn install
yarn watch
# in another window
http-server -c1

Then open http://localhost:8080/

Also, run ./ml4f in this folder.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

ml4f's People

Contributors

microsoft-github-operations[bot] avatar microsoftopensource avatar mmoskal avatar pelikhan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ml4f's Issues

Support for "linear"/"relu" Activation layer

We are currently looking to see if we can convert a Keras model with ml4f. The current model is exported Tensorflow Micro to run on the micro:bit for the Next Gen project and we wanted to see how it'd perform with ml4f.

When converting the model with the --debug flag, the the final part of the output prints the following:

Layer: Conv2D; data: [250,3,1]@0 => [76,1,20]@1520 1237604 cycles (13.7% opt)
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
input_1 (InputLayer)         [null,250,3]              0         
_________________________________________________________________
reshape (Reshape)            [null,250,3,1]            0         
_________________________________________________________________
conv2d (Conv2D)              [null,76,1,20]            1520      
_________________________________________________________________
activation (Activation)      [null,76,1,20]            0         
_________________________________________________________________
batch_normalization (BatchNo [null,76,1,20]            80        
_________________________________________________________________
average_pooling2d (AveragePo [null,38,1,20]            0         
_________________________________________________________________
sequential (Sequential)      [null,11,1,64]            1856      
_________________________________________________________________
sequential_1 (Sequential)    [null,2,1,64]             4864      
_________________________________________________________________
flatten (Flatten)            [null,128]                0         
_________________________________________________________________
transfer_dense_1 (Dense)     [null,32]                 4128      
_________________________________________________________________
dropout (Dropout)            [null,32]                 0         
_________________________________________________________________
transfer_dense_out (Dense)   [null,4]                  132       
_________________________________________________________________
softmax (Softmax)            [null,4]                  0         
=================================================================
Total params: 12580
Trainable params: 12284
Non-trainable params: 296
_________________________________________________________________
Layer: InputLayer; data: [250,3]@0 => [250,3]@0 (no computation)
Layer: Reshape; data: [250,3]@0 => [250,3,1]@0 (no computation)
[ null, 250, 3, 1 ] [ null, 76, 1, 20 ] {
  filters: 20,
  kernelInitializer: {
    className: 'VarianceScaling',
    config: { scale: 1, mode: 'fanAvg', distribution: 'uniform', seed: null }
  },
  kernelRegularizer: null,
  kernelConstraint: null,
  kernelSize: [ 25, 3 ],
  strides: [ 3, 1 ],
  padding: 'valid',
  dataFormat: 'channelsLast',
  dilationRate: [ 1, 1 ],
  activation: 'linear',
  useBias: true,
  biasInitializer: { className: 'Zeros', config: {} },
  biasRegularizer: null,
  activityRegularizer: null,
  biasConstraint: null,
  name: 'conv2d',
  trainable: true
}
Layer: Conv2D; data: [250,3,1]@0 => [76,1,20]@1520 1237604 cycles (13.7% opt)
Error: Unsupported operator or config: layer: Activation
    at unsupported (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:2605:15)
    at compileModelCore (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:3074:17)
    at compileAndTest (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:4015:24)
    at Object.compileModelAndFullValidate (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:3982:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processModelFile (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/cli/cli.js:124:66)
    at async Object.mainCli (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/cli/cli.js:180:9)

Looking at the project README, Activation should be supported, is this specific Activation type what needs support?
The tool output indicates "linear" Activation, but I think when Activation functions have been used they have been configured with "relu". @neil-tan could you confirm this is the case?

We are in the process to open source everything, but right now the repos are still private. @mmoskal in the meantime I've invited you to the repositories in case you'd like have a look at the code creating the model and the model itself:

Model configuration: https://github.com/microbit-foundation/microbit-ml-adl/blob/reduced_labels_c1_5/transfer_learning.py
Model file: https://github.com/microbit-foundation/microbit-ml-adl/blob/reduced_labels_c1_5/models/transfer_finetuned_model_dw250_c1_5.h5

Activation layers:

mlf4f full output can be expanded here
$ npx ml4f --output ml4fbuild --debug models/transfer_finetuned_model_dw250_c1_5.h5
RUN tensorflowjs_converter --input_format keras --output_format tfjs_layers_model models/transfer_finetuned_model_dw250_c1_5.h5 ml4fbuild/converted.tfjs
2024-03-07 17:21:21.805144: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
RUN OK
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
input_1 (InputLayer)         [null,250,3]              0         
_________________________________________________________________
reshape (Reshape)            [null,250,3,1]            0         
_________________________________________________________________
conv2d (Conv2D)              [null,76,1,20]            1520      
_________________________________________________________________
activation (Activation)      [null,76,1,20]            0         
_________________________________________________________________
batch_normalization (BatchNo [null,76,1,20]            80        
_________________________________________________________________
average_pooling2d (AveragePo [null,38,1,20]            0         
_________________________________________________________________
sequential (Sequential)      [null,11,1,64]            1856      
_________________________________________________________________
sequential_1 (Sequential)    [null,2,1,64]             4864      
_________________________________________________________________
flatten (Flatten)            [null,128]                0         
_________________________________________________________________
transfer_dense_1 (Dense)     [null,32]                 4128      
_________________________________________________________________
dropout (Dropout)            [null,32]                 0         
_________________________________________________________________
transfer_dense_out (Dense)   [null,4]                  132       
_________________________________________________________________
softmax (Softmax)            [null,4]                  0         
=================================================================
Total params: 12580
Trainable params: 12284
Non-trainable params: 296
_________________________________________________________________
Validating partial models...
testing Conv2D: [250,3,1] => [76,1,20]...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
conv2d (Conv2D)              [null,76,1,20]            1520      
=================================================================
Total params: 1520
Trainable params: 1520
Non-trainable params: 0
_________________________________________________________________
[ null, 250, 3, 1 ] [ null, 76, 1, 20 ] {
  filters: 20,
  kernelInitializer: {
    className: 'VarianceScaling',
    config: { scale: 1, mode: 'fanAvg', distribution: 'uniform', seed: null }
  },
  kernelRegularizer: null,
  kernelConstraint: null,
  kernelSize: [ 25, 3 ],
  strides: [ 3, 1 ],
  padding: 'valid',
  dataFormat: 'channelsLast',
  dilationRate: [ 1, 1 ],
  activation: 'linear',
  useBias: true,
  biasInitializer: { className: 'Zeros', config: {} },
  biasRegularizer: null,
  activityRegularizer: null,
  biasConstraint: null,
  name: 'conv2d',
  trainable: true,
  batchInputShape: [ null, 250, 3, 1 ],
  dtype: 'float32'
}
Layer: Conv2D; data: [250,3,1]@0 => [76,1,20]@750 1237084 cycles (13.7% opt)
total cycles: 1237084 (14.727ms at 84MHz)
Test output Float32Array(1520) [
   -0.6543942093849182,  -1.5987398624420166,    4.679758071899414,
    0.3610239624977112,   0.5543566942214966,  -1.8997654914855957,
    -1.243112564086914,   0.3233872354030609,  -3.5152804851531982,
   -1.9008723497390747,   1.3731722831726074,  -0.9202901124954224,
   -3.6674437522888184,   -2.608750104904175,   2.9830570220947266,
    1.1572322845458984,  -1.3406109809875488,   -2.059849977493286,
     -6.13929557800293,  -2.2732644081115723,  -3.8865113258361816,
    3.6685848236083984,   0.3366440534591675,  -0.7717487812042236,
   -1.2727856636047363,   1.4740164279937744,   -2.459336042404175,
    -3.834590196609497,   3.2260305881500244,   1.4937301874160767,
  -0.23774562776088715,  0.16589975357055664,   1.9998061656951904,
     3.917616605758667,   1.1070278882980347, -0.13852745294570923,
    2.6381006240844727,   -6.204899311065674,   1.2381953001022339,
   -0.7501019835472107,    3.885274648666382,   1.8398363590240479,
   -1.3074214458465576,  0.49256426095962524,   -4.247359275817871,
   -2.6867311000823975,   -3.137449026107788,  -0.7782284021377563,
    0.4831981658935547, 0.046072423458099365,  -3.9969711303710938,
   -6.7271270751953125,    1.109713077545166,    1.979538083076477,
    1.2244105339050293,   1.5509064197540283,   3.8467490673065186,
    3.6345109939575195,   -2.223506212234497,  -1.3395938873291016,
     4.270734786987305,  -2.9101133346557617,    2.987860918045044,
    -1.573803424835205,  -0.9366786479949951,    4.285688400268555,
    2.9084129333496094,   1.4391733407974243,   -2.573387861251831,
    1.3292585611343384,    4.322605133056641,   2.8347506523132324,
   -0.7743972539901733,   1.4138282537460327,    -3.13751482963562,
   -1.7189602851867676,    5.751336574554443,  -0.8854779005050659,
     5.005840301513672,  -1.3907403945922852,  0.10051273554563522,
    1.4028103351593018,   3.4799532890319824,  -0.1328551471233368,
      2.20620059967041,   1.5114022493362427,   -2.716763734817505,
   -3.8681015968322754,   2.4142608642578125,   -4.160702228546143,
   -0.9808037281036377,    3.083132743835449,    5.198317050933838,
    -7.352654933929443,   0.9993666410446167,   0.6479471921920776,
    -5.731224060058594,  -1.0054080486297607,  -0.2493310570716858,
     4.042226791381836,
  ... 1420 more items
]
also with no activation...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
conv2d (Conv2D)              [null,76,1,20]            1520      
=================================================================
Total params: 1520
Trainable params: 1520
Non-trainable params: 0
_________________________________________________________________
[ null, 250, 3, 1 ] [ null, 76, 1, 20 ] {
  filters: 20,
  kernelInitializer: {
    className: 'VarianceScaling',
    config: { scale: 1, mode: 'fanAvg', distribution: 'uniform', seed: null }
  },
  kernelRegularizer: null,
  kernelConstraint: null,
  kernelSize: [ 25, 3 ],
  strides: [ 3, 1 ],
  padding: 'valid',
  dataFormat: 'channelsLast',
  dilationRate: [ 1, 1 ],
  activation: 'linear',
  useBias: true,
  biasInitializer: { className: 'Zeros', config: {} },
  biasRegularizer: null,
  activityRegularizer: null,
  biasConstraint: null,
  name: 'conv2d',
  trainable: true,
  batchInputShape: [ null, 250, 3, 1 ],
  dtype: 'float32'
}
Layer: Conv2D; data: [250,3,1]@0 => [76,1,20]@750 1237084 cycles (13.7% opt)
total cycles: 1237084 (14.727ms at 84MHz)
Test output Float32Array(1520) [
   0.20257160067558289,    1.6592046022415161,   0.9287804961204529,
   -3.1827306747436523,    1.4833396673202515,  -3.6374905109405518,
    -1.307392954826355,     6.236717700958252,    3.702615737915039,
    1.3866358995437622,    0.5585417747497559,    2.096182346343994,
    3.0644049644470215,  -0.08257564902305603,    4.523300647735596,
    -2.895974636077881,     3.872354507446289,   -4.038097381591797,
   -0.6986581087112427,   -3.5762250423431396,    2.978877067565918,
    2.5779786109924316,     6.626351833343506,    1.472097635269165,
   -1.8630352020263672,    3.0687551498413086,  -1.8141788244247437,
     -2.99149227142334,   -0.8446914553642273,   2.2210276126861572,
    -4.096405506134033,    0.5246019959449768,   0.1524740755558014,
   -1.3061646223068237,    1.8644702434539795,  -0.3695562481880188,
     4.641002178192139,     4.524179935455322,   0.9788439869880676,
     1.153949499130249,  -0.38989484310150146,   -2.404341459274292,
   0.14737750589847565,   0.22244125604629517,  -3.4457149505615234,
    3.8636856079101562,    2.3340110778808594,  -3.4669487476348877,
  -0.12754786014556885,     4.619879245758057,   1.9956555366516113,
   -1.1953635215759277,    2.8809518814086914,   5.2587995529174805,
   -0.3462246060371399,   -0.5038015842437744,  -2.4923758506774902,
    -2.686619520187378, -0.029805511236190796,  -1.2059459686279297,
   -1.4842612743377686,    0.2929033041000366,   1.2422633171081543,
     4.855828285217285,   0.17732632160186768,   1.7062472105026245,
     4.689605712890625,    3.9562244415283203,    6.329590797424316,
     2.384840965270996,     4.796898365020752,   6.4863691329956055,
    0.5371824502944946,    1.8567073345184326,  -3.7192957401275635,
    0.3204510807991028,    0.5646308660507202,  -2.6706080436706543,
  -0.48085135221481323,    -0.768836259841919,    3.879024028778076,
   -0.6133213043212891,    -2.619417667388916,   -4.077198505401611,
    2.1510939598083496,    -1.627598524093628, -0.12062239646911621,
   -2.6387510299682617,    -5.229059219360352, -0.20706093311309814,
   0.10825824737548828,   -1.6642056703567505,   -5.233810901641846,
   -1.6764822006225586,    -8.184328079223633,   1.6689088344573975,
     2.380209445953369,    0.8928894400596619,  -1.1060518026351929,
   -0.8695858716964722,
  ... 1420 more items
]
testing Dense: [128] => [32]...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
transfer_dense_1 (Dense)     [null,32]                 4128      
=================================================================
Total params: 4128
Trainable params: 4128
Non-trainable params: 0
_________________________________________________________________
Layer: Dense; data: [128]@0 => [32]@128 19027 cycles (1.3% opt)
total cycles: 19027 (0.227ms at 84MHz)
Test output Float32Array(32) [
                    0,                   0,
                    0,                   0,
    5.463869094848633,                   0,
                    0, 0.48411697149276733,
                    0,                   0,
   1.4437663555145264,   6.386779308319092,
   1.6513590812683105,  1.1667512655258179,
                    0,  2.8119921684265137,
  0.12458282709121704,                   0,
                    0,  2.3636178970336914,
                    0,  0.6894450187683105,
    6.159544467926025,                   0,
                    0,                   0,
   1.2253615856170654, 0.12330290675163269,
                    0,                   0,
    1.349872350692749, 0.45826905965805054
]
also with no activation...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
transfer_dense_1 (Dense)     [null,32]                 4128      
=================================================================
Total params: 4128
Trainable params: 4128
Non-trainable params: 0
_________________________________________________________________
Layer: Dense; data: [128]@0 => [32]@128 18821 cycles (0.7% opt)
total cycles: 18821 (0.224ms at 84MHz)
Test output Float32Array(32) [
   -0.7999378442764282,  6.2634100914001465,
    1.3373290300369263,   5.851600646972656,
    0.9642249345779419,  3.3023276329040527,
    1.7263872623443604,  -1.882416009902954,
     3.913378953933716, -1.0334539413452148,
    -9.435567855834961,   3.393305778503418,
    1.5487284660339355,   4.065755844116211,
   -6.1509785652160645,  -6.310978889465332,
    0.5820216536521912, -0.7537862062454224,
     4.397172451019287,  -2.292424440383911,
    -4.048943996429443, -1.9891817569732666,
   -0.1750953197479248,   5.590221881866455,
    -2.137423515319824,  -0.376464307308197,
    -3.073636054992676,  2.9212992191314697,
     -3.37052059173584,  1.7125061750411987,
  -0.25794073939323425,  1.8945446014404297
]
testing Dense: [32] => [4]...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
transfer_dense_out (Dense)   [null,4]                  132       
=================================================================
Total params: 132
Trainable params: 132
Non-trainable params: 0
_________________________________________________________________
Layer: Dense; data: [32]@0 => [4]@32 625 cycles (2.5% opt)
total cycles: 625 (0.007ms at 84MHz)
Test output Float32Array(4) [
  -1.1431775093078613,
  -1.435903549194336,
  -2.116854429244995,
  1.8963240385055542
]
also with no activation...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
transfer_dense_out (Dense)   [null,4]                  132       
=================================================================
Total params: 132
Trainable params: 132
Non-trainable params: 0
_________________________________________________________________
Layer: Dense; data: [32]@0 => [4]@32 625 cycles (2.5% opt)
total cycles: 625 (0.007ms at 84MHz)
Test output Float32Array(4) [
  1.3852261304855347,
  1.2913734912872314,
  -3.3826866149902344,
  -2.540109634399414
]
Compiling full model...
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
input_1 (InputLayer)         [null,250,3]              0         
_________________________________________________________________
reshape (Reshape)            [null,250,3,1]            0         
_________________________________________________________________
conv2d (Conv2D)              [null,76,1,20]            1520      
_________________________________________________________________
activation (Activation)      [null,76,1,20]            0         
_________________________________________________________________
batch_normalization (BatchNo [null,76,1,20]            80        
_________________________________________________________________
average_pooling2d (AveragePo [null,38,1,20]            0         
_________________________________________________________________
sequential (Sequential)      [null,11,1,64]            1856      
_________________________________________________________________
sequential_1 (Sequential)    [null,2,1,64]             4864      
_________________________________________________________________
flatten (Flatten)            [null,128]                0         
_________________________________________________________________
transfer_dense_1 (Dense)     [null,32]                 4128      
_________________________________________________________________
dropout (Dropout)            [null,32]                 0         
_________________________________________________________________
transfer_dense_out (Dense)   [null,4]                  132       
_________________________________________________________________
softmax (Softmax)            [null,4]                  0         
=================================================================
Total params: 12580
Trainable params: 12284
Non-trainable params: 296
_________________________________________________________________
Layer: InputLayer; data: [250,3]@0 => [250,3]@0 (no computation)
Layer: Reshape; data: [250,3]@0 => [250,3,1]@0 (no computation)
[ null, 250, 3, 1 ] [ null, 76, 1, 20 ] {
  filters: 20,
  kernelInitializer: {
    className: 'VarianceScaling',
    config: { scale: 1, mode: 'fanAvg', distribution: 'uniform', seed: null }
  },
  kernelRegularizer: null,
  kernelConstraint: null,
  kernelSize: [ 25, 3 ],
  strides: [ 3, 1 ],
  padding: 'valid',
  dataFormat: 'channelsLast',
  dilationRate: [ 1, 1 ],
  activation: 'linear',
  useBias: true,
  biasInitializer: { className: 'Zeros', config: {} },
  biasRegularizer: null,
  activityRegularizer: null,
  biasConstraint: null,
  name: 'conv2d',
  trainable: true
}
Layer: Conv2D; data: [250,3,1]@0 => [76,1,20]@1520 1237604 cycles (13.7% opt)
_________________________________________________________________
Layer (type)                 Output shape              Param #   
=================================================================
input_1 (InputLayer)         [null,250,3]              0         
_________________________________________________________________
reshape (Reshape)            [null,250,3,1]            0         
_________________________________________________________________
conv2d (Conv2D)              [null,76,1,20]            1520      
_________________________________________________________________
activation (Activation)      [null,76,1,20]            0         
_________________________________________________________________
batch_normalization (BatchNo [null,76,1,20]            80        
_________________________________________________________________
average_pooling2d (AveragePo [null,38,1,20]            0         
_________________________________________________________________
sequential (Sequential)      [null,11,1,64]            1856      
_________________________________________________________________
sequential_1 (Sequential)    [null,2,1,64]             4864      
_________________________________________________________________
flatten (Flatten)            [null,128]                0         
_________________________________________________________________
transfer_dense_1 (Dense)     [null,32]                 4128      
_________________________________________________________________
dropout (Dropout)            [null,32]                 0         
_________________________________________________________________
transfer_dense_out (Dense)   [null,4]                  132       
_________________________________________________________________
softmax (Softmax)            [null,4]                  0         
=================================================================
Total params: 12580
Trainable params: 12284
Non-trainable params: 296
_________________________________________________________________
Layer: InputLayer; data: [250,3]@0 => [250,3]@0 (no computation)
Layer: Reshape; data: [250,3]@0 => [250,3,1]@0 (no computation)
[ null, 250, 3, 1 ] [ null, 76, 1, 20 ] {
  filters: 20,
  kernelInitializer: {
    className: 'VarianceScaling',
    config: { scale: 1, mode: 'fanAvg', distribution: 'uniform', seed: null }
  },
  kernelRegularizer: null,
  kernelConstraint: null,
  kernelSize: [ 25, 3 ],
  strides: [ 3, 1 ],
  padding: 'valid',
  dataFormat: 'channelsLast',
  dilationRate: [ 1, 1 ],
  activation: 'linear',
  useBias: true,
  biasInitializer: { className: 'Zeros', config: {} },
  biasRegularizer: null,
  activityRegularizer: null,
  biasConstraint: null,
  name: 'conv2d',
  trainable: true
}
Layer: Conv2D; data: [250,3,1]@0 => [76,1,20]@1520 1237604 cycles (13.7% opt)
Error: Unsupported operator or config: layer: Activation
    at unsupported (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:2605:15)
    at compileModelCore (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:3074:17)
    at compileAndTest (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:4015:24)
    at Object.compileModelAndFullValidate (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/ml4f.js:3982:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async processModelFile (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/cli/cli.js:124:66)
    at async Object.mainCli (/Users/microbit-carlos/workspace/mbef/microbit-ml-adl/node_modules/ml4f/built/cli/cli.js:180:9)

tensorflow 3.9?

Looks like tensorflow updated and changed some data structures.

circular dep

rollup complains that

Circular dependency: ../../../node_modules/@tensorflow/tfjs-core/dist/environment.js -> ../../../node_modules/@tensorflow/tfjs-core/dist/log.js -> ../../../node_modules/@tensorflow/tfjs-core/dist/environment.js

Unable to run model through program

When creating tensorflow layers models like 'https://github.com/microbit-foundation/cctd-ml-machine/blob/main/src/script/mlmodels/LayersModelTrainer.ts' the program halts and does not give an error. The program halts at this point

const copy = await tf.loadLayersModel({ load: () => Promise.resolve(mod) })
. These are the models used to generate this error 'https://github.com/Dan4P/models-store'. They are saved using the code 'model.save(downloads://my-model)' and then placed into the models folder. The command used to run and get this error is 'ml4f models/my-model.json'.
Do you have any idea why this could be happening @mmoskal?

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.