コード例 #1
0
ファイル: Dataset.cs プロジェクト: miltonluaces/mobile
        public void Read(string fileName)
        {
            StreamReader sr = new StreamReader(fileName);
            //public void Read(Stream stream) {
            //StreamReader sr = new StreamReader (stream);
            string     set = "", subset = "", line = "";
            DataSubset dataSubset;

            string[]     tokens, dataTokens;
            List <float> data;
            string       fileLine;

            while ((fileLine = sr.ReadLine()) != null)
            {
                tokens = fileLine.Split(sepTab);
                if (tokens.Length <= 1)
                {
                    continue;
                }
                if (tokens [0] == "Set")
                {
                    set = tokens [1];
                }
                else if (tokens [0] == "Subset")
                {
                    subset = tokens [1];
                }
                else if (tokens [0] == "Line")
                {
                    line       = tokens[1];
                    dataTokens = tokens[2].Split(sepSpc);
                    data       = new List <float>();
                    for (int i = 0; i < dataTokens.Length; i++)
                    {
                        if (dataTokens[i].Trim() == "")
                        {
                            continue;
                        }
                        data.Add(Convert.ToSingle(dataTokens[i]));
                    }
                    string key = GetKey(set, subset);
                    if (!dataSubsets.ContainsKey(key))
                    {
                        dataSubset = new DataSubset(set, subset);
                        dataSubsets.Add(key, dataSubset);
                    }
                    dataSubsets[key].AddLine(line, data);
                }
                else
                {
                    //do  nothing
                }
            }
        }
コード例 #2
0
 protected override TRow CreateNewRow(DataSubset <TRow, TItem> subset, int largeIndex)
 {
     // TODO: replace with dependency injection stuff if we can.
     // get this via asking for an IGridRow<TItem>, and move it back to the controllers project
     // create via IDataSubsetLoader<TRow, TItem>
     return(new RomByteDataGridRow
     {
         ByteEntry = subset.Items[largeIndex],
         Data = Data,
         ParentView = View as IBytesGridViewer <ByteEntry>,
     } as TRow);
 }
コード例 #3
0
 private void DataSet_KeyChanged(object sender, KeyChangedEventArgs e)
 {
     DataSubset.ForeignKeyValue = e.NewKey;
     DataSubset.Fill();
 }
コード例 #4
0
 /// <summary>
 /// Inheritors should use this method to put the current sample in the
 /// given mini-batch at the given position.
 /// </summary>
 /// <param name="batch">The mini-batch being constructed.</param>
 /// <param name="positionInMiniBatch">The position in mini-batch where the current sample must be put.</param>
 protected override void PutCurrentSampleInMiniBatch(DataSubset<TInput, TOutput> batch, int positionInMiniBatch)
 {
     base.PutCurrentSampleInMiniBatch(batch, positionInMiniBatch);
     batch.Outputs[positionInMiniBatch] = shuffledOutputs[CurrentSample];
 }