Changing Batch SIze
See original GitHub issueI have an onnx model. I just want to change the batch size of the model.
I have attached an image of a single node of the graph. The first one shows batch size = 1 and the second one shows batch size = 4. How to make this change using python code ??

Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Effect of batch size on training dynamics | by Kevin Shen
It has been empirically observed that smaller batch sizes not only has faster training dynamics but also generalization to the test dataset ...
Read more >gradient descent - Changing the batch size during training
On one hand, smaller batch sizes make the gradient descent more stochastic, the SGD can deviate significantly from the exact GD on the...
Read more >How to Control the Stability of Training Neural Networks With ...
Batch size controls the accuracy of the estimate of the error gradient when training neural networks. Batch, Stochastic, and Minibatch gradient ...
Read more >How to change the batch size during training? - Stack Overflow
For most purposes the accepted answer is the best, don't change the batch size. There's probably a better ...
Read more >Changing batch sizes | Python - DataCamp
Changing batch sizes ... You've seen models are usually trained in batches of a fixed size. The smaller a batch size, the more...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi,
You can change the batch-size as below. Note that you can also make the batch-size symbolic (e.g, “N”) to indicate an unknown value … then you don’t need to keep changing it for every different batch-size.
The scripts above did not work for me for the MNIST model (need to change graph.output, graph.value_info and reshape nodes). After more scrutiny I found this post so I implemented a Python script that works for MNIST:
googlenet-7.onnx inception-v2-7.onnx mnist-8.onnx resnet152-v1-7.onnx resnet50-v1-7.onnx squeezenet1.0-7.onnx vgg16-7.onnxfrom the onnx models repo.