/// <summary> /// backward action /// </summary> /// <param name="lr"> lerning rate</param> /// <param name="gradTns"> grad error tensor</param> /// <returns> true - ok</returns> public bool backward(float lr, Tensor gradTns) { if ((net_ == null) && !createNet()) { return(false); } return(snBackward(net_, lr, gradTns.size(), gradTns.data())); }
/// <summary> /// forward action /// </summary> /// <param name="isLern"> is lerning ?</param> /// <param name="inTns"> in tensor</param> /// <param name="outTns"> out result tensor</param> /// <returns> true - ok</returns> public bool forward(bool isLern, Tensor inTns, Tensor outTns) { if ((net_ == null) && !createNet()) { return(false); } return(snForward(net_, isLern, inTns.size(), inTns.data(), outTns.size(), outTns.data())); }
/// <summary> /// set weight of node /// </summary> /// <param name="name"> name node in architecture of net</param> /// <param name="weight"> set weight tensor</param> /// <returns> true - ok</returns> public bool setWeightNode(string name, Tensor weight) { if (net_ == null) { return(false); } IntPtr cname = Marshal.StringToHGlobalAnsi(name); bool ok = snSetWeightNode(net_, cname, weight.size(), weight.data()); Marshal.FreeHGlobal(cname); return(ok); }
/// <summary> /// cycle forward-backward /// </summary> /// <param name="lr"> lerning rate</param> /// <param name="inTns"> in tensor</param> /// <param name="outTns"> out tensor</param> /// <param name="targetTns"> target tensor</param> /// <param name="outAccurate"> accurate error</param> /// <returns> true - ok</returns> public bool training(float lr, Tensor inTns, Tensor outTns, Tensor targetTns, ref float outAccurate) { if ((net_ == null) && !createNet()) { return(false); } float accurate = 0; bool ok = snTraining(net_, lr, inTns.size(), inTns.data(), outTns.size(), outTns.data(), targetTns.data(), &accurate); outAccurate = accurate; return(ok); }