本文整理汇总了C++中LayerDimensions::setNumFilters方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerDimensions::setNumFilters方法的具体用法?C++ LayerDimensions::setNumFilters怎么用?C++ LayerDimensions::setNumFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerDimensions
的用法示例。
在下文中一共展示了LayerDimensions::setNumFilters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST( testforward, test2 ) {
int batchSize = 2;
LayerDimensions dim;
dim.setNumFilters(2).setNumInputPlanes(1).setInputSize(3).setFilterSize(3)
.setPadZeros(false).setBiased(false);
float data[] = { 0, 0, 0,
-0.5f, 0.5f, 0,
0, 0, 0,
0, 0, 0,
0.5f, -0.5f, 0,
0, 0, 0
};
float filter1[] = { 0, 0, 0,
0.300809f, -0.11011f, 0,
0, 0, 0,
0, 0, 0,
0.0570846f, 0.347077f, 0,
0,0,0
};
EasyCL *cl = EasyCL::createForFirstGpuOtherwiseCpu();
float *biases = 0;
Forward *forward = Forward::instanceSpecific( 1, cl, dim );
float *output = new float[forward->getOutputTotalSize(batchSize)];
forward->forward( batchSize, data, filter1, biases, output );
EXPECT_FLOAT_NEAR( -0.5f * 0.300809f -0.5f * 0.11011f, output[0] );
EXPECT_FLOAT_NEAR( -0.5f * 0.0570846f +0.5f * 0.347077f, output[1] );
EXPECT_FLOAT_NEAR( 0.5f * 0.300809f +0.5f * 0.11011f, output[2] );
EXPECT_FLOAT_NEAR( 0.5f * 0.0570846f -0.5f * 0.347077f, output[3] );
delete[] output;
delete forward;
delete cl;
}
示例2: TanhActivation
TEST( testpropagate, test2 ) {
int batchSize = 2;
// int numOutPlanes = 2;
// int numInPlanes = 1;
// int imageSize = 3;
// int filterWidth = 3;
// int padZeros = 0;
LayerDimensions dim;
dim.setNumFilters(2).setNumInputPlanes(1).setInputImageSize(3).setFilterSize(3)
.setPadZeros(false).setBiased(false);
float data[] = { 0, 0, 0,
-0.5f, 0.5f, 0,
0, 0, 0,
0, 0, 0,
0.5f, -0.5f, 0,
0, 0, 0
};
float filter1[] = { 0, 0, 0,
0.300809f, -0.11011f, 0,
0, 0, 0,
0, 0, 0,
0.0570846f, 0.347077f, 0,
0,0,0
};
OpenCLHelper *cl = OpenCLHelper::createForFirstGpuOtherwiseCpu();
// float *results = new float[512];
float *biases = 0;
// CLWrapper *dataWrapper = cl->wrap( batchSize * 9, data );
// CLWrapper *weightsWrapper = cl->wrap( numOutPlanes * 9, filter1 );
// CLWrapper *resultsWrapper = cl->wrap( 512, results );
// dataWrapper->copyToDevice();
// weightsWrapper->copyToDevice();
// CLKernel *convolve = cl->buildKernel( "../cl/propagate1.cl", "convolve_imagecubes_float2", "-D TANH" );
// CLKernel *tanh = cl->buildKernel( "ClConvolve.cl", "byelement_tanh" );
// for( int it = 0; it < 100; it ++ ) {
Propagate *propagate = Propagate::instanceSpecific( 1, cl, dim, new TanhActivation() );
float *results = propagate->propagate( batchSize, data, filter1, biases );
// convolve->in(batchSize)->in( numInPlanes )->in( numOutPlanes )->in( imageSize )->in( filterWidth )
// ->in( padZeros );
// convolve->input( dataWrapper );
// convolve->input( weightsWrapper);
// convolve->output( resultsWrapper );
// int globalSize = batchSize * numOutPlanes * imageSize * imageSize;
// int workgroupsize = cl->getMaxWorkgroupSize();
// globalSize = ( ( globalSize + workgroupsize - 1 ) / workgroupsize ) * workgroupsize;
//// cout << " globalsize " << globalSize << " workgroupsize " << workgroupsize << endl;
// convolve->run_1d( globalSize, workgroupsize );
// resultsWrapper->copyToHost();
// for( int i = 0; i < 20; i++ ) {
// cout << "results[" << i << "]=" << results[i] << endl;
// }
EXPECT_FLOAT_NEAR( -0.202616f, results[0] );
EXPECT_FLOAT_NEAR( 0.143989f, results[1] );
EXPECT_FLOAT_NEAR( 0.202616f, results[2] );
EXPECT_FLOAT_NEAR( -0.143989f, results[3] );
// }
// cout << "test2 ok" << endl;
delete propagate;
// delete convolve;
// delete resultsWrapper;
// delete weightsWrapper;
// delete dataWrapper;
delete[] results;
delete cl;
}