← all repositories
jedld/tensor_stream

TensorFlow, but make it Ruby — and actually standalone

A from-scratch reimplementation of TensorFlow's dataflow graph model that runs where Ruby runs, with optional OpenCL acceleration when you need it.

506 stars Ruby ML Frameworks
tensor_stream
Velocity · 7d
+0.2
★ / day
Trend
steady
star history

What it does

TensorStream lets you build and run machine learning models using Ruby syntax and TensorFlow-like dataflow graphs. It ships with two backends: a pure-Ruby evaluator that works across MRI, JRuby, and TruffleRuby, and an optional OpenCL evaluator for GPU/CPU acceleration on supported hardware. You can train on OpenCL, then deploy the trained model on plain Ruby.

The interesting bit

The project isn’t a wrapper around Python TensorFlow — it’s a ground-up reimplementation of the graph model, auto-differentiation, and core ops (tf.add, tf.matmul, placeholders, variables, etc.) in Ruby itself. The .t method on integers, floats, and arrays to cast them into tensors is a nice Ruby-ish touch.

Key highlights

  • Pure Ruby backend runs on MRI, JRuby, and TruffleRuby; OpenCL backend requires MRI only
  • Supports auto-differentiation via formal derivation, with optimizers including Adam, RMSProp, Adagrad, and momentum variants
  • Experimental import/export of TensorFlow pbtext files for model portability
  • Includes GraphML visualization output (yED-compatible) since TensorBoard isn’t supported
  • OpenCL kernels are generic and work across Intel, AMD, and Nvidia hardware

Caveats

  • OpenCL is basically required for deep learning or image tasks; the README bluntly states pure Ruby is “too slow even with JIT speedups”
  • Scalar-only workloads (like the included linear regression sample) actually run slower on OpenCL due to overhead
  • TensorBoard not supported; visualization is limited to GraphML dumps
  • “Not all ops are available” — compatibility with TensorFlow is partial, and the Python-to-Ruby porting guide highlights naming and parameter convention differences

Verdict

Worth a look if you’re committed to a Ruby stack and need lightweight model deployment without Python dependencies. Skip it if you need full TensorFlow compatibility, mature GPU acceleration (CUDA isn’t mentioned), or serious deep learning performance.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.