New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tensorflow-ruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tensorflow-ruby

0.2.0
Rubygems
Version published
Maintainers
1
Created
Source

Tensorflow

Ruby bindings for Tensorflow.

Installation

First you'll need to install Tensorflow 2. You can either do a full installation or just install Tensorflow for C. In both cases, you'll need to make sure the tensorflow library is on the system PATH so the Ruby bindings can load it.

Next install the gem:

gem install 'tensorflow-ruby'

Overview

The Ruby bindings are on built on top of TensorFlow's [C API] (https://github.com/tensorflow/docs/blob/master/site/en/r1/guide/extend/bindings.md) which provides access to some, but not all, of TensorFlow's functionality. The Ruby bindings
are designed to mimic the Python API. Just like the Python bindings, Ruby defaults to eager execution mode.

Current Status

FeatureStatus
Run a predefined GraphImplemented
Graph construction with generated op functionsImplemented
GradientsImplemented
FunctionsImplemented
TrainersGradient Descent Implemented
Data API80% Implemented
Tensorboard SupportImplemented
Control FlowNot Implemented
Gradient TapeNot Implemented
KerasNot Implemented

Getting Help

To learn how to use the library:

  • Read this file
  • Take a look at the comprehensive test suite - it will show you examples of using all the binding's functionality
  • Review the gem documentation
  • Review the Python API documentation
  • Take a look at the models directory for example implementations (linear regression, mnist neural network, etc.)

Using tensorflow-ruby

Constants

Constants are

a = Tf.constant([1, 2, 3])
b = Tf.constant([4, 5, 6])
a + b

Variables

v = Tf::Variable.new(0.0)
w = v + 1

Math

Tf::Math.abs([-1, -2])
Tf::Math.sqrt([1.0, 4.0, 9.0])

Data::Dataset

# load
train_dataset = Tf::Data::Dataset.from_tensor_slices([train_examples, train_labels])
test_dataset = Tf::Data::Dataset.from_tensor_slices([test_examples, test_labels])

# shuffle and batch
train_dataset = train_dataset.shuffle(100).batch(32)
test_dataset = test_dataset.batch(32)

# iterate
train_dataset.each do |examples, labels|
  # ...
end

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

To get started with development and testing:

git clone https://github.com/cfis/tensorflow-ruby.git
cd tensorflow-ruby
bundle install
rake test

FAQs

Package last updated on 03 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts