2using System.Collections.Generic;
20 List<string> m_rgstrFileNames =
new List<string>();
22 int m_nCurrentFile = 0;
23 int m_nCurrentRow = 0;
25 List<int> m_rgDataPermutation =
new List<int>();
26 List<int> m_rgFilePermutation =
new List<int>();
69 for (
int i = 0; i < nTopCount; i++)
74 if (m_colHdfBlobs.
Count < nTopCount)
77 m_colHdfBlobs.
Add(blob);
81 blob = m_colHdfBlobs[i];
92 m_log.
CHECK_GE(m_colHdfBlobs[0].num_axes, 1,
"Input must have at least 1 axis.");
93 int nNum = m_colHdfBlobs[0].shape(0);
95 for (
int i = 1; i < nTopCount; i++)
97 m_log.
CHECK_EQ(m_colHdfBlobs[i].shape(0), nNum,
"The 'num' on all blobs must be equal.");
101 m_rgDataPermutation =
new List<int>();
102 for (
int i = 0; i < nNum; i++)
104 m_rgDataPermutation.Add(i);
111 m_log.
WriteLine(
"Successfully loaded " + nNum.ToString() +
" rows (shuffled).");
115 m_log.
WriteLine(
"Successfully loaded " + nNum.ToString() +
" rows.");
149 m_nNumFiles = m_rgstrFileNames.Count;
152 m_log.
WriteLine(
"Number of HDF5 files: " + m_nNumFiles.ToString());
156 m_rgFilePermutation =
new List<int>();
157 for (
int i = 0; i < m_nNumFiles; i++)
159 m_rgFilePermutation.Add(i);
173 List<int> rgTopShape =
new List<int>();
175 for (
int i = 0; i < nTopSize; i++)
177 rgTopShape =
Utility.Clone<
int>(m_colHdfBlobs[i].shape());
178 rgTopShape[0] = nBatchSize;
204 if (m_nCurrentRow == m_colHdfBlobs[0].shape(0))
210 if (m_nCurrentFile == m_nNumFiles)
251 for (
int i = 0; i < nBatch; i++)
258 int nDataDim = colTop[j].count() / colTop[j].shape(0);
259 int nSrcIdx = m_rgDataPermutation[m_nCurrentRow] * nDataDim;
260 int nDstIdx = i * nDataDim;
261 m_cuda.copy(nDataDim, m_colHdfBlobs[j].gpu_data, colTop[j].mutable_gpu_data, nSrcIdx, nDstIdx);
The Log class provides general output in text form.
void WriteLine(string str, bool bOverrideEnabled=false, bool bHeader=false, bool bError=false, bool bDisable=false)
Write a line of output.
void CHECK_EQ(double df1, double df2, string str)
Test whether one number is equal to another.
void CHECK_GE(double df1, double df2, string str)
Test whether one number is greater than or equal to another.
The Utility class provides general utility funtions.
static List< int > RandomShuffle(List< int > rg, int? nSeed=null)
Randomly shuffle the entries in the specified list.
static List< string > LoadTextLines(string strFile, Log log=null, bool bPrependPath=true)
Load each line of a text file and return the contents as a list.
The BlobCollection contains a list of Blobs.
void Dispose()
Release all resource used by the collection and its Blobs.
void Add(Blob< T > b)
Add a new Blob to the collection.
int Count
Returns the number of items in the collection.
void Reshape(int[] rgShape)
Reshapes all blobs in the collection to the given shape.
The Blob is the main holder of data that moves through the Layers of the Net.
string Name
Get/set the name of the Blob.
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
An interface for the units of computation which can be composed into a Net.
Log m_log
Specifies the Log for output.
LayerParameter m_param
Specifies the LayerParameter describing the Layer.
CudaDnn< T > m_cuda
Specifies the CudaDnn connection to Cuda.
LayerParameter.LayerType m_type
Specifies the Layer type.
The HDF5DataLayer loads data from files in the HDF5 data format. This layer is initialized with the M...
HDF5DataLayer(CudaDnn< T > cuda, Log log, LayerParameter p)
The HDF5DataLayer constructor.
override void backward(BlobCollection< T > colTop, List< bool > rgbPropagateDown, BlobCollection< T > colBottom)
Not implemented - data Layers do not perform backward..
override void dispose()
Release all internal blobs.
override int ExactNumBottomBlobs
Returns 0 for data layers have no bottom (input) Blobs.
override void Reshape(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Data layers have no bottoms, so reshaping is trivial.
override void LayerSetUp(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Setup the layer.
override int MinTopBlobs
Returns the minimum number of required top (output) Blobs: data
virtual void LoadHDF5FileData(string strFile)
Load the data from an HDF5 file.
bool Skip()
Called to see if the current data item should be skipped.
override void forward(BlobCollection< T > colBottom, BlobCollection< T > colTop)
Run the Forward computation, which fills the data into the top (output) Blobs.
void Next()
Advanced to the next data item.
The HDF5 object provides HDF5 dataset support to the HDF5DataLayer.
void Dispose()
Release all resources uses.
void load_nd_dataset(Blob< T > blob, string strDatasetName, bool bReshape=false, int nMinDim=1, int nMaxDim=int.MaxValue, H5GroupId id=null, bool bAllowSingleItems=false)
Creates a new dataset from an HDF5 data file.
string source
Specifies the data source.
virtual uint batch_size
Specifies the batch size.
bool shuffle
Specifies the whether to shuffle the data or now.
Specifies the base parameter for all layers.
List< string > top
Specifies the active top connections (in the bottom, out the top)
int solver_count
Returns the number of Solvers participating in a multi-GPU session for which the Solver using this La...
int solver_rank
Returns the SolverRank of the Solver using this LayerParameter (if any).
HDF5DataParameter hdf5_data_param
Returns the parameter set when initialized with LayerType.HDF5_DATA
TransformationParameter transform_param
Returns the parameter set when initialized with LayerType.TRANSFORM
Phase phase
Specifies the Phase for which this LayerParameter is run.
LayerType
Specifies the layer type.
override string ToString()
Returns a string representation of the LayerParameter.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Phase
Defines the Phase under which to run a Net.
The MyCaffe.common namespace contains common MyCaffe classes.
The MyCaffe.fillers namespace contains all fillers including the Filler class.
The MyCaffe.layers.hdf5 namespace contains all HDF5 related layers.
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...