Fair warning, the Glow team is pretty focused on inference right now, so you’ll likely encounter some rough edges in training. Keep in mind Glow currently has no way to save training results, so you’re limited to training and performing inference in a single process. To answer your questions, though:
- In the example/mnist.cpp, I found the code use same data to train and infer, is that right?
Yes, that’s currently what it’s doing. There’s no reason for it though; you could easily separate the data into train and test sets.
- How do I specify a loss function before training? How do I know how many steps I should train before success?
You’ll need to specify the loss function as part of the graph (e.g. Softmax, CrossEntryopyLoss, etc.).
- I can load a modle from caffee2 or onnx and use it to infer, But if I want to load a net from caffee2 or onnx and use it to train, what should I do? Should I modify the code of " image-iclassifier" to support train mode?
So, we’ve never actually tried training from a c2 or onnx model. In theory one could make it work but I’m not sure the loader knows how to create a graph for training. (Specifically, I think it might make all the weights constant). You can give this a shot by modifying image-classifier but I’d be very surprised if it works out-of-the-box.