MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
RandomMemoryCollection.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using MyCaffe.basecode;
7
9{
14 {
15 MemoryCollection m_mem;
16 double[] m_rgWts = null;
17 int[] m_rgIdx = null;
18
23 public RandomMemoryCollection(int nMax)
24 {
25 m_mem = new MemoryCollection(nMax);
26 }
27
31 public void CleanUp()
32 {
33 }
34
38 public int Count
39 {
40 get { return m_mem.Count; }
41 }
42
47 public void Add(MemoryItem m)
48 {
49 m_mem.Add(m);
50 }
51
59 public MemoryCollection GetSamples(CryptoRandom random, int nCount, double dfBeta)
60 {
61 if (m_rgWts == null || m_rgWts.Length != nCount)
62 {
63 m_rgWts = new double[nCount];
64 for (int i = 0; i < m_rgWts.Length; i++)
65 {
66 m_rgWts[i] = 1.0;
67 }
68 }
69
70 if (m_rgIdx == null || m_rgIdx.Length != nCount)
71 {
72 m_rgIdx = new int[nCount];
73 }
74
75 MemoryCollection mem = m_mem.GetRandomSamples(random, nCount);
76
77 mem.Indexes = m_rgIdx;
78 mem.Priorities = m_rgWts;
79
80 return mem;
81 }
82
87 public void Update(MemoryCollection rgSamples)
88 {
89 }
90 }
91}
The CryptoRandom is a random number generator that can use either the standard .Net Random objec or t...
Definition: CryptoRandom.cs:14
The memory collection stores a set of memory items.
MemoryCollection GetRandomSamples(CryptoRandom random, int nCount)
Retrieves a random sample of items from the list.
double[] Priorities
Get/set the priorities associated with the collection (if any).
int Count
Returns the current count of items.
int[] Indexes
Get/set the indexes associated with the collection (if any).
virtual void Add(MemoryItem item)
Adds a new memory item to the array of items and if at capacity, removes an item.
The MemoryItem stores the information about a given cycle.
The RandomMemoryCollection is used to randomly sample the collection of items.
void Add(MemoryItem m)
Add a new item to the collection.
void CleanUp()
Complete any final processing.
void Update(MemoryCollection rgSamples)
Update - does nothing.
int Count
Returns the number of items in the collection.
MemoryCollection GetSamples(CryptoRandom random, int nCount, double dfBeta)
Return a batch of items.
The IMemoryCollection interface is implemented by all memory collection types.
Definition: Interfaces.cs:37
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12