类似 PyTorch 的 JavaScript 张量与自动微分库。构建、训练、运行神经网络 —— 无需 Python。 A PyTorch-like tensor and autograd library for JavaScript. Build, train, and run neural networks — no Python required.
npm install estorch神经网络训练所需的一切,开箱即用。 Everything you need for neural network training, in the browser or Node.js.
基于计算图的自动微分。调用 backward(),梯度自动流过所有运算 —— 和 PyTorch 一样。
Automatic differentiation with a computation graph. Call backward() and gradients flow through your operations — just like PyTorch.
内置 Linear、Conv2d、AvgPool2d、CrossEntropyLoss,以及提供 parameters() 和 stateDict() 的 Module 基类。
Built-in Linear, Conv2d, AvgPool2d, CrossEntropyLoss, and a Module base class with parameters() and stateDict().
纯 JavaScript 实现,无任何外部依赖。只需 npm install estorch 即可开始训练。轻量且便携。
Pure JavaScript with no external packages. Just npm install estorch and you're ready to train. Lightweight and portable.
如果你会 PyTorch,你就已经会 EsTorch。相同的类名、相同的方法签名、相同的训练循环模式。 If you know PyTorch, you already know EsTorch. Same class names, same method signatures, same training loop pattern.
内置 DataLoader,支持异步迭代器、批处理、随机打乱,以及开箱即用的 MNIST 数据集辅助工具。
Built-in DataLoader with async iterators, batch support, shuffling, and ready-to-use MNIST dataset helpers.
Adam 优化器,支持配置学习率、beta 参数和 epsilon。StepLR 调度器用于训练过程中的学习率衰减。 Adam optimizer with configurable learning rate, betas, and epsilon. StepLR scheduler for learning rate decay during training.
你熟悉的训练循环模式。 A familiar training loop you'll feel right at home with.
// 用约 10 行代码训练神经网络// Train a neural network in ~10 lines const torch = require('estorch'); const model = new SimpleNet(); const criterion = new torch.nn.CrossEntropyLoss(); const optimizer = new torch.optim.Adam(model.parameters(), { lr: 0.001 }); for await (const [images, labels] of trainLoader) { optimizer.zeroGrad(); const outputs = model.forward(images); const loss = criterion.forward(outputs, labels); loss.backward(); optimizer.step(); }
熟悉的模块结构,灵感来自 PyTorch。 Familiar module structure, inspired by PyTorch.
今天就开始用 JavaScript 训练神经网络。 Start training neural networks in JavaScript today.