4using System.Collections.Generic;
 
    8using System.Threading.Tasks;
 
   31            foreach (
Layer<T> layer1 
in m_net.layers)
 
   41                throw new Exception(
"At least one layer in the net must support pre and post processing!");
 
   56        public List<Tuple<double, bool, List<Tuple<string, int, double>>>> 
Search(
PropertySet input, 
int nK, 
double dfThreshold = 0.01, 
int nMax = 80)
 
   58            List<Tuple<double, bool, List<Tuple<string, int, double>>>> rgSequences = 
new List<Tuple<double, bool, List<Tuple<string, int, double>>>>();
 
   59            rgSequences.Add(
new Tuple<
double, 
bool, List<Tuple<string, int, double>>>(0, 
false, 
new List<Tuple<string, int, double>>()));
 
   68            List<Tuple<string, int, double>> rgRes = m_layer.
PostProcessOutput(colTop[0], nK);
 
   69            rgRes = rgRes.Where(p => p.Item3 >= dfThreshold).ToList();
 
   70            List<List<Tuple<string, int, double>>> rgrgRes = 
new List<List<Tuple<string, int, double>>>();
 
   74            while (!bDone && nMax > 0)
 
   76                int nProcessedCount = 0;
 
   78                List<Tuple<double, bool, List<Tuple<string, int, double>>>> rgCandidates = 
new List<Tuple<double, bool, List<Tuple<string, int, double>>>>();
 
   80                for (
int i = 0; i < rgSequences.Count; i++)
 
   82                    if (rgrgRes[i].Count > 0)
 
   84                        for (
int j = 0; j < rgrgRes[i].Count; j++)
 
   86                            if (rgrgRes[i][j].Item1.Length > 0)
 
   88                                double dfScore = rgSequences[i].Item1 - Math.Log(rgrgRes[i][j].Item3);
 
   90                                List<Tuple<string, int, double>> rgSequence1 = 
new List<Tuple<string, int, double>>();
 
   91                                rgSequence1.AddRange(rgSequences[i].Item3);
 
   92                                rgSequence1.Add(rgrgRes[i][j]);
 
   94                                rgCandidates.Add(
new Tuple<
double, 
bool, List<Tuple<string, int, double>>>(dfScore, 
false, rgSequence1));
 
  101                        rgCandidates.Add(
new Tuple<
double, 
bool, List<Tuple<string, int, double>>>(rgSequences[i].Item1, 
true, rgSequences[i].Item3));
 
  105                if (nProcessedCount > 0)
 
  107                    rgSequences = rgCandidates.OrderBy(p => p.Item1).Take(nK).ToList();
 
  108                    rgrgRes = 
new List<List<Tuple<string, int, double>>>();
 
  110                    for (
int i = 0; i < rgSequences.Count; i++)
 
  112                        if (!rgSequences[i].Item2)
 
  114                            rgRes = 
new List<Tuple<string, int, double>>();
 
  118                            m_net.Forward(colBottom, out dfLoss, 
true);
 
  121                            for (
int j = 0; j < rgSequences[i].Item3.Count; j++)
 
  123                                int nIdx = rgSequences[i].Item3[j].Item2;
 
  126                                colTop = m_net.Forward(colBottom, out dfLoss, 
true);
 
  128                                if (j == rgSequences[i].Item3.Count - 1)
 
  130                                    List<Tuple<string, int, double>> rgRes1 = m_layer.
PostProcessOutput(colTop[0], nK);
 
  131                                    rgRes1 = rgRes1.Where(p => p.Item3 >= dfThreshold).ToList();
 
  133                                    for (
int k = 0; k < rgRes1.Count; k++)
 
  135                                        if (rgRes1[k].Item1.Length > 0)
 
  136                                            rgRes.Add(rgRes1[k]);
 
  138                                            Trace.WriteLine(
"EOS");
 
  147                            rgrgRes.Add(
new List<Tuple<string, int, double>>());
 
Specifies a key-value pair of properties.
string GetProperty(string strName, bool bThrowExceptions=true)
Returns a property as a string value.
The BeamSearch uses the softmax output from the network and continually runs the net on each output (...
List< Tuple< double, bool, List< Tuple< string, int, double > > > > Search(PropertySet input, int nK, double dfThreshold=0.01, int nMax=80)
Perform the beam-search.
BeamSearch(Net< T > net)
The constructor.
The BlobCollection contains a list of Blobs.
Connects Layer's together into a direct acrylic graph (DAG) specified by a NetParameter
An interface for the units of computation which can be composed into a Net.
virtual bool SupportsPostProcessing
Should return true when pre PostProcessing methods are overriden.
virtual List< Tuple< string, int, double > > PostProcessOutput(Blob< T > blobSofmtax, int nK=1)
The PostProcessOutput allows derivative data layers to post-process the results, converting them back...
virtual bool SupportsPreProcessing
Should return true when PreProcessing methods are overriden.
virtual BlobCollection< T > PreProcessInput(PropertySet customInput, out int nSeqLen, BlobCollection< T > colBottom=null)
The PreprocessInput allows derivative data layers to convert a property set of input data into the bo...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.common namespace contains common MyCaffe classes.
The MyCaffe.layers namespace contains all layers that have a solidified code base,...
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...