added requires to matrix operations; removed cost dependence from trainer; moved tensors and values allocation to constructors