Struct autograd::context::Context [] [src]

pub struct Context {
    pub variables: HashMap<Tensor, NdArray>,
    pub outputs: HashMap<Tensor, Result<NdArray, OpComputeErrorStatus>>,
}

What is necessary to run computation graphs.

Context object is used: - to create shared variable tensors - to create constant tensors - to run computation graphs actually

When a computation graph is evaluated, all the variables/constants in the graph must be what derives from the same context; otherwise will panic.

extern crate ndarray;
extern crate autograd as ag;

// new Context
let mut ctx = ag::Context::new();

let ref x = ag::placeholder(&[2]);
// make shared variable in the context
let ref v = ag::variable(ndarray::arr1(&[2., 2.]), &mut ctx);
let ref b = ag::ones(&[2]);
let ref z = x + v + b;

// fills placeholder
ctx.feed_input(x, ndarray::arr1(&[1., 1.]));

// eval
assert_eq!(z.eval(&mut ctx).as_slice().unwrap(), &[4., 4.]);

Fields

Methods

impl Context
[src]

[src]

Creates new context object.

[src]

Returns all variables in this context.

[src]

Skips arr's shape checking.

[src]

Trait Implementations

impl Clone for Context
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more