#TensorFlow #ndarray

ndarray-tensorflow

Adapter for Tensorflow tensors to expose the ndarray API

3 releases (breaking)

✓ Uses Rust 2018 edition

new 0.3.0 Nov 28, 2019
0.2.0 May 21, 2019
0.1.0 May 4, 2019

#44 in Machine learning

Download history 69/week @ 2019-08-15 37/week @ 2019-08-22 33/week @ 2019-08-29 28/week @ 2019-09-05 9/week @ 2019-09-12 97/week @ 2019-09-19 54/week @ 2019-09-26 97/week @ 2019-10-03 103/week @ 2019-10-10 314/week @ 2019-10-17 98/week @ 2019-10-24 199/week @ 2019-10-31 72/week @ 2019-11-07 39/week @ 2019-11-14 20/week @ 2019-11-21

389 downloads per month
Used in 2 crates (1 directly)

Apache-2.0

8KB
123 lines

Introduction

crates.io docs.rs Travis CI

This crate provides a wrapper for the Tensor type of the tensorflow crate that can create ArrayView and ArrayViewMut instances. This makes it possible to use tensors through the ndarray API.


lib.rs:

Tensor wrapper that exposes the ndarray API.

This crate provides a small wrapper around the Tensor data structure of the tensorflow crate, to make it possible to use the ndarray API. This wrapper, NdTensor, provides the view and view_mut methods to respectively obtain ArrayView and ArrayViewMut instances.

The following example shows how to wrap a Tensor and obtain an ArrayView:

use ndarray::{arr2, Ix2};
use ndarray_tensorflow::NdTensor;
use tensorflow::Tensor;

let tensor = Tensor::new(&[2, 3])
    .with_values(&[0u32, 1, 2, 3, 4, 5])
    .unwrap();
let array: NdTensor<_, Ix2> =
    NdTensor::from_tensor(tensor)
    .unwrap();
assert_eq!(array.view(),
    arr2(&[[0, 1, 2], [3, 4, 5]]));

Dependencies

~1.6–3MB
~56K SLoC