Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
dingguanglei committed Oct 26, 2018
1 parent ac27f20 commit 7bb969b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
59 changes: 58 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,64 @@ Welcome to jdit's documentation!
model
optimizer
trainer
metric



**Jdit** is a research processing oriented framework based on pytorch. Only care about your ideas.
You don't need to build a long boring code to run a deep learning project to verify your ideas.

You only need to implement you ideas and
don't do anything with training framework, multiply-gpus, checkpoint, process visualization, performance evaluation and so on.

Quick start
-----------
After building and installing jdit package, you can make a new directory for a quick test.
Assuming that you get a new directory `example`.
run this code in `ipython` cmd.(Create a `main.py` file is also acceptable.)

.. code:: python
from jdit.trainer.instances.fashingClassification
import start_example
start_example()
Then you will see something like this as following.

.. code:: python
===> Build dataset
use 8 thread!
Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-images-idx3-ubyte.gz
Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/train-labels-idx1-ubyte.gz
Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-images-idx3-ubyte.gz
Downloading http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/t10k-labels-idx1-ubyte.gz
Processing...
Done!
===> Building model
ResNet Total number of parameters: 2776522
ResNet model use CPU!
apply kaiming weight init!
===> Building optimizer
===> Training
using `tensorboard --logdir=log` to see learning curves and net structure.
training and valid data, configures info and checkpoint were save in `log` directory.
0%| | 0/10 [00:00<?, ?epoch/s]
0step [00:00, ?step/s]
* It will search a fashing mnist dataset.
* Then build a resnet18 for classification.
* For training process, you can find learning curves in `tensorboard`.
* It will create a `log` directory in `example/`, which saves training processing data and configures.

Although it is just an example, you still can build your own project easily by using jdit framework.
Jdit framework can deal with
* Data visualization. (learning curves, images in pilot process)
* CPU, GPU or GPUs. (Training your model on specify devices)
* Intermediate data storage. (Saving training data into a csv file)
* Model checkpoint automatically.
* Flexible templates can be used to integrate and custom overrides.
So, let's see what is **jdit**.


Indices and tables
==================
Expand Down
6 changes: 6 additions & 0 deletions docs/source/trainer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ SupTrainer
.. autoclass:: SupTrainer
:members:

ClassificationTrainer
-------------------

.. autoclass:: ClassificationTrainer
:members:

GanTrainer
----------

Expand Down
7 changes: 3 additions & 4 deletions jdit/trainer/classification.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# import torch
# from torch.autograd import Variable
from torch.nn import CrossEntropyLoss
from .super import *
from abc import abstractmethod
from tqdm import *


class ClassificationTrainer(SupTrainer):
num_class = None
"""this is a classification trainer.
"""
num_class = None
def __init__(self, logdir, nepochs, gpu_ids, net, opt, datasets):
super(ClassificationTrainer, self).__init__(nepochs, logdir, gpu_ids_abs=gpu_ids)
self.net = net
Expand Down
7 changes: 7 additions & 0 deletions jdit/trainer/instances/fashingClassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@


class FashingClassTrainer(ClassificationTrainer):
"""this is an instance of how to use `ClassificationTrainer` to build your own trainer
"""
mode = "L"
num_class = 10
every_epoch_checkpoint = 20 # 2
Expand Down Expand Up @@ -55,6 +58,10 @@ def compute_valid(self):


def start_example():
""" run this to test a `FashingClassTrainer` instance
:return:
"""
gpus = [0]
batchSize = 64
nepochs = 10
Expand Down
12 changes: 12 additions & 0 deletions jdit/trainer/super.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@


class SupTrainer(object):
"""this is a super class of all trainers
"""
every_epoch_checkpoint = 10
every_epoch_changelr = 0
mode = "L"
Expand Down Expand Up @@ -112,6 +115,9 @@ def configure(self):


class Loger(object):
"""this is a log recorder.
"""
def __init__(self, logdir="log"):
self.logdir = logdir
self.regist_list = []
Expand Down Expand Up @@ -183,6 +189,9 @@ def clear_regist(self):


class Watcher(object):
"""this is a params and images watcher
"""
def __init__(self, logdir, mode="L"):
self.logdir = logdir
self.writer = SummaryWriter(log_dir=logdir)
Expand Down Expand Up @@ -280,6 +289,9 @@ def _buildDir(self, dirs):


class Performance(object):
"""this is a performance watcher.
"""

def __init__(self, gpu_ids_abs=()):
self.config_dic = dict()
Expand Down

0 comments on commit 7bb969b

Please sign in to comment.