public void ParameterlessConstructor_Activator() { var activator = ActivatorFactory.Build(typeof(Class)); for (var i = 0; i < trials; i++) { activator(); } }
private static ILayer DeserializeStandardLayer(SerializedStandardLayer standardSerialized, int batchSize) { var weights = Matrix <double> .Build.DenseOfArray(standardSerialized.Weights); var bias = Matrix <double> .Build.DenseOfColumnArrays(new double[][] { standardSerialized.Bias }); var activator = ActivatorFactory.Build(standardSerialized.ActivatorType); switch (standardSerialized.GradientAdjustmentParameters.Type) { case GradientAdjustmentType.FixedLearningRate: var learningRate = standardSerialized.GradientAdjustmentParameters as FixedLearningRateParameters; var LRAdjustment = new FixedLRAdjustment(new FixedLearningRateParameters(learningRate.LearningRate / batchSize)); return(new BasicStandardLayer(weights, bias, batchSize, activator, learningRate, LRAdjustment)); case GradientAdjustmentType.Momentum: var momentum = standardSerialized.GradientAdjustmentParameters as MomentumParameters; var momentumAdjustment = new MomentumAdjustment(new MomentumParameters(momentum.LearningRate / batchSize, momentum.Momentum), weights, bias, batchSize); return(new BasicStandardLayer(weights, bias, batchSize, activator, momentum, momentumAdjustment)); default: throw new InvalidOperationException("Unknown Gradient Adjustment Parameter Type"); } }