public override void LoadFromZip(ZipArchiveEntry[] ww) { foreach (var item in ww) { if (item.Name.Contains("_weight")) { using (var stream = item.Open()) { using (var memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); Weight = NpyLoader.Load(memoryStream.ToArray()); } } } if (item.Name.Contains("_bias")) { using (var stream = item.Open()) { using (var memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); Bias = NpyLoader.Load(memoryStream.ToArray()); } } } } }
public Form1() { InitializeComponent(); //Fix.main(null); /*var n1 = THWrapper.THIntTensor_new(); * THWrapper.THIntTensor_resize2d(n1, 10, 20); * * var bts = BitConverter.GetBytes(-422); * var res = BitConverter.ToUInt32(bts, 0); * THWrapper.THIntTensor_set2d(n1, 0, 0, res); * var v1 = THWrapper.THIntTensor_get2d(n1, 0, 0); * var bts2 = BitConverter.GetBytes(v1); * var restore = BitConverter.ToInt32(bts2, 0);*/ //var n1 = THWrapper.THFloatTensor_new(); //THWrapper.THFloatTensor_resize2d(n1, 10, 20); //var v1 = THWrapper.THFloatTensor_get2d(n1, 0, 0); //THWrapper.THFloatTensor_fill(n1, 11); //var dims=THWrapper.THFloatTensor_nDimension(n1); //for (int i = 0; i < dims; i++) //{ // var a1 = THWrapper.THFloatTensor_size(n1, i); //} //var v2 = THWrapper.THFloatTensor_get2d(n1, 0, 0); //THWrapper.THFloatTensor_set2d(n1, 0, 0,-4.4f); //var v3 = THWrapper.THFloatTensor_get2d(n1, 0, 0); //var di = THWrapper.THFloatTensor_data(n1); //byte[] dest = new byte[4 * 4]; //Marshal.Copy(di, dest, 0, 16); //var aaaa= BitConverter.ToSingle(dest, 0); //var aaaa2 = BitConverter.ToSingle(dest, 4); //var int1=InternalArray.FromTHTensor(n1); //var bts = BitConverter.GetBytes(-12.143f); //for (int i = 0; i < bts.Length; i++) //{ // dest[i] = bts[i]; //} //Marshal.Copy(dest, 0, di, 16); //v3 = THWrapper.THFloatTensor_get2d(n1, 0, 0); //THWrapper.THFloatTensor_free(n1); net = new FPBinLeNetTest(); imgs = Stuff.LoadImages("t10k-images.idx3-ubyte", "t10k-labels.idx1-ubyte"); if (File.Exists("1.npy")) { sample = NpyLoader.Load("1.npy"); } net.LoadFromZip("BinLenet.zip"); net.PrepareData(); }