pub struct HogwildArray<A, D>(_);
Array for Hogwild parallel optimization.
This array type can be used for the Hogwild (Niu, et al. 2011) method
of parallel Stochastic Gradient descent. In Hogwild different threads
share the same parameters without locking. If SGD is performed on a
sparse optimization problem, where only a small subset of parameters
is updated in each gradient descent, the impact of data races is
negligible.
In order to use Hogwild in Rust, we have to subvert the ownership
system. This is what the HogwildArray type does. It uses reference
counting to share an ndarray Array type between multiple
HogwildArray instances. Views of the underling Array can be borrowed
mutably from each instance, without mutual exclusion between mutable
borrows in different HogwildArray instances.
extern crate hogwild;
extern crate ndarray;
use hogwild::HogwildArray2;
use ndarray::Array2;
let mut a1: HogwildArray2<f32> = Array2::zeros((2, 2)).into();
let mut a2 = a1.clone();
let mut a1_view = a1.view_mut();
let c00 = &mut a1_view[(0, 0)];
*c00 = 1.0;
a2.view_mut()[(1, 1)] = *c00 * 2.0;
assert_eq!(&[1.0, 0.0, 0.0, 2.0], a2.as_slice().unwrap());
Get an immutable subview of the Hogwild array.
Get a mutable subview of the Hogwild array.
Get a slice reference to the underlying data array.
Get an immutable view of the Hogwild array.
Get an mutable view of the Hogwild array.
Performs copy-assignment from source. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (try_from)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from)
Mutably borrows from an owned value. Read more