Code Monkey home page Code Monkey logo

gaze's Introduction

Gaze ๐Ÿ‘๐Ÿง 

Visualize PyTorch Models

Streaming:

Pull up a live visualization of model training or inference:

model = Model()
# Pass nn.Module and optimizer into the Gaze wrapper
gaze = Gaze(model.network, model.optimizer)

# Show how gradients are flowing through a layer during training
gaze.streamGradient("layer_name")

# Show how weights during training or inference
gaze.streamWeight("layer_name")

# Start using the model and Gaze will show you the weights and/or the gradients
if train:
  model.train()
elif test:
  model.test()

Checking:

You might only want to peer into the model under specific conditions. For this we have checking:

from gaze import Gaze

class Model:
  def __init__(self):
    self.network = Network(...) # nn.Module
    self.optimizer = optim.SomePyTorchOptimizer(...) 
    self.gaze = Gaze(self.network, self.optimizer)

  def train(epochs):
    for e in range(epochs):
      for i, data_batch in enumerate(data):
        self.optimizer.zero_grad()
        output = self.network(data_batch)
        loss = somePyTorchLoss(output, labels[i])

        # Only check weights and gradients when loss is lower than some threshold:
        if loss.item() < threshold:
          self.gaze.checkWeight("layer_name")
          self.gaze.checkGradient("layer_name")

        loss.backward()
        self.optimizer.step()

gaze's People

Contributors

iejmac avatar

Watchers

 avatar

gaze's Issues

version 0.2

TODO:

  • Establish nicer visualization, nice windows, 3d network? just layers? decide what we're going with
  • nicer interface, maybe in code for now but architect in such a way that allows users to access information through some sort of UI in the future
  • setup script

enhance the experience

version 0.1

TODO:

  • Support gradients
  • Individual calls placed throughout code : checkGradient() as opposed to streamGradient()

you should be able to get access to the gradients and the weights of the model at all times, easily.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.