MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
DataItem.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace MyCaffe.db.stream
8{
12 public class DataItem
13 {
14 double[] m_rgdfData;
15 int m_nFilled;
16 int m_nFull;
17
22 public DataItem(int nFieldCount)
23 {
24 m_rgdfData = new double[nFieldCount];
25 m_nFilled = 0;
26 m_nFull = ((int)Math.Pow(2, nFieldCount)) - 1;
27 }
28
37 public int Add(int nFieldIdx, int nItemIdx, double[] rg, int nFieldCount)
38 {
39 int nStart = (nFieldIdx == 0) ? 0 : 1;
40
41 for (int j = nStart; j < nFieldCount; j++)
42 {
43 int nIdx = (nItemIdx * nFieldCount) + j;
44 Add(nFieldIdx, rg[nIdx]);
45 nFieldIdx++;
46 }
47
48 return nFieldIdx;
49 }
50
57 public bool Add(int nFieldIdx, double df)
58 {
59 m_rgdfData[nFieldIdx] = df;
60 m_nFilled |= (0x0001 << nFieldIdx);
61
62 if (m_nFilled == m_nFull)
63 return true;
64
65 return false;
66 }
67
72 public double[] GetData()
73 {
74 return m_rgdfData;
75 }
76
80 public void Reset()
81 {
82 Array.Clear(m_rgdfData, 0, m_rgdfData.Length);
83 m_nFilled = 0;
84 }
85 }
86}
The DataItem manages one synchronized data item where the first element is the sync field.
Definition: DataItem.cs:13
int Add(int nFieldIdx, int nItemIdx, double[] rg, int nFieldCount)
Adds a new set of raw data to the synchronized data.
Definition: DataItem.cs:37
bool Add(int nFieldIdx, double df)
Add a new data item at a specified field index.
Definition: DataItem.cs:57
DataItem(int nFieldCount)
The constructor.
Definition: DataItem.cs:22
void Reset()
Clears the data fields and the filled status.
Definition: DataItem.cs:80
double[] GetData()
Returns the synchronized data fields.
Definition: DataItem.cs:72
The MyCaffe.db.stream namespace contains all data streaming related classes.