MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
WeightInfo.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6
7namespace MyCaffe.common
8{
14 public class WeightInfo<T>
15 {
16 Dictionary<string, Tuple<List<int>, BLOB_TYPE>> m_rgBlobInfo = new Dictionary<string, Tuple<List<int>, BLOB_TYPE>>();
17 BlobName m_names = new BlobName();
18
22 public WeightInfo()
23 {
24 }
25
32 public void AddBlob(string strName, List<int> rgShape, BLOB_TYPE type)
33 {
34 strName = m_names.GetName(strName);
35 m_rgBlobInfo.Add(strName, new Tuple<List<int>, BLOB_TYPE>(rgShape, type));
36 }
37
42 public void AddBlob(Blob<T> b)
43 {
44 string strName = m_names.GetName(b.Name);
45 m_rgBlobInfo.Add(strName, new Tuple<List<int>, BLOB_TYPE>(b.shape(), b.type));
46 }
47
52 public Dictionary<string, Tuple<List<int>, BLOB_TYPE>> Blobs
53 {
54 get { return m_rgBlobInfo; }
55 }
56 }
57
61 public class BlobName
62 {
63 Dictionary<string, int> m_rgNames = new Dictionary<string, int>();
64
68 public BlobName()
69 {
70 }
71
77 public string GetName(string strName)
78 {
79 if (string.IsNullOrEmpty(strName))
80 strName = "b";
81
82 if (!m_rgNames.ContainsKey(strName))
83 {
84 m_rgNames.Add(strName, 1);
85 }
86 else
87 {
88 m_rgNames[strName]++;
89 strName = strName + m_rgNames[strName].ToString();
90 }
91
92 return strName;
93 }
94 }
95}
The Blob is the main holder of data that moves through the Layers of the Net.
Definition: Blob.cs:25
BLOB_TYPE type
Returns the BLOB_TYPE of the Blob.
Definition: Blob.cs:2761
List< int > shape()
Returns an array where each element contains the shape of an axis of the Blob.
Definition: Blob.cs:684
string Name
Get/set the name of the Blob.
Definition: Blob.cs:2184
The BlobName class is used to build unique blob names.
Definition: WeightInfo.cs:62
string GetName(string strName)
Returns a unique blob name.
Definition: WeightInfo.cs:77
BlobName()
The constructor.
Definition: WeightInfo.cs:68
The WeightInfo class describes the weights of a given weight set including the blob names and sizes o...
Definition: WeightInfo.cs:15
void AddBlob(string strName, List< int > rgShape, BLOB_TYPE type)
Add a blob name and shape to the WeightInfo.
Definition: WeightInfo.cs:32
WeightInfo()
The constructor.
Definition: WeightInfo.cs:22
Dictionary< string, Tuple< List< int >, BLOB_TYPE > > Blobs
Returns the list of blob information describing the weights. Each entry within the Dictionary returne...
Definition: WeightInfo.cs:53
void AddBlob(Blob< T > b)
Add a blob name and shape to the WeightInfo.
Definition: WeightInfo.cs:42
The MyCaffe.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
BLOB_TYPE
Defines the tpe of data held by a given Blob.
Definition: Interfaces.cs:62