dcslin edited a comment on issue #691:
URL: https://github.com/apache/singa/issues/691#issuecomment-629634540


   Quoted from @joddiy , `m=MyModel(path) # check the file is a model or just 
states`, this case, user know `MyModel` class, so just loading states right?
   
   
   From the perspective of a new onnx user, please let me know if this part is 
not correct.
   `singa_rep`: model like `singa.Module`
   `singa.save()/singa.load()`: save/load model w/o states
   `singa.Module.save_states()/load_states()`: save/load model states only
   
   ### Use case 1, load model from onnx file
   ```python
   class MySONNXModel(SONNXModel):
       pass # so we know the structure of model already?
   
   # load from onnx model
   onnx_model=onnx.load('./saved_models/onnx_model_downloaded')
   m1=MySONNXModel(onnx_model) # so we know the structure of model already?
   m1.compile([placeholder_x], ...)
   for _ in data:
       m1.train_one_batch(_)
   ```
   
   ### use case 2: save states and model
   ```python
   # save
   m1.save_states('./saved_models/my_checkpoint_1')
   singa.save('./saved_models/my_model_1', m1)
   ```
   
   ### use case 3 load model and states from disk
   ```python
   # Later reuse the model
   m2=singa.load('./saved_models/my_model_1')
   m2.load_states('./saved_models/my_checkpoint_1')
   m2.compile([placeholder_x], use_graph=True)
   ```
   
   ### use case 4 load states only
   ```python
   # singa model is known
   class MyModel(Module):
       pass
   
   m3=MyModel(states_path='./saved_models/my_checkpoint_1') # could only be 
states, right?
   # m3=MyModel('./saved_models/my_model_1') # could not be saved_model right? 
since we know the model
   m3.compile(...)
   ```
   
   To be frank, I am a bit overwhelmed by all the discussions not just in this 
issue, is it possible to consolidate the new API into a specification including 
example in singa-doc? Which is useful for new users? btw, is API in 
[onnx-doc](https://github.com/apache/singa-doc/blob/master/docs-site/docs/onnx.md)
 gonna change?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to