public void FirstTrainingShouldSetMatrixDimensions() { var bamModel = new BamModel(); bamModel.Teach(_image1, _name1); _output.WriteLine(bamModel.WeightsMatrix.ToString()); bamModel.WeightsMatrix.RowCount.ShouldBeEquivalentTo(6); bamModel.WeightsMatrix.ColumnCount.ShouldBeEquivalentTo(4); }
public void TrainingByNameWithBadLengthShouldThrowArgumentException() { var bamModel = new BamModel(); var nameWithBadLength = Vector <float> .Build.DenseOfArray(new float[5]); bamModel.Teach(_image1, _name1); Action validatingImageLength = () => bamModel.Teach(_image2, nameWithBadLength); validatingImageLength.ShouldThrow <ArgumentException>(); }
public void RecoveringImageFromNameVectorWithWrongLengthShouldThrowArgumentException() { var bamModel = new BamModel(); var namesMatrixWithWrongColumnLength = Matrix <float> .Build.DenseOfArray(new float[1, 10]); bamModel.Teach(_image1, _name1); Action recoveringImageFromWrongName = () => bamModel.RecoverImage(namesMatrixWithWrongColumnLength); recoveringImageFromWrongName.ShouldThrow <ArgumentException>(); }
public void RecoveringNameWithOneGivenImageVectorShouldReturnRightName() { var bamModel = new BamModel(); var imagesMatrix = Matrix <float> .Build.DenseOfRowVectors(_image1); var namesMatrix = Matrix <float> .Build.DenseOfRowVectors(_name1); bamModel.Teach(_image1, _name1); bamModel.Teach(_image2, _name2); Matrix <float> resultNamesMatrix = bamModel.RecoverName(imagesMatrix); _output.WriteLine(resultNamesMatrix.ToString()); resultNamesMatrix.ShouldBeEquivalentTo(namesMatrix); }
public void SecondTrainingShouldGiveRightWeightMatrix() { var bamModel = new BamModel(); var correctMatrix = Matrix <float> .Build.DenseOfArray(new[, ] { { 0f, -2, 2, 0 }, { 0, 2, -2, 0 }, { 0, 2, -2, 0 }, { 2, 0, 0, -2 }, { -2, 0, 0, 2 }, { 0, 2, -2, 0 } }); bamModel.Teach(_image1, _name1); bamModel.Teach(_image2, _name2); _output.WriteLine(bamModel.WeightsMatrix.ToString()); bamModel.WeightsMatrix.ShouldBeEquivalentTo(correctMatrix); }