| Crates.io | ghostflow-data |
| lib.rs | ghostflow-data |
| version | 1.0.0 |
| created_at | 2026-01-03 11:20:40.853477+00 |
| updated_at | 2026-01-08 06:27:36.57558+00 |
| description | Data loading utilities for GhostFlow ML framework |
| homepage | https://github.com/choksi2212/ghost-flow |
| repository | https://github.com/choksi2212/ghost-flow |
| max_upload_size | |
| id | 2019930 |
| size | 69,498 |
Available in Python and Rust โข Hand-Optimized Kernels โข 85+ ML Algorithms โข Multi-Platform
pip install ghostflow # Python
cargo add ghost-flow # Rust
npm install ghostflow-wasm # JavaScript/WASM
Features โข Quick Start โข Examples โข Multi-Platform โข Documentation
GhostFlow is a complete machine learning framework built in Rust with Python bindings. It combines the performance of Rust with the convenience of Python, offering competitive performance and a rich set of ML algorithms.
๐งฎ Tensor Operations
|
๐ Neural Networks
|
๐ Automatic Differentiation
|
โก Optimizers
|
GhostFlow includes hand-optimized CUDA kernels that outperform standard libraries:
Enable GPU acceleration:
[dependencies]
ghostflow = { version = "0.1", features = ["cuda"] }
Requirements: NVIDIA GPU (Compute Capability 7.0+), CUDA Toolkit 11.0+
See CUDA_USAGE.md for detailed GPU setup and performance tips.
pip install ghost-flow
cargo add ghost-flow
import ghost_flow as gf
# Create a neural network
model = gf.nn.Sequential([
gf.nn.Linear(784, 128),
gf.nn.ReLU(),
gf.nn.Linear(128, 10)
])
# Create data
x = gf.Tensor.randn([32, 784]) # Batch of 32 images
y_true = gf.Tensor.randn([32, 10]) # Labels
# Forward pass
y_pred = model(x)
# Compute loss
loss = gf.nn.mse_loss(y_pred, y_true)
# Backward pass
loss.backward()
print(f"GhostFlow v{gf.__version__} - Loss: {loss.item():.4f}")
import ghost_flow as gf
# Model and optimizer
model = gf.nn.Linear(10, 1)
optimizer = gf.optim.Adam(model.parameters(), lr=0.01)
# Training
for epoch in range(100):
# Forward
x = gf.Tensor.randn([32, 10])
y_true = gf.Tensor.randn([32, 1])
y_pred = model(x)
# Loss
loss = ((y_pred - y_true) ** 2).mean()
# Backward
loss.backward()
optimizer.step()
optimizer.zero_grad()
if epoch % 10 == 0:
print(f"Epoch {epoch}: Loss = {loss.item():.4f}")
import ghost_flow as gf
# Random Forest
model = gf.ml.RandomForest(n_estimators=100, max_depth=5)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
accuracy = model.score(X_test, y_test)
print(f"Accuracy: {accuracy:.2%}")
use ghost_flow::prelude::*;
fn main() {
// Create tensors
let x = Tensor::randn(&[1000, 1000]);
let y = Tensor::randn(&[1000, 1000]);
// Matrix multiply (blazingly fast!)
let z = x.matmul(&y);
println!("Result shape: {:?}", z.shape());
}
use ghost_flow::prelude::*;
fn main() {
// Create model
let layer1 = Linear::new(784, 128);
let layer2 = Linear::new(128, 10);
// Forward pass
let x = Tensor::randn(&[32, 784]);
let h = layer1.forward(&x).relu();
let output = layer2.forward(&h);
// Compute loss
let target = Tensor::zeros(&[32, 10]);
let loss = output.mse_loss(&target);
// Backward pass
loss.backward();
println!("Loss: {}", loss.item());
}
GhostFlow is designed for performance with hand-optimized operations and efficient memory management.
GhostFlow aims to provide competitive performance with established frameworks:
Note: Performance varies by workload. For production use, always benchmark with your specific use case.
GhostFlow provides competitive performance for ML workloads. Performance varies by operation and hardware.
These are illustrative examples. Actual performance depends on your hardware, data size, and specific use case.
| Operation | Notes |
|---|---|
| Matrix Multiplication | SIMD-optimized for CPU, CUDA for GPU |
| Convolution | Supports im2col and direct convolution |
| Neural Network Training | Efficient autograd and memory management |
| Classical ML | Optimized decision trees, clustering, etc. |
Important: Always benchmark with your specific workload. Performance claims should be verified for your use case.
Benchmarks run on: Intel i9-12900K, NVIDIA RTX 4090, 32GB RAM
use ghostflow_nn::*;
use ghostflow_core::Tensor;
// Build a CNN for MNIST
let model = Sequential::new(vec![
Box::new(Conv2d::new(1, 32, 3, 1, 1)),
Box::new(ReLU),
Box::new(MaxPool2d::new(2, 2)),
Box::new(Conv2d::new(32, 64, 3, 1, 1)),
Box::new(ReLU),
Box::new(MaxPool2d::new(2, 2)),
Box::new(Flatten),
Box::new(Linear::new(64 * 7 * 7, 128)),
Box::new(ReLU),
Box::new(Linear::new(128, 10)),
]);
// Training loop
for epoch in 0..10 {
for (images, labels) in train_loader {
let output = model.forward(&images);
let loss = output.cross_entropy_loss(&labels);
optimizer.zero_grad();
loss.backward();
optimizer.step();
}
}
use ghostflow_ml::ensemble::RandomForestClassifier;
let mut rf = RandomForestClassifier::new(100) // 100 trees
.max_depth(10)
.min_samples_split(2)
.max_features(Some(4));
rf.fit(&x_train, &y_train);
let accuracy = rf.score(&x_test, &y_test);
println!("Accuracy: {:.2}%", accuracy * 100.0);
use ghostflow_ml::ensemble::GradientBoostingClassifier;
let mut gb = GradientBoostingClassifier::new()
.n_estimators(100)
.learning_rate(0.1)
.max_depth(3);
gb.fit(&x_train, &y_train);
let predictions = gb.predict_proba(&x_test);
use ghostflow_ml::cluster::KMeans;
let mut kmeans = KMeans::new(5) // 5 clusters
.max_iter(300)
.tol(1e-4);
kmeans.fit(&data);
let labels = kmeans.predict(&data);
let centers = kmeans.cluster_centers();
GhostFlow is organized into modular crates:
ghostflow/
โโโ ghostflow-core # Tensor operations, autograd, SIMD
โโโ ghostflow-nn # Neural network layers and losses
โโโ ghostflow-optim # Optimizers and schedulers
โโโ ghostflow-data # Data loading and preprocessing
โโโ ghostflow-autograd # Automatic differentiation engine
โโโ ghostflow-ml # 50+ ML algorithms
โโโ ghostflow-cuda # GPU acceleration (optional)
pip install ghost-flowcargo add ghost-flowGhostFlow has comprehensive test coverage:
cargo test --workspace
Test Results:
pip install ghostflow)See FUTURE_ROADMAP_2026_2027.md for detailed roadmap.
We welcome contributions! Whether it's:
Please see our Contributing Guide for details.
# Clone the repository
git clone https://github.com/choksi2212/ghost-flow.git
cd ghost-flow
# Build all crates
cargo build --workspace
# Run tests
cargo test --workspace
# Run benchmarks
cargo bench --workspace
GhostFlow is dual-licensed under:
You may choose either license for your use.
GhostFlow is inspired by:
Special thanks to the Rust community for building an amazing ecosystem!