UNPKG

stargrad

Version:

A JavaScript library for automatic gradient calculation, inspired by PyTorch

74 lines (49 loc) 1.65 kB
# StarGrad StarGrad is a powerful JavaScript library that provides automatic gradient calculation and mathematical tools, inspired by PyTorch's functionality. It's designed to make deep learning and mathematical computations more accessible to JavaScript developers. ## Features - Automatic gradient calculation - Tensor operations similar to PyTorch - Mathematical operations and functions - GPU acceleration support (coming soon) - TypeScript support ## Installation You can install StarGrad using npm: ```bash npm install stargrad ``` ## Quick Start Import StarGrad in your project: ```javascript import { Tensor } from 'stargrad'; // Create a tensor const x = new Tensor([1, 2, 3]); // Perform operations const y = x.mul(2); // Multiply by 2 const z = y.add(1); // Add 1 // Calculate gradients z.backward(); ``` ## Documentation ### Core Concepts - **Tensors**: The fundamental data structure in StarGrad - **Autograd**: Automatic gradient calculation system - **Operations**: Mathematical operations on tensors ### Basic Operations ```javascript // Create tensors const a = new Tensor([1, 2, 3]); const b = new Tensor([4, 5, 6]); // Basic arithmetic const sum = a.add(b); const product = a.mul(b); const quotient = a.div(b); // Matrix operations const matrix = new Tensor([[1, 2], [3, 4]]); const transpose = matrix.transpose(); ``` ## Contributing We welcome contributions! Please feel free to submit a Pull Request. ## License This project is licensed under the MIT License - see the LICENSE file for details. ## Support If you encounter any issues or have questions, please open an issue on our GitHub repository.