hal-ml 0.2.0

HAL: a machine learning library that is able to run on Nvidia, OpenCL or CPU BLAS based compute backends. It currently provides stackable classical neural networks, RNN's and soon to be LSTM's. A differentiation of this package is that we are looking to implement RTRL (instead of just BPTT) for the recurrent layers in order to provide a solid framework for online learning. We will also (in the future) be implementing various layers such as unitary RNN's, NTM's and Adaptive Computation time based LSTM's. HAL also comes with the ability to plot and do many basic math operations on arrays.
use af;
use af::{Array, Dim4, HasAfEnum};

use utils;
//use error::HALError;

pub fn plot_array(values: &Array, title: &str, window_x: u16, window_y: u16) {
  assert!(values.dims()[1] == 1);

  // create a window
  let title_str = String::from(title);
  let wnd = af::Window::new(window_x as i32, window_y as i32, title_str);

  // display till closed
  loop {
    wnd.draw_plot(&af::range::<f32>(values.dims().clone()
                                    , 0), &values, None);
    if wnd.is_closed() == true { break; }
  }
}

pub fn plot_vec<T: HasAfEnum>(raw_values: Vec<T>, title: &str, window_x: u16, window_y: u16) {
  // copy from float vector to Array
  let num_rows = raw_values.len();
  let dims = Dim4::new(&[num_rows as u64, 1, 1, 1]);
  let values = utils::vec_to_array(raw_values, dims);
  plot_array(&values, title, window_x, window_y);
}