private Vector3 GetRandomShift() { float x = RandomGaussian.Next(0.0f, deviation); float z = RandomGaussian.Next(0.0f, deviation); return(new Vector3(x, 0, z)); }
public static Network BuildNetwork(Random random, ICostFunction costFunction, IRegularizationFunction regularizationFunction, WeightIntializerType weightIntializerType, DropoutLayerOptions dropoutLayerOptions, int inputNeuronCount, int outputNeuronCount, params int[] hiddenLayerCounts) { Network network = new Network(costFunction, regularizationFunction, dropoutLayerOptions, random); network.InputLayer = InputLayer.BuildInputLayer(null, inputNeuronCount, random); Layer previousLayer = network.InputLayer; int dropoutLayerIndex = 1; bool isDropoutLayer = false; IWeightBuilder weightBuilder = null; for (int c = 0; c < hiddenLayerCounts.Length; c++) { isDropoutLayer = dropoutLayerOptions.DropoutLayerIndices.Contains(dropoutLayerIndex); int currentLayerCount = hiddenLayerCounts[c]; switch (weightIntializerType) { case WeightIntializerType.RandomGaussianWithNeuronCount: weightBuilder = new RandomGaussianWithNeuronCount(previousLayer.Neurons.Count, 0, random); break; case WeightIntializerType.RandomNormal: weightBuilder = new RandomGaussian(0, 1, random); break; } HiddenLayer hiddenLayer = HiddenLayer.BuildHiddenLayer(weightBuilder, previousLayer, currentLayerCount, isDropoutLayer ? dropoutLayerOptions.ProbabilityOfDropout : 0, random); network.HiddenLayers.Add(hiddenLayer); previousLayer = hiddenLayer; dropoutLayerIndex++; } isDropoutLayer = dropoutLayerOptions.DropoutLayerIndices.Contains(dropoutLayerIndex); switch (weightIntializerType) { case WeightIntializerType.RandomGaussianWithNeuronCount: weightBuilder = new RandomGaussianWithNeuronCount(previousLayer.Neurons.Count, 0, random); break; case WeightIntializerType.RandomNormal: weightBuilder = new RandomGaussian(0, 1, random); break; } network.OutputLayer = OutputLayer.BuildOutputLayer(weightBuilder, (HiddenLayer)previousLayer, outputNeuronCount, isDropoutLayer ? dropoutLayerOptions.ProbabilityOfDropout : 0, random); return(network); }
private Vector3 findSpreadDirection(Vector3 aim) { float spread1 = RandomGaussian.GetGaussian(0.0f, 2.0f, -horizontalSpread / 2.0f, horizontalSpread / 2.0f); float spread2 = RandomGaussian.GetGaussian(0.0f, 2.0f, -verticalSpread / 2.0f, verticalSpread / 2.0f); Vector3 retAim = Quaternion.Euler(spread1, spread2, spread1) * aim; retAim.Normalize(); return(retAim); }
private int[,] GenerateEnzymeArray(int numGroups, int numEnz) { int[,] protVals = new int[numGroups, numEnz]; // healthy baseline, normally distributed int mean = 15; int sigma = 3; RandomGaussian randGaussian = new RandomGaussian(sigma, mean); // disease difference float fractionDiff = .1f; // fraction of total enzyme types that are going to be different int numDiff = Mathf.CeilToInt(Global.sim.limit_enzs * fractionDiff); // number of enzyme types that are different int delta = 1; for (int g = 0; g < numGroups; g++) { int[] ei = Global.RandPerm(numEnz); for (int e = 0; e < numEnz; e++) { int value; if (g == 0) { value = Mathf.Max(0, Mathf.RoundToInt(randGaussian.Get())); } // healthy baseline else if (e < numDiff) { value = protVals[0, ei[e]] + RandSign(delta); } // perturbation else { value = protVals[0, ei[e]]; } // no perturbation protVals[g, ei[e]] = Mathf.Max(0, value); } } return(protVals); }
private float GetRawChangeLength(int min, int length) { // return (int)Math.Round(RandomGaussian.NextGaussian(toMinMax*_meanRange, (float)Math.Sqrt(toMinMax), 0f, toMinMax)); //doubtful about sqrt return(RandomGaussian.NextGaussian(length * _meanRange, (length - min) * 0.2f, min, length)); }