Git Product home page Git Product logo

micrograd-rs's Introduction

Building core Deep Learning algorithms in Rust.

It's kinda like the middle child of karpathy/micrograd and geohot/tinygrad.


Contributing

Any type of contribution is welcome as long as it adds value! i.e

  • Bug fixes followed with tests to ensure the bug never resurfaces
  • Increasing code readability, or run-time/memory efficiency
  • Completing a To-Do task

To-Do


Loading a model from Pytorch

We need the convert_state_dict() function to convert PyTorch tensors to lists because micrograd_rs can't unpickle PyTorch tensors. This conversion will allow micrograd_rs to load pytorch models without any issues.

# we need this import to serialize the model in a compatible format
import pickle

# changes PyTorch generated state dict to micrograd state dict
def convert_state_dict(state_dict):
    new_state_dict = {}
    for name, tensor in state_dict.items():
        new_state_dict[name] = tensor.float().flatten().tolist()
    return new_state_dict

new_state_dict = convert_state_dict(model.state_dict())

# stores new state dict
with open(path, "wb") as f:
    pickle.dump(new_state_dict, f)
// To load model in rust
model.load_state_dict(path);

micrograd-rs's People

Contributors

demba3 avatar jrego43 avatar lazarohurtado avatar pochetes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

micrograd-rs's Issues

bug: `Default` macro

error[E0658]: deriving `Default` on enums is experimental
  --> src/ops/mod.rs:15:10
   |
15 | #[derive(Default)]
   |          ^^^^^^^
   |
   = note: see issue #86985 <https://github.com/rust-lang/rust/issues/86985> for more information
   = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0658`.
error: could not compile `micrograd-rs` due to previous error

to reproduce this, just run cargo build.

not sure if this is a bug, but I'm not too experienced with the repo to be making these type of changes.

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.