public NeuralNetworkDefaultData(NeuralNetworkDefault nrlNet)
 {
     Id = nrlNet.Id;
     ActivationFuncName = FuncDictionary.GetFuncName(nrlNet.ActivationFunc) ?? "Unknown function";
     Layers             = nrlNet.Layers;
     Weights            = nrlNet.Weigths;
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MediumSolverFactory"/> class.
        /// </summary>
        /// <param name="timeStep">The time step.</param>
        public MediumSolverFactory(double timeStep)
        {
            this.timeStep      = timeStep;
            this.mediumFactors = new MemoDictionary <string, BaseMediumFactor>();
            this.mediumSolvers = new FuncDictionary();

            this.initSolvers();

            this.initFactors();
        }
예제 #3
0
        public static void EqualTest(bool shouldBeEqual, int[] xs, string[] xv, int[] ys, string[] yv)
        {
            var expected = FuncDictionary.Make(xs.Zip(xv));
            var actual   = FuncDictionary.Make(ys.Zip(yv));

            if (shouldBeEqual)
            {
                Assert.True(actual.Equals(expected));
            }
            else
            {
                Assert.False(actual.Equals(expected));
            }
        }
예제 #4
0
        public NetworkDataModel GetNetworkData()
        {
            var data = new NetworkDataModel
            {
                ActivationFuncName = FuncDictionary.GetFuncName(ActivationFunc),
                Id           = Id,
                Layers       = Layers,
                LearningRate = LearningRate,
                Name         = Name,
                Weights      = Weigths,
                Generation   = Generation,
                StorageId    = StorageId
            };

            return(data);
        }
예제 #5
0
        public NetworkVM GetViewModel()
        {
            NetworkVM networkVM = new NetworkVM(this)
            {
                Id           = Id.ToString(),
                Layers       = new ObservableCollection <NetworkLayerVM>(Layers.ToLayerViewModels()),
                CurrentFunc  = FuncDictionary.GetFuncName(ActivationFunc),
                LearningRate = LearningRate,
                Name         = Name,
                IsPrototype  = false,
                Generation   = Generation,
                Storageid    = StorageId.ToString()
            };

            return(networkVM);
        }
예제 #6
0
        public static void FuncDictionaryAdd(int[] xs, string[] ys, int key, string value)
        {
            var intComp = new FuncComparer <int>((x, y) => x.CompareTo(y), x => x.GetHashCode());

            var fd         = new FuncDictionary <int, string>(intComp, (xs ?? new int[0]).Zip(ys ?? new string[0]));
            var origLength = fd.Count;

            fd.Add(key, value);

            var dict = new FuncDictionary <int, string>(intComp, (xs ?? new int[0]).Zip(ys ?? new string[0]))
            {
                { key, value }
            };

            Assert.Equal(dict.OrderBy(kv => kv.Key), fd.OrderBy(kv => kv.Key));
            Assert.Equal(origLength + 1, fd.Count);
        }
예제 #7
0
        public NeuralNetworkDefault(NeuralNetworkDefaultData nrlNetData)
        {
            Id           = nrlNetData.Id ?? Guid.NewGuid();
            Layers       = nrlNetData.Layers;
            Weigths      = nrlNetData.Weights ?? GetDefaultWeigths();
            LearningRate = nrlNetData.LearningRate;
            AllOutputs   = new Matrix2D[Layers.Length];

            if (!string.IsNullOrEmpty(nrlNetData.ActivationFuncName) && FuncDictionary.TryGetFunc(nrlNetData.ActivationFuncName, out Func <float, float> activationFunc))
            {
                ActivationFunc = activationFunc;
            }
            else
            {
                ActivationFunc = MathFuncs.Sigmoid;
            }
        }
예제 #8
0
 /// <summary>
 /// Equivalent to <see cref="IFunctor{TSource}.Map{TResult}(Func{TSource, TResult})"/>, but restricted to <see cref="FuncDictionary{TKey, TValue}"/>. Offers LINQ query support with one <c>from</c>-clause.
 /// </summary>
 /// <typeparam name="TKey">The type of the source's key.</typeparam>
 /// <typeparam name="TSource">The type of the source's value.</typeparam>
 /// <typeparam name="TResult">The type of the result's value.</typeparam>
 /// <param name="source">The source.</param>
 /// <param name="f">The function to apply.</param>
 public static FuncDictionary <TKey, TResult> Select <TKey, TSource, TResult>(this FuncDictionary <TKey, TSource> source, Func <TSource, TResult> f)
 => (FuncDictionary <TKey, TResult>)source.Map(f);