public void Check_URL_Remove_Html_Code() { var cacheMock = new Mock <IDataCache>(); var RepoMock = new Mock <IRepository>(); var urlExecutor = new SingleLayer(cacheMock.Object, RepoMock.Object); urlExecutor.SetUrl("https://tabish.com/first%2FSecond"); urlExecutor.Url.ShouldBe("https://tabish.com/first/second"); }
/// <summary> /// Returns value of single unit in a single layer for single data row /// </summary> /// <param name="idxUptillLayer"></param> /// <param name="idxUnit"></param> /// <param name="dataRow"></param> /// <returns></returns> public double GetNeuralNetworkOutputSingleDataRowSingleUnit( int idxUptillLayer, long idxUnit, long dataRow) { //((SingleLayerInput)(_layers[0])).SetCurrentRow(dataRow); SingleLayer lastLayer = _layers[idxUptillLayer]; return(lastLayer.GetValue(idxUnit, dataRow)); }
public void Check_URL_Do_Not_Append() { var cacheMock = new Mock <IDataCache>(); var RepoMock = new Mock <IRepository>(); var urlExecutor = new SingleLayer(cacheMock.Object, RepoMock.Object); urlExecutor.SetUrl("https://tabish.com"); urlExecutor.Url.ShouldBe("https://tabish.com"); }
public void Check_URL_Empty_Validation_Fail() { var cacheMock = new Mock <IDataCache>(); var RepoMock = new Mock <IRepository>(); var urlExecutor = new SingleLayer(cacheMock.Object, RepoMock.Object); urlExecutor.SetUrl(""); bool result = urlExecutor.Validate(); result.ShouldBeFalse(); urlExecutor.ErrorMessages.Count.ShouldBe(1); }
public void AddLayer(int layerIdx, long numberOfUnits, double weightInitValue, IActivationFunction actFunction, int maxParallelThreads) { if (layerIdx > _layers.Length - 1) { throw new IndexOutOfRangeException(); } int upStreamIdx = 0; if (layerIdx > 0) { upStreamIdx = layerIdx - 1; } _layers[layerIdx] = new SingleLayer(numberOfUnits, weightInitValue, _layers[upStreamIdx], actFunction, _maxParallelThreads); }
public NeuralGenTrainTask() { ISingleLayer <double>[] layers = new ISingleLayer <double> [2]; layers[0] = new SingleLayer(6, 6, new Neuro.MLP.ActivateFunction.BipolarTreshhold(), new Random()); layers[1] = new SingleLayer(6, 1, new Neuro.MLP.ActivateFunction.BipolarTreshhold(), new Random()); MultiLayer mLayer = new MultiLayer(layers); DifferintiableLearningConfig config = new DifferintiableLearningConfig(new Neuro.MLP.ErrorFunction.HalfEuclid()); config.Step = 0.1; config.OneImageMinError = 0.01; config.MinError = 0.5; config.MinChangeError = 0.0000001; config.UseRandomShuffle = true; config.MaxEpoch = 10000; SimpleBackPropogation learn = new SimpleBackPropogation(config); network = new MultiLayerNeuralNetwork(mLayer, learn); }
public double[] GetNeuralNetworkOutputForSingleDataRow(int idxUptillLayer, long dataRow) { SingleLayer lastLayer = _layers[idxUptillLayer]; long lastLayerNoOfUnits = lastLayer.GetNumberOfUnits(); double[] outputs = new double[lastLayerNoOfUnits]; //Only run for last layer for (int uIdx = 0; uIdx < lastLayerNoOfUnits; uIdx++) { outputs[uIdx] = GetNeuralNetworkOutputSingleDataRowSingleUnit(idxUptillLayer, uIdx, dataRow); } return(outputs); }
public void Generate_Url_From_KeyCode() { string url = "https://tabish.com/first/Second"; var cacheMock = new Mock <IDataCache>(); var RepoMock = new Mock <IRepository>(); RepoMock.Setup(x => x.FindKey(It.IsAny <long>())).Returns(new TopLevelModel() { Id = 1, Url = url }); var urlExecutor = new SingleLayer(cacheMock.Object, RepoMock.Object); urlExecutor.SetUrl(url); var result = urlExecutor.GetLongUrl("b"); result.ShouldNotBeNullOrEmpty(); result.ShouldBe(url); }
public void Generate_KeyCode_From_Url() { var cacheMock = new Mock <IDataCache>(); var RepoMock = new Mock <IRepository>(); RepoMock.Setup(x => x.Add(It.IsAny <TopLevelModel>())).Returns(new TopLevelModel() { Id = 1 }); var urlExecutor = new SingleLayer(cacheMock.Object, RepoMock.Object); urlExecutor.SetUrl("https://tabish.com/first%2FSecond"); var result = urlExecutor.GetShortUrl(); result.ShouldNotBeNullOrEmpty(); result.ShouldBe("b"); }