/// <summary> /// Creates a new feature. /// </summary> /// <returns>An object which implements <see cref="T:IFeature" /></returns> public IFeature <T, float[]> Create() { int index1 = ThreadsafeRandom.Next(0, _length); int index2 = ThreadsafeRandom.Next(0, _length); while (index2 == index1) { index2 = ThreadsafeRandom.Next(0, _length); } switch (_combo) { case BinaryCombination.Add: return(new Add(index1, index2, _modifier)); case BinaryCombination.Divide: return(new Divide(index1, index2, _modifier)); case BinaryCombination.Log: return(new Log(index1, index2, _modifier)); case BinaryCombination.Multiply: return(new Multiply(index1, index2, _modifier)); case BinaryCombination.Subtract: default: return(new Subtract(index1, index2, _modifier)); } }
public IEnumerable <int> Receive(int minMessageCount, int maxMessageCount) { var returnedMessages = ThreadsafeRandom.Next(minMessageCount, maxMessageCount + 1); for (var i = 0; i < returnedMessages; i++) { yield return(i); } }
public static string CreateAlphanumeric(int length) { var buffer = new char[length]; for (var i = 0; i < length; i++) { buffer[i] = _alphanumeric[ThreadsafeRandom.Next(_alphanumeric.Length)]; } return(new string(buffer)); }
/// <summary> /// Creates a new feature. /// </summary> /// <returns>An object which implements <see cref="T:IFeature" /></returns> public IFeature <ImageDataPoint <float>, float[]> Create() { int row, column; row = ThreadsafeRandom.Next(-_boxRows, _boxRows); column = ThreadsafeRandom.Next(-_boxColumns, _boxColumns); int channel = ThreadsafeRandom.Next(0, _numChannels); return(new UnaryFeature(row, column, channel, _modifier)); }
/// <summary> /// Creates a new feature. /// </summary> /// <returns>An object which implements <see cref="T:IFeature" /></returns> public IFeature <ImageDataPoint <float>, float[]> Create() { int row = ThreadsafeRandom.Next(-BoxSize, BoxSize); int column = ThreadsafeRandom.Next(-BoxSize, BoxSize); int rows = ThreadsafeRandom.Next(1, MaxRows); int columns = ThreadsafeRandom.Next(1, MaxColumns); int channel = ThreadsafeRandom.Next(ChannelCount); return(new RectangleFeature(new Rectangle { R = row, C = column, Rows = rows, Columns = columns }, channel)); }
/// <summary> /// Creates a new part feature. /// </summary> /// <returns>The part feature</returns> public IFeature <ImageDataPoint <float>, float[]> Create() { Part[] parts = new Part[_numParts]; for (int i = 0; i < _numParts; i++) { parts[i] = new Part( ThreadsafeRandom.Next(-_boxSize, _boxSize), ThreadsafeRandom.Next(-_boxSize, _boxSize), ThreadsafeRandom.Next(0, _numChannels), 1f - ThreadsafeRandom.NextFloat(2) ); } return(new PartFeature(parts)); }
private short getLabel(short label, LabelSet labels) { switch (_supervisionMode) { case SupervisionMode.Full: return(label); case SupervisionMode.Part: return(labels.SelectRandom()); case SupervisionMode.None: return((short)ThreadsafeRandom.Next(20)); } return(0); }
/// <summary> /// Creates a new feature. /// </summary> /// <returns>An object which implements <see cref="T:IFeature" /></returns> public IFeature <T, float[]> Create() { int index; if (_random) { index = ThreadsafeRandom.Next(0, _length); } else { index = _currentIndex++; if (_currentIndex == _length) { _currentIndex = 0; } } return(new UnaryFeature(index, _modifier)); }
/// <summary> /// Creates a new feature. /// </summary> /// <returns>An object which implements <see cref="T:IFeature" /></returns> public IFeature <ImageDataPoint <float>, float[]> Create() { int index = ThreadsafeRandom.Next(0, HaarFeatures.FEATURES.Length); Rectangle[] rectangles = HaarFeatures.FEATURES[index]; int[] channels = new int[rectangles.Length]; if (_mixChannels) { for (int i = 0; i < channels.Length; i++) { channels[i] = ThreadsafeRandom.Next(0, _numChannels); } } else { int channel = ThreadsafeRandom.Next(0, _numChannels); for (int i = 0; i < channels.Length; i++) { channels[i] = channel; } } return(new HaarFeature(HaarFeatures.FEATURES[index], channels)); }
/// <summary> /// Creates a new feature. /// </summary> /// <returns>An object which implements <see cref="T:IFeature" /></returns> public IFeature <ImageDataPoint <float>, float[]> Create() { int row1, row2, column1, column2, channel1, channel2; row1 = randomRow(); row2 = randomRow(); column1 = randomColumn(); column2 = randomColumn(); channel1 = ThreadsafeRandom.Next(0, _numChannels); if (_mixChannels) { channel2 = ThreadsafeRandom.Next(0, _numChannels); } else { channel2 = channel1; } switch (_combo) { case BinaryCombination.Add: return(new Add(row1, column1, channel1, row2, column2, channel2, _modifier)); case BinaryCombination.Divide: return(new Divide(row1, column1, channel1, row2, column2, channel2, _modifier)); case BinaryCombination.Log: return(new Log(row1, column1, channel1, row2, column2, channel2, _modifier)); case BinaryCombination.Multiply: return(new Multiply(row1, column1, channel1, row2, column2, channel2, _modifier)); case BinaryCombination.Subtract: default: return(new Subtract(row1, column1, channel1, row2, column2, channel2, _modifier)); } }
private int randomColumn() { return(ThreadsafeRandom.Next(-_boxColumns, _boxColumns)); }
private int randomRow() { return(ThreadsafeRandom.Next(-_boxRows, _boxRows)); }