Coder Social home page Coder Social logo

Comments (8)

YuriSizuku avatar YuriSizuku commented on September 17, 2024 1

Didn't really solve this but here is my research:

  • TF_NUM_OPS eventually will go here as tOpCount
  • I am not experienced enough to explain it fully but by reading this it seems to be the number of "operations" that you add later by e.g. doing: tf.resolver.AddFullyConnected(); or tf.resolver.AddSoftmax();

So, if you only add FullyConnected TF_NUM_OPS should be 1? I have the feeling this library here will be dropped anyways in favour of this one, which also uses the number of operations as argument....

Thank you for the information.
Is this the number of operations ? Is that means we needs to pre allocate memory before using each operation ?

from eloquenttinyml.

jakobkilian avatar jakobkilian commented on September 17, 2024

I would also be very interested in this. Unfortunately, I can't get my models to run with the update, but I don't know what should be entered there...
Thanks for the great work, Simone!

from eloquenttinyml.

jakobkilian avatar jakobkilian commented on September 17, 2024

Didn't really solve this but here is my research:

  • TF_NUM_OPS eventually will go here as tOpCount
  • I am not experienced enough to explain it fully but by reading this it seems to be the number of "operations" that you add later by e.g. doing: tf.resolver.AddFullyConnected(); or tf.resolver.AddSoftmax();

So, if you only add FullyConnected TF_NUM_OPS should be 1? I have the feeling this library here will be dropped anyways in favour of this one, which also uses the number of operations as argument....

from eloquenttinyml.

jakobkilian avatar jakobkilian commented on September 17, 2024

Just a short note as I understand some more things now and may be able to explain this partly:

There is a couple of possible operations in tflite. With TF_NUM_OPS in this library (and also in others) you just reserve memory to do these operations.

Example:
When using a quantized model (taking in float, quantizing it to an int, running the inference and dequantize it back to a float) you would need TF_NUM_OPS to be at least 3 because:

#define TF_NUM_OPS 3
#define ARENA_SIZE 2000
Eloquent::TF::Sequential<TF_NUM_OPS, ARENA_SIZE> tf;

void setup() {
    //stuff
    tf.resolver.AddFullyConnected();
    tf.resolver.AddQuantize();
    tf.resolver.AddDequantize();
}

with this you could load a quantized model like described here in the end

from eloquenttinyml.

YuriSizuku avatar YuriSizuku commented on September 17, 2024

Just a short note as I understand some more things now and may be able to explain this partly:

There is a couple of possible operations in tflite. With TF_NUM_OPS in this library (and also in others) you just reserve memory to do these operations.

Example: When using a quantized model (taking in float, quantizing it to an int, running the inference and dequantize it back to a float) you would need TF_NUM_OPS to be at least 3 because:

#define TF_NUM_OPS 3
#define ARENA_SIZE 2000
Eloquent::TF::Sequential<TF_NUM_OPS, ARENA_SIZE> tf;

void setup() {
    //stuff
    tf.resolver.AddFullyConnected();
    tf.resolver.AddQuantize();
    tf.resolver.AddDequantize();
}

with this you could load a quantized model like described here in the end

Thank you for your explanation. I wonder how do we know what operations are necessory for the model ?

from eloquenttinyml.

jakobkilian avatar jakobkilian commented on September 17, 2024

I also wonder why there seems to be no good docu about it.
If you train your model yourself, you can decide on its architecture and the operations you build in. When you have a tflite file and no knowledge you can use Netron to analyse the model. This is e.g. a tiny quantized tflite model I trained as a test. It has quantization built in as you can see in the screenshot and there is a correspinding AddFullyConnected in the mentioned list.
Still I don't fully understand this: this model runs for example even if you just add a single AddFullyConnected() and AddQuantize() only (not multiple fully connected and dequantize).

Netron App Screenshot

from eloquenttinyml.

YuriSizuku avatar YuriSizuku commented on September 17, 2024

I also wonder why there seems to be no good docu about it. If you train your model yourself, you can decide on its architecture and the operations you build in. When you have a tflite file and no knowledge you can use Netron to analyse the model. This is e.g. a tiny quantized tflite model I trained as a test. It has quantization built in as you can see in the screenshot and there is a correspinding AddFullyConnected in the mentioned list. Still I don't fully understand this: this model runs for example even if you just add a single AddFullyConnected() and AddQuantize() only (not multiple fully connected and dequantize).

Netron App Screenshot

I found a use way to summary the ops in a tflite model.
python -m tensorflow.lite.tools.visualize xxx.tflite

from eloquenttinyml.

YuriSizuku avatar YuriSizuku commented on September 17, 2024

I also wonder why there seems to be no good docu about it. If you train your model yourself, you can decide on its architecture and the operations you build in. When you have a tflite file and no knowledge you can use Netron to analyse the model. This is e.g. a tiny quantized tflite model I trained as a test. It has quantization built in as you can see in the screenshot and there is a correspinding AddFullyConnected in the mentioned list. Still I don't fully understand this: this model runs for example even if you just add a single AddFullyConnected() and AddQuantize() only (not multiple fully connected and dequantize).
Netron App Screenshot

Thank you for providing the information. I found a easy way to summary the ops in a tflite model. python -m tensorflow.lite.tools.visualize xxx.tflite

from eloquenttinyml.

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.