Skip to main content

No project description provided

Project description

MicroTorch

MicroTorch is a minimal implementation of PyTorch , NumPy, TensorFlow, and other popular machine learning libraries. It is intended to be used as a learning tool for understanding the how is works neural networks ,autograd, and other machine learning concepts.

Installation

pip install microtorch

Usage

import microtorch as mt

# Create a tensor 1 dimension
x = mt.Tensor([1, 2, 3, 4, 5])

# Create a tensor 2 dimension
x = mt.Tensor([[1, 2, 3], [4, 5, 6]])

# Create a tensor 3 dimension
x = mt.Tensor([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])

# Create a tensor 4 dimension
x = mt.Tensor([[[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]], [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]])

# create a tensor with random values
x = mt.rand(2, 3)

# create a tensor with zeros
x = mt.zeros(2, 3)

# create a tensor with ones
x = mt.ones(2, 3)

# create a tensor with a range
x = mt.arange(0, 10)

# create a tensor with a range and step
x = mt.arange(0, 10, 2)

# create a tensor with a range and step
x = mt.arange(0, 10, 2)

# create a tensor with a range and step
x = mt.arange(0, 10, 2)

# create neural network
model = mt.Sequential(
    mt.Linear(2, 5),
    mt.ReLU(),
    mt.Linear(5, 1),
    mt.Sigmoid()
)

# create loss function
loss_fn = mt.MSELoss()

# create optimizer

optimizer = mt.SGD(model.parameters(), lr=0.01)

# train model

for epoch in range(100):
    # forward
    y_pred = model(x)

    # compute loss
    loss = loss_fn(y_pred, y)

    # zero gradients
    optimizer.zero_grad()

    # backward
    loss.backward()

    # update weights
    optimizer.step()

License

MIT

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

microtorch-0.1.1.tar.gz (1.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microtorch-0.1.1-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file microtorch-0.1.1.tar.gz.

File metadata

  • Download URL: microtorch-0.1.1.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-76-generic

File hashes

Hashes for microtorch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 679db34c5760d0282276286be47cc6311d92b2480c568436ce5665cc407e52f8
MD5 b251621b4502d58202cf9cfb07d934aa
BLAKE2b-256 589dd4d6450de22834fa90ab1f3a1bc8541b8c4861fb3ae1ae9e7e7ca390fc8d

See more details on using hashes here.

File details

Details for the file microtorch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: microtorch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-76-generic

File hashes

Hashes for microtorch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1d2b7749a956fb3867afbb91bcc7c75a28fef1eb2f1c927681d889e4d81c3ea6
MD5 fe54deb2a7070ed216c07553fe9711f0
BLAKE2b-256 6037ec4ae5de943ed349386ac8a0128ce6f9bebbc3d44e4129d6b1a716d24336

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page