Skip to content

Commit

Permalink
docs of model
Browse files Browse the repository at this point in the history
  • Loading branch information
dingguanglei committed Oct 29, 2018
1 parent ac4429c commit d70640d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
22 changes: 12 additions & 10 deletions jdit/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ class Model(object):
In the simplest case, we use a raw pytorch ``module`` to assemble a ``Model`` of this class.
It can be more convenient to use some feather method, such ``checkPoint`` , ``loadModel`` and so on.
* :attr:`proto_model` is the core model in this class. It is no necessary to passing a ``module``
when you init a ``Model`` . you can build a model later by using ``Model.define(module)`` or load a model from
a file.
* :attr:`proto_model` is the core model in this class. It is no necessary to passing a ``module``when you init a ``Model`` . you can build a model later by using ``Model.define(module)`` or load a model from a file.
* :attr:`gpu_ids_abs` controls the gpus which you want to use. you should use a absolute id of gpus.
* :attr:`init_method` controls the weights init method.
* At init_method="xavier", it will use ``init.xavier_normal_``, in ``pytorch.nn.init``, to init the Conv
layers of model.
* At init_method="kaiming", it will use ``init.kaiming_normal_``, in ``pytorch.nn.init``, to init the Conv
layers of model.
* At init_method=your_own_method, it will be used on weights, just like what ``pytorch.nn.init`` method does.
* At init_method="xavier", it will use ``init.xavier_normal_``,in ``pytorch.nn.init``, to init the Conv layers of model.
* At init_method="kaiming", it will use ``init.kaiming_normal_``,in ``pytorch.nn.init``, to init the Conv layers of model.
* At init_method=your_own_method, it will be used on weights,just like what ``pytorch.nn.init`` method does.
* :attr:`show_structure` controls whether to show your network structure.
Expand Down Expand Up @@ -84,7 +82,9 @@ def define(self, proto_model, gpu_ids, init_method, show_structure):
"""Define and wrap a pytorch module, according to CPU, GPU and multi-GPUs.
* Print the module's info.
* Move this module to specify device.
* Apply weight init method.
:param proto_model: Network, type of ``module``.
Expand Down Expand Up @@ -112,7 +112,7 @@ def print_network(self, net, show_structure=False):
return num_params

def loadModel(self, model_or_path, weights_or_path=None, gpu_ids=()):
r"""Assemble a model and weights from paths or passing parameters.
"""Assemble a model and weights from paths or passing parameters.
You can load a model from a file, passing parameters or both.
Expand Down Expand Up @@ -171,8 +171,10 @@ def loadModel(self, model_or_path, weights_or_path=None, gpu_ids=()):
self.model = self._set_device(model, gpu_ids)

def saveModel(self, model_path=None, weights_path=None, to_cpu=False):
r"""Save a model and weights to files.
"""Save a model and weights to files.
You can save a model, weights or both to file.
.. note::
This method deal well with different devices on model saving.
Expand Down
22 changes: 12 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
pip
mock
future
numpy
#pandas
psutil
torch
tqdm
pyyaml
mock
scipy
setuptools
six
typing
psutil


nvidia_ml_py3
sphinx_rtd_theme
pandas
torchvision
Pillow
imageio
scikit_learn
tensorboardX

0 comments on commit d70640d

Please sign in to comment.