chrishkchris edited a comment on issue #651: [WIP ]Simply example APIs URL: https://github.com/apache/singa/pull/651#issuecomment-609049842 > I suggest to merge the examples under `examples/autograd` into the follow structure. > > ``` > autograd > train.py > train_mpi.py > train_multiprocess.py > data # define the data loading and preprocessing > cifar10.py > mnist.py > model # define the model > cnn.py > resnet.py > xception.py > ``` > > The pseudo code of each file: > > ```python > # train.py > def run(max_epoch, worker_id, num_workers, model, data, sgd): > if model == 'resnet': > from model import resnet > model = resnet.create_model() > elif model == 'cnn': > model = cnn.create_model() > .... > if data == 'cifar10': > from data import cifar10: > train_x, train_y, val_x, val_y = cifar10.load() > elif data == 'mnist': > .... > > train_x, train_y, val_x, val_y = partition(worker_id, num_workers, train_x, train_y, val_x, val_y) > > # bp and sgd > > if __name__ == '__main__': > # use argparse to get command config: max_epoch, model, data, etc. for single gpu training > sgd = # create sgd > run(0, 1, ..., sgd) > > # train_mpi.py > if __name__ == '__main__': > # use argparse to get command args: max_epoch, model, data, etc. for multi-gpu training > sgd = # create sgd > dist_sgd = DistOpt(sgd...) > run(dist_sgd.rank, dist_sgd.world_size, ... dist_sgd) > > # train_multiprocess.py > def run(rank, num_gpu, ...): > sgd = ... > dist_sgd = DistOpt(sgd) > train.run(rank, num_gpu, ... dist_sgd) > > if __name__ == '__main__': > # use argparse to get command args: max_epoch, model, data, etc. for multi-gpu training > nccl_id = ... > process = [] > for worker_id in range(0, gpu_per_node): > process.append(multiprocessing.Process(target=run, args=(worker_id, ... nccl_id))) > > for p in process: > p.start() > ``` thanks! I will work on it. Since seems a lot of work, to speed up may need Rulin to help Seems the graph module cnn_module.py and resnet_module.py is not included, not sure how to include the graph module
---------------------------------------------------------------- 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] With regards, Apache Git Services
