public Tensor(snLSize lsz) { lsz_ = lsz; int sz = (int)(lsz.w * lsz.h * lsz.ch * lsz.bsz * sizeof(float)); if (sz > 0) { data_ = (float *)Marshal.AllocHGlobal(sz); } }
public Tensor(snLSize lsz, float *data) { lsz_ = lsz; UInt64 sz = lsz.w * lsz.h * lsz.ch * lsz.bsz * sizeof(float); if (sz > 0) { data_ = (float *)Marshal.AllocHGlobal((int)sz); MemCopy((IntPtr)data_, (IntPtr)data, sz); } }
static extern bool snSetWeightNode(void *net, IntPtr name, snLSize wsz, float *wData);
static extern bool snTraining(void *net, float lr, snLSize insz, float *iLayer, snLSize osz, float *outData, float *targetData, float *outAccurate);
static extern bool snBackward(void *net, float lr, snLSize gsz, float *grad);
static extern bool snForward(void *net, bool isLern, snLSize isz, float *iLayer, snLSize osz, float *outData);
public Tensor(snLSize lsz = new snLSize(), float[] data = null){ lsz_ = lsz; data_ = data; }