예제 #1
0
파일: kernel.cpp 프로젝트: calebbuahin/MRVM
af::array Kernel::calculateHomogeneousPolynomialKernel(const af::array& x1, const af::array& x2)
{
  int rowX1 = x1.dims(0);

  double eta = 1/(m_lengthScale*m_lengthScale);

  af::array temp = af::pow(eta * af::matmul(x1, x2.T()) , m_polynomailPower);

  return m_useBias ? af::join(1, af::constant(1.0,rowX1,1),temp) : temp;
}
예제 #2
0
파일: kernel.cpp 프로젝트: calebbuahin/MRVM
af::array Kernel::distanceSquared(const af::array& x , const af::array& y)
{
  int nx = x.dims(0);
  int ny = y.dims(0);

  af::array arg1 =  af::matmul(af::sum(af::pow(x,2.0),1), af::constant(1.0,1,ny));
  af::array arg2 =  af::matmul(af::constant(1.0,nx,1), af::sum(af::pow(y,2.0),1).T());
  af::array arg3 =  2.0 * (af::matmul(x,y.T()));
  af::array values = arg1 + arg2 - arg3;

  return  values;
}