All Projects β†’ julvo β†’ Reloading

julvo / Reloading

Licence: mit
Change Python code while it's running without losing state

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Reloading

Bash Lib
Library for bash utility methods and tools
Stars: ✭ 546 (-24.48%)
Mutual labels:  utility
Ugrep
πŸ”NEW ugrep v3.1: ultra fast grep with interactive query UI and fuzzy search: search file systems, source code, text, binary files, archives (cpio/tar/pax/zip), compressed files (gz/Z/bz2/lzma/xz/lz4), documents and more. A faster, user-friendly and compatible grep replacement.
Stars: ✭ 626 (-13.42%)
Mutual labels:  interactive
Oji
(β—•β€Ώβ—•) Text Emoticons Maker
Stars: ✭ 668 (-7.61%)
Mutual labels:  interactive
Datatable
A simple, modern and interactive datatable library for the web
Stars: ✭ 587 (-18.81%)
Mutual labels:  interactive
Cabin
🌲 Cabin is the best JavaScript and Node.js logging service and logging npm package
Stars: ✭ 622 (-13.97%)
Mutual labels:  utility
Bit
Bit is a modern Git CLI
Stars: ✭ 5,723 (+691.56%)
Mutual labels:  interactive
Saws
A supercharged AWS command line interface (CLI).
Stars: ✭ 4,886 (+575.8%)
Mutual labels:  utility
Embedmd
embedmd: embed code into markdown and keep everything in sync
Stars: ✭ 714 (-1.24%)
Mutual labels:  utility
Minic Hosting
A simple stack-based virtual machine that runs C in the browser.
Stars: ✭ 628 (-13.14%)
Mutual labels:  interactive
Thor
Switch the right application ASAP.
Stars: ✭ 660 (-8.71%)
Mutual labels:  utility
Iruby
Official gem repository: Ruby kernel for Jupyter/IPython Notebook
Stars: ✭ 600 (-17.01%)
Mutual labels:  interactive
Search Deflector
A small program that forwards searches from Cortana to your preferred browser and search engine.
Stars: ✭ 620 (-14.25%)
Mutual labels:  utility
Heatmap.js
πŸ”₯ JavaScript Library for HTML5 canvas based heatmaps
Stars: ✭ 5,685 (+686.31%)
Mutual labels:  interactive
Vue Interactive Paycard
Credit card form with smooth and sweet micro-interactions
Stars: ✭ 5,451 (+653.94%)
Mutual labels:  interactive
Backslide
πŸ’¦ CLI tool for making HTML presentations with Remark.js using Markdown
Stars: ✭ 679 (-6.09%)
Mutual labels:  utility
Dozer
Hide menu bar icons on macOS
Stars: ✭ 5,655 (+682.16%)
Mutual labels:  utility
Vorpal
Node's framework for interactive CLIs
Stars: ✭ 5,489 (+659.2%)
Mutual labels:  interactive
Quicktile
Adds window-tiling hotkeys to any X11 desktop. (An analogue to WinSplit Revolution for people who don't want to use Compiz Grid)
Stars: ✭ 719 (-0.55%)
Mutual labels:  utility
Goto
Alias and navigate to directories with tab completion in Linux
Stars: ✭ 698 (-3.46%)
Mutual labels:  utility
Basscss
Low-level CSS Toolkit – the original Functional/Utility/Atomic CSS library
Stars: ✭ 5,669 (+684.09%)
Mutual labels:  utility

reloading

pypi badge

A Python utility to reload a loop body from source on each iteration without losing state

Useful for editing source code during training of deep learning models. This lets you e.g. add logging, print statistics or save the model without restarting the training and, therefore, without losing the training progress.

Demo

Install

pip install reloading

Usage

To reload the body of a for loop from source before each iteration, simply wrap the iterator with reloading, e.g.

from reloading import reloading

for i in reloading(range(10)):
    # here could be your training loop
    print(i)

To reload a function from source before each execution, decorate the function definition with @reloading, e.g.

from reloading import reloading

@reloading
def some_function():
    pass

Examples

Here are the short snippets of how to use reloading with your favourite library. For complete examples, check out the examples folder.

PyTorch

for epoch in reloading(range(NB_EPOCHS)):
    # the code inside this outer loop will be reloaded before each epoch

    for images, targets in dataloader:
        optimiser.zero_grad()
        predictions = model(images)
        loss = F.cross_entropy(predictions, targets)
        loss.backward()
        optimiser.step()

Here is a full PyTorch example.

fastai

@reloading
def update_learner(learner):
    # this function will be reloaded from source before each epoch so that you
    # can make changes to the learner while the training is running
    pass

class LearnerUpdater(LearnerCallback):
    def on_epoch_begin(self, **kwargs):
        update_learner(self.learn)

path = untar_data(URLs.MNIST_SAMPLE)
data = ImageDataBunch.from_folder(path)
learn = cnn_learner(data, models.resnet18, metrics=accuracy, 
                    callback_fns=[LearnerUpdater])
learn.fit(10)

Here is a full fastai example.

Keras

@reloading
def update_model(model):
    # this function will be reloaded from source before each epoch so that you
    # can make changes to the model while the training is running using
    # K.set_value()
    pass

class ModelUpdater(Callback):
    def on_epoch_begin(self, epoch, logs=None):
        update_model(self.model)

model = Sequential()
model.add(Dense(64, activation='relu', input_dim=20))
model.add(Dense(10, activation='softmax'))

sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='categorical_crossentropy',
              optimizer=sgd,
              metrics=['accuracy'])

model.fit(x_train, y_train,
          epochs=200,
          batch_size=128,
          callbacks=[ModelUpdater()])

Here is a full Keras example.

TensorFlow

for epoch in reloading(range(NB_EPOCHS)):
    # the code inside this outer loop will be reloaded from source
    # before each epoch so that you can change it during training
  
    train_loss.reset_states()
    train_accuracy.reset_states()
    test_loss.reset_states()
    test_accuracy.reset_states()
  
    for images, labels in tqdm(train_ds):
      train_step(images, labels)
  
    for test_images, test_labels in tqdm(test_ds):
      test_step(test_images, test_labels)

Here is a full TensorFlow example.

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].