Skip to content

XpressAI/xai-pytorch

Repository files navigation

Component LibrariesProject Templates
DocsInstallTutorialsDeveloper GuidesContributeBlogDiscord

Xircuits Component Library for integrating PyTorch! Build and deploy machine learning models with ease.

Xircuits Component Library for PyTorch

This library integrates PyTorch into Xircuits workflows, providing tools for seamless model development, training, and general PyTorch operations. It streamlines complex machine learning tasks with modular components.

Table of Contents

Preview

PytorchTrainModel Example

PytorchTrainModel

PytorchTrainModel Result

PytorchTrainModel result

PytorchPredictFromModel Example

PytorchPredictFromModel

PytorchPredictFromModel Result

PytorchPredictFromModel result

PytorchTrainCustomNN Example

PytorchTrainCustomNN

PytorchTrainCustomNN Result

PytorchTrainCustomNN result

Prerequisites

Before you begin, you will need the following:

  1. Python3.9+.
  2. Xircuits.

Main Xircuits Components

TorchModel Component:

Defines a custom PyTorch model with optional flattening and a configurable optimizer and loss function for training.

TorchModel

TorchAddLinearLayer Component:

Adds a Linear Layer to a sequential model with specified input and output features.

TorchAddLinearLayer

TorchAddConv1DLayer Component:

Adds a 1D convolutional layer with configurable kernel size, stride, padding, and other parameters.

TorchAddConv1DLayer

TorchAddTransformerEncoderLayer Component:

Inserts a Transformer Encoder layer with multi-head attention and configurable feedforward dimensions and activation.

TorchAddTransformerDecoderLayer Component:

Adds a Transformer Decoder layer with attention mechanisms and flexible feedforward configurations.

TorchLSTM Component:

Creates an LSTM layer for sequence modeling, supporting options for bidirectionality, dropout, and projection.

TorchAddReluLayer Component:

Adds a ReLU activation layer to a model, applying non-linearity to enhance model learning.

TorchAddDropoutLayer Component:

Incorporates a Dropout layer to reduce overfitting by randomly zeroing out input elements during training.

Try the Examples

We have provided an example workflow to help you get started with the PyTorch component library. Give it a try and see how you can create custom PyTorch components for your applications.

PytorchTrainModel

This workflow automates PyTorch model training by connecting modular components for data loading, training, testing, and saving. It simplifies complex training pipelines, reduces boilerplate code, and ensures reusability across projects.

PytorchPredictFromModel

This workflow demonstrates a PyTorch-based prediction pipeline. It automates the process of loading a saved model, preprocessing an input image into a tensor, and predicting the image's class using predefined labels.

PytorchTrainCustomNN

This workflow demonstrates training a custom neural network using PyTorch components, allowing flexible layer and parameter configurations.

Installation

To use this component library, ensure that you have an existing Xircuits setup. You can then install the PyTorch library using the component library interface, or through the CLI using:

xircuits install pytorch
# base Xircuits directory
git clone https://github.com/XpressAI/xai-pytorch xai_components/xai_pytorch
pip install -r xai_components/xai_pytorch/requirements.txt 

About

Xircuits component library for Pytorch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages