All Projects → louis-she → minetorch

louis-she / minetorch

Licence: MIT License
Build deep learning applications in a new and easy way.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to minetorch

Aoe
AoE (AI on Edge,终端智能,边缘计算) 是一个终端侧AI集成运行时环境 (IRE),帮助开发者提升效率。
Stars: ✭ 759 (+383.44%)
Mutual labels:  tools, mnist
Eurge
Eurge js 脚本代码
Stars: ✭ 14 (-91.08%)
Mutual labels:  tools
whatdevsneed
Discover new developer tools 🧰
Stars: ✭ 48 (-69.43%)
Mutual labels:  tools
Online-Tools
Webpage offering a wide range of online tools
Stars: ✭ 38 (-75.8%)
Mutual labels:  tools
ml4se
A curated list of papers, theses, datasets, and tools related to the application of Machine Learning for Software Engineering
Stars: ✭ 46 (-70.7%)
Mutual labels:  tools
vistir
Setup / utilities which most projects eventually need
Stars: ✭ 30 (-80.89%)
Mutual labels:  tools
xiv-resources
A list of websites and tools for FFXIV.
Stars: ✭ 117 (-25.48%)
Mutual labels:  tools
awesome
my personal collection of awesome projects, links, books.
Stars: ✭ 16 (-89.81%)
Mutual labels:  tools
solidus dev support
A collection of tools for developing Solidus extensions.
Stars: ✭ 14 (-91.08%)
Mutual labels:  tools
MNIST-invert-color
Invert the color of MNIST images with PyTorch
Stars: ✭ 13 (-91.72%)
Mutual labels:  mnist
JMadOnion
No description or website provided.
Stars: ✭ 14 (-91.08%)
Mutual labels:  tools
DST-CBC
Implementation of our paper "DMT: Dynamic Mutual Training for Semi-Supervised Learning"
Stars: ✭ 98 (-37.58%)
Mutual labels:  tensorboard
remarkable-uuuflash
uuu scripts for recovery console and flashing
Stars: ✭ 31 (-80.25%)
Mutual labels:  tools
ignite-reactjs
Projetos desenvolvidos em ReactJS durante a trilha de ReactJS do Ignite da Rocketseat. 💜🚀
Stars: ✭ 20 (-87.26%)
Mutual labels:  ignite
apim-cli
Axway API-Management CLI - Manage your platform from the command line or with your CI/CD pipeline
Stars: ✭ 25 (-84.08%)
Mutual labels:  tools
fireman
Tame your Firebase databases
Stars: ✭ 36 (-77.07%)
Mutual labels:  tools
share-it
share-it-nine.vercel.app
Stars: ✭ 19 (-87.9%)
Mutual labels:  tools
lobe
Lobe is the world's first AI paralegal.
Stars: ✭ 22 (-85.99%)
Mutual labels:  tools
redis-inventory
CLI tool to see redis memory usage by keys in hierarchical way. Think of disk inventory but for redis.
Stars: ✭ 163 (+3.82%)
Mutual labels:  tools
Awesome-Deepfakes-Detection
A list of tools, papers and code related to Deepfake Detection.
Stars: ✭ 30 (-80.89%)
Mutual labels:  tools

Minetorch

In Minecraft, torches are very important for mining. No one can get all the diamonds without a torch. So is data-mining, A special torch named PyTorch can help us get the diamonds in data. Minetorch is a tools collection for miners, to use PyTorch in a more convenient way.

Features

  • Logging of course.
  • Play with Google Sheets.
  • Visualization. built-in with Tensorboard or Matplotlib.
  • Resumption. Default will resume from the last checkpoint.
  • Many hook points.
  • Training code. Or actually a namespace, used to easily sperate different training status.

Installation

pip install minetorch

Minetorch X Google Sheets

Minetorch can easily work with Google Sheets. To step up, you should have a Google account and, if you are in China, a proxy.

This is the demo sheet that produced with Minetorch training on MNIST dataset.

Enable Google API

  1. Sign in to https://console.developers.google.com with your Google account
  2. Create a new Project
  3. In the API Libarary, search drive and sheet, and enable them both. During this, Google should have alert you about creating the service account. If you have get the right credential file, ignore step 4.
  4. Create a Google Service Account in at https://console.developers.google.com/iam-admin/iam .

After all these steps you should get a json credential file which looks like this:

{
  "type": "xxxxxx",
  "project_id": "xxxxxx",
  "private_key_id": "xxxxxx",
  "private_key": "-----BEGIN PRIVATE KEY-----\n .......... \n-----END PRIVATE KEY-----\n",
  "client_email": "[email protected]",
  "client_id": "xxxxxxxxxxxxxxxxxxxxx",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.iam.gserviceaccount.com"
}

Create the spreadsheet

  1. At http://drive.google.com/, create a new spreadsheet.
  2. Share that spreadsheet with your service account, you can find your service account email address in your credential file.
  3. Get the id of the spreadsheet, it's right in the middle of the URL.

Ready to go

In your code, just create a minetorch.spreadsheet.GoogleSheet instance and pass it to Miner.

miner = Miner(
    # ...
    sheet=GoogleSheet('Your sheet id', 'path-of-your-google-service-account-credensial-file.json')
    # ...
)

miner.train()

and that's it, your spreadsheet should be automatically updated when you start your training process.

Minetorch update the sheet in async way, so it will not slow down the training speed.

Quick Start

  1. Clone this repo
git clone [email protected]:louis-she/minetorch.git
  1. Goto examples and execute
python mnist.py

The mnist.py is pretty much like PyTorch official mnist example https://github.com/pytorch/examples/blob/master/mnist/main.py, with some minor changes to be adapted to Minetorch.

This will create an alchemistic_directory and data directory in the working directory.

  1. Execute tensorboard to visualize
tensorboard ./log

or if you used matplotlib as the drawer, there would be 2 images under the path ${alchemistic_directory}/${code}/graph named loss.png and accuracy.png

loss.png accuracy.png

Note: Since PyTorch 1.0 comes with CUDA10 but the newest version of Tensorboard just supported CUDA9, so if you are using Tensorboard as a drawer, make sure you got CUDA9 installed, or it's better to use matplotlib. Due to this, Minetorch default drawer has changed to matplotlib instead of Tensorboard.

  1. Now let's change the loss function to cross_entropy(just follow some instructions in the comments of mnist.py), and train the mnist again.

How it works

Minetorch lets users focusing on the only necessary things, and will take care of the others. It's more like a skeleton and users should provide necessary components to make it work.

The parameters users must provide:

parameters type description
alchemistic_directory string path of a directory, all the checkpoint, log or graph will be saved in this alchemistic_directory
train_dataloader torch.utils.data.DataLoader Used to tell minetorch how to load training data
model torch.nn.Module PyTorch's nn.Module
loss_func callable A special hook function, should receive 2 arguments: data which yields by the loader and trainer which is the trainer instance, this function should return a single scalar which is the loss

And that's it, minetorch will take care of other things like logging, resuming, visualization etc... The names of the components are actually the parameters of the Trainer class. The other optional parameters are:

parameters type description
val_dataloader torch.utils.data.DataLoader Used to tell minetorch how to load validation data
resume bool or string Defaults to True, means the minetorch will try to resume from the latest checkpoint. If a string is given then minetorch will resume from a specified checkpoint, the string could be number of epoch, name of the checkpoint file or absolute path of the checkpoint file, false means train from scratch
eval_stride int Defaults to 1, how many epochs to run a validation process
persist_stride int Defaults to 1, how many epochs to save a checkpoint
drawer minetorch.Drawer or string Defaults to 'matplotlib'. To generate graphs of the whole training process, now support 'tensorboard' and 'matplotlib', can also write a customized Drawer by yourself
code string it's actually a subdirectory path of alchemistic_directory, for separating the results of different attempts, every attempt should have a unique name
hooks dict Defining hook function, see Hooks
max_epochs int How many epochs to train, defaults to None, means unlimited
logging_format string Defaults to '%(levelname)s %(asctime)s %(message)s', same as logging's format
trivial bool Defaults to False, if set to True, both training and validation process will be broken in 10 iterations, useful at development stage
in_notebook bool Defaults to False, if use minetorch in jupyter notebook environment, set this option to True to have a better output
statable dict Defaults to {}. A statble is an object which has implemented state_dict and load_state_dict, pass these objects in statable dict will let minetorch handle the load and save operation on it. For instance, Learning Rate Schedular is a typical statable object. Don't put optimizer and model here, minetorch already know that they are statble.

Hooks

Minetorch provided many hook points for users to control the training behaviors. All the hook functions receive current trainer instance as the arguments so the hook function can access all the functions and status of Trainer.

hook points description
after_init called after the construct function of Trainer been called
before_epoch_start called before every epoch started
after_epoch_end called after every epoch ended
before_train_iteration_start called before every training iteration started
after_train_iteration_end called after every training iteration ended
before_val_iteration_start called before every validation iteration started
after_val_iteration_end called after every validation iteration ended
before_checkpoint_persisted called before checkpoint persisted
after_checkpoint_persisted called after checkpoint persisted
before_quit called before the max_epochs exceeded and about to quit training

TODOs

  • More hook points.
  • Number of x-axis of Drawer generated images are not changed after resuming from a checkpoint.
  • Drawer DB Adapter. To persist drawer data to DB and then can be visualization by any tools.
  • Graceful exists.
  • Dockerize.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].