1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! Interface to [TensorFlow][1].
//!
//! [1]: https://www.tensorflow.org
//!
//! ## Example
//!
//! Create a graph in Python:
//!
//! ```python
//! import tensorflow as tf
//!
//! with tf.Session() as session:
//! a = tf.Variable(0.0, name='a')
//! b = tf.Variable(0.0, name='b')
//! c = tf.mul(a, b, name='c')
//! tf.train.write_graph(session.graph_def, '', 'graph.pb', as_text=False)
//! ```
//!
//! Evaluate the graph in Rust:
//!
//! ```
//! # const GRAPH_PATH: &'static str = "examples/fixtures/graph.pb";
//! use tensorflux::{Definition, Input, Options, Output, Session, Tensor};
//!
//! let mut session = Session::new(&Options::new().unwrap()).unwrap();
//! session.extend(&Definition::load(GRAPH_PATH).unwrap()).unwrap(); // c = a * b
//!
//! let mut inputs = vec![Input::new("a"), Input::new("b")];
//! inputs[0].set(Tensor::new(vec![1f32, 2.0, 3.0], &[3]).unwrap());
//! inputs[1].set(Tensor::new(vec![4f32, 5.0, 6.0], &[3]).unwrap());
//!
//! let mut outputs = vec![Output::new("c")];
//!
//! session.run(&mut inputs, &mut outputs, &vec![]).unwrap();
//!
//! let result = outputs[0].get::<f32>().unwrap();
//! assert_eq!(&result[..], &[1.0 * 4.0, 2.0 * 5.0, 3.0 * 6.0]);
//! ```
extern crate libc;
extern crate tensorflow_sys as ffi;
pub use Definition;
pub use Error;
pub use ;
pub use Options;
pub use ;
pub use Tensor;
/// A result.
pub type Result<T> = Result;