Crate tfdeploy[−][src]
Tensorflow Deploy
Tiny, no-nonsense, self contained, portable Tensorflow inference.
Example
use tfdeploy::*; // load a simple model that just add 3 to each input component let model = tfdeploy::tf::for_path("tests/models/plus3.pb").unwrap(); // "input" and "output" are tensorflow graph node names. // we build an execution plan for computing output from input let plan = SimplePlan::new(&model, &["input"], &["output"]).unwrap(); // run the computation. let input = ndarray::arr1(&[1.0f32, 2.5, 5.0]); let mut outputs = plan.run(tvec![input.into()]).unwrap(); // take the tensors coming out of the only output node let mut tensors = outputs.pop().unwrap(); // grab the first (and only) tensor of this output, and unwrap it as array of f32 let tensor = tensors.pop().unwrap().take_f32s().unwrap(); assert_eq!(tensor, ndarray::arr1(&[4.0, 5.5, 8.0]).into_dyn());
For a more serious example, see inception v3 example.
Re-exports
pub use errors::*; |
pub use analyser::TensorFact; |
pub use dim::TDim; |
pub use model::Model; |
pub use model::Node; |
pub use model::TVec; |
pub use plan::SimplePlan; |
pub use tensor::DatumType; |
pub use tensor::Tensor; |
pub use model::tf; |
Modules
| analyser | |
| dim | |
| errors |
error_chain generated types |
| macros | |
| model | |
| ops |
TensorFlow Ops |
| plan | |
| streaming | |
| tensor |
|
| tfpb |
Generated protobuf codec for Tensorflow models, plus a handful of helper for writting tests. |
Macros
| dimfact |
Constructs a dimension fact. |
| map_tensor | |
| shapefact |
Constructs a shape fact. |
| tvec | |
| typefact |
Constructs a type fact. |
| unwrap_or_none |
Tries to unwrap an option, or returns Ok(None) otherwise. |
| valuefact |
Constructs an value fact. |
| wrap |