Example #1
0
        /// <summary>
        /// Open any datasets that were used by the input layer.
        /// </summary>
        private void OpenDataSet()
        {
            // clear out any data sets already there
            this.readDataSet.Clear();
            this.dataSetFieldMap.Clear();
            this.dataSetIteratorMap.Clear();

            // only add each iterator once
            IDictionary <INeuralDataSet, NeuralDataFieldHolder> uniqueSets = new Dictionary <INeuralDataSet, NeuralDataFieldHolder>();

            // find the unique files
            foreach (IInputField field in this.inputFields)
            {
                if (field is InputFieldNeuralDataSet)
                {
                    InputFieldNeuralDataSet dataSetField = (InputFieldNeuralDataSet)field;
                    INeuralDataSet          dataSet      = dataSetField.NeuralDataSet;
                    if (!uniqueSets.ContainsKey(dataSet))
                    {
                        IEnumerator <INeuralDataPair> iterator = dataSet
                                                                 .GetEnumerator();
                        NeuralDataFieldHolder holder = new NeuralDataFieldHolder(
                            iterator, dataSetField);
                        uniqueSets[dataSet] = holder;
                        this.readDataSet.Add(iterator);
                    }

                    NeuralDataFieldHolder holder2 = uniqueSets[dataSet];

                    this.dataSetFieldMap[dataSetField] = holder2;
                    this.dataSetIteratorMap[holder2.GetEnumerator()] = holder2;
                }
            }
        }
Example #2
0
        /// <summary>
        /// Called internally to advance to the next row.
        /// </summary>
        /// <returns>True if there are more rows to reed.</returns>
        private bool Next()
        {
            // see if any of the CSV readers want to stop
            foreach (ReadCSV csv in this.readCSV)
            {
                if (!csv.Next())
                {
                    return(false);
                }
            }

            // see if any of the data sets want to stop
            foreach (IEnumerator <INeuralDataPair> iterator in this.readDataSet)
            {
                if (!iterator.MoveNext())
                {
                    return(false);
                }
                NeuralDataFieldHolder holder = this.dataSetIteratorMap
                                               [iterator];
                INeuralDataPair pair = iterator.Current;
                holder.Pair = pair;
            }

            // see if any of the arrays want to stop
            foreach (IInputField field in this.inputFields)
            {
                if (field is IHasFixedLength)
                {
                    IHasFixedLength fl = (IHasFixedLength)field;
                    if ((this.currentIndex + 1) >= fl.Length)
                    {
                        return(false);
                    }
                }
            }

            this.currentIndex++;

            return(true);
        }
Example #3
0
        /// <summary>
        /// Called internally to obtain the current value for an input field.
        /// </summary>
        /// <param name="field">The input field to determine.</param>
        /// <param name="index">The current index.</param>
        /// <returns>The value for this input field.</returns>
        private double DetermineInputFieldValue(IInputField field,
                                                int index)
        {
            double result = 0;

            if (field is InputFieldCSV)
            {
                InputFieldCSV fieldCSV = (InputFieldCSV)field;
                ReadCSV       csv      = this.csvMap[field];
                result = csv.GetDouble(fieldCSV.Offset);
            }
            else if (field is InputFieldNeuralDataSet)
            {
                InputFieldNeuralDataSet neuralField = (InputFieldNeuralDataSet)field;
                NeuralDataFieldHolder   holder      = this.dataSetFieldMap
                                                      [field];
                INeuralDataPair pair   = holder.Pair;
                int             offset = neuralField.Offset;
                if (offset < pair.Input.Count)
                {
                    result = pair.Input[offset];
                }
                else
                {
                    offset -= pair.Input.Count;
                    result  = pair.Ideal[offset];
                }
            }
            else
            {
                result = field.GetValue(index);
            }

            field.CurrentValue = result;
            return(result);
        }