예제 #1
0
파일: RAE.cpp 프로젝트: zerkh/RAE
lbfgsfloatval_t RAE::decay()
{
	lbfgsfloatval_t val = 0;

	for(int row = 0; row < weights1.rows(); row++)
	{
		for(int col = 0; col < weights1.cols(); col++)
		{
			val += pow(weights1(row, col), 2)/2;
			val += pow(weights2(col, row), 2)/2;
		}
	}

	for(int col = 0; col < weights_b1.cols(); col++)
	{
		val += pow(weights_b1(0, col), 2)/2;
	}

	for(int col = 0; col < weights_b2.cols(); col++)
	{
		val += pow(weights_b2(0, col), 2)/2;
	}

	return val;
}
예제 #2
0
GPU_PERF_TEST(BlendLinear, cv::gpu::DeviceInfo, cv::Size, MatType)
{
    cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
    cv::gpu::setDevice(devInfo.deviceID());

    cv::Size size = GET_PARAM(1);
    int type = GET_PARAM(2);

    cv::Mat img1_host(size, type);
    fill(img1_host, 0, 255);

    cv::Mat img2_host(size, type);
    fill(img2_host, 0, 255);

    cv::gpu::GpuMat img1(img1_host);
    cv::gpu::GpuMat img2(img2_host);
    cv::gpu::GpuMat weights1(size, CV_32FC1, cv::Scalar::all(0.5));
    cv::gpu::GpuMat weights2(size, CV_32FC1, cv::Scalar::all(0.5));
    cv::gpu::GpuMat dst;

    cv::gpu::blendLinear(img1, img2, weights1, weights2, dst);

    TEST_CYCLE()
    {
        cv::gpu::blendLinear(img1, img2, weights1, weights2, dst);
    }
}
예제 #3
0
OCL_PERF_TEST_P(BlendLinearFixture, BlendLinear, ::testing::Combine(OCL_TEST_SIZES, OCL_TEST_TYPES_134))
{
    Size_MatType_t params = GetParam();
    const Size srcSize = get<0>(params);
    const int srcType = get<1>(params);
    const double eps = CV_MAT_DEPTH(srcType) <= CV_32S ? 1.0 : 0.2;

    checkDeviceMaxMemoryAllocSize(srcSize, srcType);

    UMat src1(srcSize, srcType), src2(srcSize, srcType), dst(srcSize, srcType);
    UMat weights1(srcSize, CV_32FC1), weights2(srcSize, CV_32FC1);

    declare.in(src1, src2, WARMUP_RNG).in(weights1, weights2, WARMUP_READ).out(dst);
    randu(weights1, 0, 1);
    randu(weights2, 0, 1);

    OCL_TEST_CYCLE() cv::blendLinear(src1, src2, weights1, weights2, dst);

    SANITY_CHECK(dst, eps);
}
예제 #4
0
파일: adtree.cpp 프로젝트: drmcwilli/WFUBMC
/**
 * score_categorical
 * 
 * Perform scoring for a given precondition and variable.
 * 
 * @param int r: Precondition in use
 * @param long i: SNP in use
 * @param Condition::comparison &: Type of comparison returned.
 * @param short s: Optimal split point.
 */
double ADTree::score_categorical(int r, long i, Condition::comparison &c, short &s){
	
	double *ret_score = new double[9];
	double z1, z2, ret;
	weights2(ret_score,r,i); // run both tests.
	z2 = 2.0*(sqrt(ret_score[0]*ret_score[1]) + sqrt(ret_score[2]*ret_score[3])) + ret_score[8];
	z1 = 2.0*(sqrt(ret_score[4]*ret_score[5]) + sqrt(ret_score[6]*ret_score[7])) + ret_score[8];
	
	if(z1 < z2){
		ret = z1;
		c = Condition::GE;
		s = 4;
	}else{ // so default to z2.
		ret = z2;
		c = Condition::GE;
		s = 2;
	}
	
	delete[] ret_score;
	return ret;
}
예제 #5
0
파일: RAE.cpp 프로젝트: zerkh/RAE
void RAE::loadWeights(Parameter* para)
{
	string filename;

	if(RAEType == SL)
	{
		filename = para->getPara("srcRAEWeightsLogFile");
	}
	else
	{
		filename = para->getPara("tgtRAEWeightsLogFile");
	}

	ifstream in(filename.c_str(), ios::in);

	bool rae_w1 = false;
	bool rae_b1 = false;
	bool rae_w2 = false;
	bool rae_b2 = false;
	int row = 0;

	string line;
	while(getline(in, line))
	{
		if(line.find("W1") == 0)
		{
			row = 0;
			rae_w1 = true;
			continue;
		}
		if(line.find("W2") == 0)
		{
			row = 0;
			rae_b1 = false;
			rae_w2 = true;
			continue;
		}
		if(line.find("B1") == 0)
		{
			row = 0;
			rae_w1 = false;
			rae_b1 = true;
			continue;
		}
		if(line.find("B2") == 0)
		{
			row = 0;
			rae_w2 = false;
			rae_b2 = true;
			continue;
		}

		if(rae_w1)
		{
			stringstream ss(line);

			for(int col = 0; col < weights1.cols(); col++)
			{
				ss >> weights1(row, col);
			}
		}
		if(rae_w2)
		{
			stringstream ss(line);

			for(int col = 0; col < weights2.cols(); col++)
			{
				ss >> weights2(row, col);
			}
		}
		if(rae_b2)
		{
			stringstream ss(line);

			for(int col = 0; col < weights_b2.cols(); col++)
			{
				ss >> weights_b2(row, col);
			}
		}
		if(rae_b1)
		{
			stringstream ss(line);

			for(int col = 0; col < weights_b1.cols(); col++)
			{
				ss >> weights_b1(row, col);
			}
		}

		row++;
	}
}