本文整理汇总了C++中NeuralNetwork::getSubgraphConnectedToThisOutput方法的典型用法代码示例。如果您正苦于以下问题:C++ NeuralNetwork::getSubgraphConnectedToThisOutput方法的具体用法?C++ NeuralNetwork::getSubgraphConnectedToThisOutput怎么用?C++ NeuralNetwork::getSubgraphConnectedToThisOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork::getSubgraphConnectedToThisOutput方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractTileFromNetwork
static NeuralNetwork extractTileFromNetwork(const NeuralNetwork& network,
unsigned int outputNeuron)
{
// Get the connected subgraph
auto newNetwork = network.getSubgraphConnectedToThisOutput(outputNeuron);
util::log("NeuronVisualizer")
<< "sliced out tile with shape: " << newNetwork.shapeString() << ".\n";
// Remove all other connections from the final layer
#if 1
size_t block = (outputNeuron % newNetwork.getOutputNeurons()) / newNetwork.getOutputBlockingFactor();
size_t offset = (outputNeuron % newNetwork.getOutputNeurons()) % newNetwork.getOutputBlockingFactor();
auto& outputLayer = newNetwork.back();
assert(block < outputLayer.blocks());
Matrix weights = outputLayer[block].slice(0, offset, outputLayer.getInputBlockingFactor(), 1);
Matrix bias = outputLayer.at_bias(block).slice(0, offset, 1, 1);
outputLayer.resize(1, outputLayer.getInputBlockingFactor(), 1);
outputLayer[0] = weights;
outputLayer.at_bias(0) = bias;
util::log("NeuronVisualizer")
<< " trimmed to: " << newNetwork.shapeString() << ".\n";
#endif
return newNetwork;
}