public static float[] ValueToArray(CNTK.Value value) { if (value.IsSparse) { throw new NotImplementedException("Sparse value is not supported yet"); } if (value.DataType != CNTK.DataType.Float) { throw new NotImplementedException("Only float value is supported"); } var variable = CNTK.Variable.InputVariable(value.Shape, CNTK.DataType.Float); var result = value.GetDenseData <float>(variable); return(result[0].ToArray()); }
public static DataSourceBase <float, IList <float> > FromVariable(CNTK.Variable variable) { var array = variable.GetValue(); if (array.IsSparse) { throw new NotImplementedException("Sparse value is not supported yet"); } if (array.DataType != CNTK.DataType.Float) { throw new NotImplementedException("Only float value is supported"); } var value = new CNTK.Value(array); var result = value.GetDenseData <float>(variable); return(new DataSourceBase <float, IList <float> >(result[0], value.Shape.Dimensions.ToArray())); }