public void ModelGradients3() { Matrix <double> in_hid = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 }, { 2 } } ); Matrix <double> hid_class = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1, 0 }, { 0, 1 } } ); Matrix <double> input = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 } } ); Matrix <double> target = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 }, { 0 } } ); MutableTypes.Model networkModel = new MutableTypes.Model(in_hid, hid_class); MutableTypes.NetworkState networkState = NetRun.RunNetwork(networkModel, input); MutableTypes.Model gradients = Training._getModelGradients(networkModel, networkState, target); double l1 = NetworkFunctions.Logistic(1); double l2 = NetworkFunctions.Logistic(2); double el1 = Math.Exp(l1); double el2 = Math.Exp(l2); double N = el1 + el2; double el1N = el1 / N; double el2N = el2 / N; double ld1 = NetworkFunctions.LogisticDerivative_f_output(l1); double ld2 = NetworkFunctions.LogisticDerivative_f_output(l2); Matrix <double> hid_class_gradient_check = Matrix <double> .Build.DenseOfArray( new double[, ] { { l1 *(el1N - 1), l2 *(el1N - 1) }, { l1 *el2N, l2 *el2N } } ); Matrix <double> in_hid_gradient_check = Matrix <double> .Build.DenseOfArray( new double[, ] { { ld1 *(el1N - 1) }, { ld2 *el2N } } ); Assert.AreEqual(hid_class_gradient_check, gradients.HiddenToClassifier); Assert.AreEqual(in_hid_gradient_check, gradients.InputToHidden); }
public void LoadInterfaces() { this.Interfaces.Clear(); this.AllAttachednetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface tmpInterface in this.AllAttachednetworkInterfaces) { if (tmpInterface.OperationalStatus != OperationalStatus.Up) { continue; } if (tmpInterface.GetIPProperties() == null || tmpInterface.GetIPProperties().UnicastAddresses.Count <= 0) { continue; } // Find entry with valid IPv4 address // Continue if no valid IP address and netmask is found UnicastIPAddressInformation ipAddress = this.DetermineIpAddress(tmpInterface); if (ipAddress?.IPv4Mask == null) { continue; } // Append found interface with details to interface array try { var newInterface = default(NetworkInterfaceConfig); newInterface.IsUp = true; newInterface.Id = tmpInterface.Id; newInterface.Name = tmpInterface.Name; newInterface.Description = tmpInterface.Description; newInterface.IpAddress = ipAddress.Address.ToString(); newInterface.MacAddress = NetworkFunctions.GetMacByIp(ipAddress.Address.ToString()); newInterface.BroadcastAddr = NetworkFunctions.GetBroadcastAddress(ipAddress.Address, ipAddress.IPv4Mask).ToString(); newInterface.NetworkAddr = NetworkFunctions.GetNetworkAddress(ipAddress.Address, ipAddress.IPv4Mask).ToString(); newInterface.DefaultGw = this.DetermineGatewayIp(tmpInterface); newInterface.GatewayMac = NetworkFunctions.GetMacByIp(newInterface.DefaultGw); this.Interfaces.Add(newInterface); } catch (Exception ex) { LogCons.Inst.Write(LogLevel.Error, ex.Message); } } }
public void ModelGradients2() { Matrix <double> in_hid = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 } } ); Matrix <double> hid_class = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 }, { 1 } } ); Matrix <double> input = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 } } ); Matrix <double> target = Matrix <double> .Build.DenseOfArray( new double[, ] { { 1 }, { 0 } } ); MutableTypes.Model networkModel = new MutableTypes.Model(in_hid, hid_class); MutableTypes.NetworkState networkState = NetRun.RunNetwork(networkModel, input); MutableTypes.Model gradients = Training._getModelGradients(networkModel, networkState, target); Matrix <double> hid_class_gradient_check = Matrix <double> .Build.DenseOfArray( new double[, ] { { -NetworkFunctions.Logistic(1) / 2 }, { NetworkFunctions.Logistic(1) / 2 } } ); Matrix <double> in_hid_gradient_check = Matrix <double> .Build.DenseOfArray( new double[, ] { { 0 } } ); Assert.AreEqual(hid_class_gradient_check, gradients.HiddenToClassifier); Assert.AreEqual(in_hid_gradient_check, gradients.InputToHidden); }
static public async Task CreateNewMatchAsync(string matchID = null) { if (matchID == null) { matchID = MatchID; } Debug.Log("Creating a new QUADCORE match in firebase with ID: " + matchID); var function = NetworkFunctions.GetHttpsCallable("addMatch"); var data = new Dictionary <string, object>(); data["match_id"] = matchID; /* * data["players"] = new string[] * { * "TestPlayer", * null * }; */ dynamic result = await function.CallAsync(data); Debug.Log("Write result: " + result?.Data["result"]); }
void Start() { instance = this; }
protected void checkStorageThread() { if (storageThread.NumChunks() > 0) { Chunk chunk = storageThread.DequeueChunk(); Logger.Debug("EchoBackupService:checkStorageThread Finished archiving chunk."); //identify host(s) to send to. List <GuidAndIP> gai = NetworkFunctions.GetOnlineNodesIPAddresses(); if (gai.Count < 2) { Logger.Warn("EchoBackupService:checkStorageThread not enough online hosts. hosts online: " + gai.Count); } //send chunk to hosts. List <Block> blocks = new List <Block>(); long filesize = new FileInfo(chunk.Path()).Length; for (int i = 0; i < 2 && i < gai.Count; i++) { TcpClient tc = new TcpClient(gai[i].ipAddress.ToString(), CommandServer.SERVER_PORT); ClientThread ct = new ClientThread(tc, false, this.guid); PushRequest pr = new PushRequest(Node.GetIPAddress(), this.guid, MiscFunctions.Next()); pr.Path = chunk.Path(); pr.FileSize = filesize; pr.BackupNumber = chunk.BackupID(); pr.ChunkNumber = chunk.ChunkID(); ct.EnqueueWork(pr); lock (clientThreads) { clientThreads.Add(ct); } blocks.Add(new Block(this.guid.ToString(), gai[i].guid.ToString(), "bad storage path", filesize, MiscFunctions.DBDateAndTime())); } //do something with the index so we know about this backup //store files in BackupIndex IndexDatabase idb = new IndexDatabase(); foreach (FileInChunk fic in chunk.Files()) { BackupIndex bi = new BackupIndex(); string fullpath = Path.Combine(chunk.BasePath(), fic.path); if (Directory.Exists(fullpath)) { continue; } bi.backupLevel = 0; bi.dateAndTime = MiscFunctions.DBDateAndTime(); bi.firstBlockOffset = 0; bi.size = new FileInfo(fullpath).Length; bi.sourceGUID = this.guid.ToString(); bi.sourcePath = fullpath; //todo: we cannot insert multiple blocks for every file. that is what the index-to-block table is for //idb.InsertIndex(bi, blocks); } //store indexes in DB } if (storageThread.NumRecoverStructs() > 0) { RecoverResult rs = storageThread.DequeueRecoverResult(); lock (recoverResults) { recoverResults.Enqueue(rs); } } }