本文整理汇总了C++中NeuralNetwork::addLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ NeuralNetwork::addLayer方法的具体用法?C++ NeuralNetwork::addLayer怎么用?C++ NeuralNetwork::addLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork::addLayer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNeuralNetwork
static NeuralNetwork createNeuralNetwork(size_t xPixels, size_t yPixels,
size_t colors, std::default_random_engine& engine)
{
NeuralNetwork network;
// 5x5 convolutional layer
network.addLayer(FeedForwardLayer(xPixels, yPixels * colors, yPixels * colors));
// 2x2 pooling layer
//network.addLayer(Layer(1, xPixels, xPixels));
// final prediction layer
network.addLayer(FeedForwardLayer(1, network.getOutputCount(), 1));
network.initializeRandomly(engine);
return network;
}
示例2: createModel
static void createModel(ClassificationModel& model, const Parameters& parameters,
std::default_random_engine& engine)
{
NeuralNetwork featureSelector;
size_t totalPixels = parameters.xPixels * parameters.yPixels * parameters.colors;
// derive parameters from image dimensions
const size_t blockSize = std::min(parameters.xPixels, parameters.blockX) *
std::min(parameters.yPixels, parameters.blockY) * parameters.colors;
const size_t blocks = totalPixels / blockSize;
const size_t blockStep = blockSize / parameters.blockStep;
size_t reductionFactor = 4;
// convolutional layer
featureSelector.addLayer(Layer(blocks, blockSize, blockSize / reductionFactor, blockStep));
// pooling layer
featureSelector.addLayer(
Layer(1,
blocks * featureSelector.back().getOutputBlockingFactor(),
blocks * featureSelector.back().getOutputBlockingFactor()));
// contrast normalization
//featureSelector.addLayer(Layer(featureSelector.back().blocks(),
// featureSelector.back().getOutputBlockingFactor(),
// featureSelector.back().getOutputBlockingFactor()));
featureSelector.initializeRandomly(engine);
minerva::util::log("TestFirstLayerFeatures")
<< "Building feature selector network with "
<< featureSelector.getOutputCount() << " output neurons\n";
featureSelector.setUseSparseCostFunction(true);
model.setNeuralNetwork("FeatureSelector", featureSelector);
}
示例3: NNDecider
NNDecider( vector< Digit > trainingSet )
: nn(64)
{
nn.addLayer(10);
for(int i = 0; i < 10; i++)
{
for(int j = -1; j < 64; j++)
{
nn.addConnection(0, i, j, 0);
}
}
int N = 10;
while(N--)
{
for(int i = 0; i < trainingSet.size(); i++)
{
learnProbColorGivenN(trainingSet[i]);
}
}
}