• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VecType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中VecType的典型用法代码示例。如果您正苦于以下问题:C++ VecType类的具体用法?C++ VecType怎么用?C++ VecType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了VecType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FeedForward

  /**
   * Ordinary feed forward pass of a neural network, evaluating the function
   * f(x) by propagating the activity forward through f.
   *
   * @param inputActivation Input data used for evaluating the specified
   * activity function.
   * @param outputActivation Datatype to store the resulting output activation.
   */
  void FeedForward(const VecType& inputActivation, VecType& outputActivation)
  {
    if (inGate.n_cols < seqLen)
    {
      inGate = arma::zeros<MatType>(layerSize, seqLen);
      inGateAct = arma::zeros<MatType>(layerSize, seqLen);
      inGateError = arma::zeros<MatType>(layerSize, seqLen);
      outGate = arma::zeros<MatType>(layerSize, seqLen);
      outGateAct = arma::zeros<MatType>(layerSize, seqLen);
      outGateError = arma::zeros<MatType>(layerSize, seqLen);
      forgetGate = arma::zeros<MatType>(layerSize, seqLen);
      forgetGateAct = arma::zeros<MatType>(layerSize, seqLen);
      forgetGateError = arma::zeros<MatType>(layerSize, seqLen);
      state = arma::zeros<MatType>(layerSize, seqLen);
      stateError = arma::zeros<MatType>(layerSize, seqLen);
      cellAct = arma::zeros<MatType>(layerSize, seqLen);
    }

    // Split up the inputactivation into the 3 parts (inGate, forgetGate,
    // outGate).
    inGate.col(offset) = inputActivation.subvec(0, layerSize - 1);
    forgetGate.col(offset) = inputActivation.subvec(
        layerSize, (layerSize * 2) - 1);
    outGate.col(offset) = inputActivation.subvec(
        layerSize * 3, (layerSize * 4) - 1);

    if (peepholes && offset > 0)
    {
      inGate.col(offset) += inGatePeepholeWeights % state.col(offset - 1);
      forgetGate.col(offset) += forgetGatePeepholeWeights %
          state.col(offset - 1);
    }

    VecType inGateActivation = inGateAct.unsafe_col(offset);
    GateActivationFunction::fn(inGate.unsafe_col(offset), inGateActivation);

    VecType forgetGateActivation = forgetGateAct.unsafe_col(offset);
    GateActivationFunction::fn(forgetGate.unsafe_col(offset),
        forgetGateActivation);

    VecType cellActivation = cellAct.unsafe_col(offset);
    StateActivationFunction::fn(inputActivation.subvec(layerSize * 2,
        (layerSize * 3) - 1), cellActivation);

    state.col(offset) = inGateAct.col(offset) % cellActivation;

    if (offset > 0)
      state.col(offset) += forgetGateAct.col(offset) % state.col(offset - 1);

    if (peepholes)
      outGate.col(offset) += outGatePeepholeWeights % state.col(offset);

    VecType outGateActivation = outGateAct.unsafe_col(offset);
    GateActivationFunction::fn(outGate.unsafe_col(offset), outGateActivation);

    OutputActivationFunction::fn(state.unsafe_col(offset), outputActivation);
    outputActivation = outGateAct.col(offset) % outputActivation;

    offset = (offset + 1) % seqLen;
  }
开发者ID:riveridea,项目名称:mlpack,代码行数:68,代码来源:lstm_layer.hpp


示例2: operator

 void operator()(VecType x, VecType& y) {
   // y = x;
   // printf("Calling Preconditioners::LocalInnerSolver\n");
   std::fill(y.begin(),y.end(),typename VecType::value_type(0.));
   GMRES(plan, y, x, options, M, context);
   context.reset();
 }
开发者ID:LEONOB2014,项目名称:fmm-bem-relaxed,代码行数:7,代码来源:BlockDiagonalPC_Stokes.hpp


示例3: vec_exp_tanh_float

always_inline VecType vec_exp_tanh_float(VecType const & arg)
{
    typedef typename VecType::int_vec int_vec;

    /* Express e**x = e**g 2**n
     *   = e**g e**( n loge(2) )
     *   = e**( g + n loge(2) )
     */

    // black magic
    VecType x = arg;
    VecType z = round(VecType(1.44269504088896341f) * x);
    int_vec n = z.truncate_to_int();
    x -= z*VecType(0.693359375f);
    x -= z*VecType(-2.12194440e-4f);

    /* Theoretical peak relative error in [-0.5, +0.5] is 3.5e-8. */
    VecType p = 1.f +
        x * (1.00000035762786865234375f +
        x * (0.4999996721744537353515625f +
        x * (0.16665561497211456298828125f +
        x * (4.167006909847259521484375e-2f +
        x * (8.420792408287525177001953125e-3f +
        x * 1.386119984090328216552734375e-3f)))));

    /* multiply by power of 2 */
    VecType approx = ldexp_float(p, n);

    return approx;
}
开发者ID:mrotondo,项目名称:poopworm,代码行数:30,代码来源:vec_math.hpp


示例4:

hduPlane<T>::hduPlane(const VecType &pt1,
                   const VecType &pt2,
                   const VecType &p3)
{
    const VecType v1 = pt2 - pt1;
    const VecType v2 = p3 - pt1;
    
    m_normal = v1.crossProduct(v2);
    m_normal.normalize();
    
    m_d = -(m_normal.dotProduct(pt1));
}
开发者ID:gzmk,项目名称:phantom_code,代码行数:12,代码来源:hduPlane.cpp


示例5: dimCheck

  /** Dimensionality check during initialization */
  bool dimCheck(){

    if( Sx_.rows() != Sx_.cols() ){
      std::cerr << "Error: MatType must be a square matrix \n";
      return false;
    }
    if( Sx_.rows() != x_.size() ){
      std::cerr << "Error: VecType and MatType dimension mismatch \n";
      return false;
    }
    nDim_ = x_.size();
    return true;
  }
开发者ID:bigjun,项目名称:RFS-SLAM,代码行数:14,代码来源:RandomVec.hpp


示例6: entry_or_zero

 inline typename VecType::value_type entry_or_zero(const VecType &v, unsigned i)
 {
   if (i >= v.size())
     return 0;
   else
     return v[i];
 }
开发者ID:gimac,项目名称:pyrticle,代码行数:7,代码来源:tools.hpp


示例7: outputClass

 /*
  * Calculate the output class using the specified input activation.
  *
  * @param inputActivations Input data used to calculate the output class.
  * @param output Output class of the input activation.
  */
 void outputClass(const VecType& inputActivations, VecType& output)
 {
   output = arma::zeros<VecType>(inputActivations.n_elem);
   arma::uword maxIndex;
   inputActivations.max(maxIndex);
   output(maxIndex) = 1;
 }
开发者ID:PhenixI,项目名称:mlpack,代码行数:13,代码来源:one_hot_layer.hpp


示例8: vec_sin_float

always_inline VecType vec_sin_float(VecType const & arg)
{
    typedef typename VecType::int_vec int_vec;

    const typename VecType::float_type four_over_pi = 1.27323954473516268615107010698011489627567716592367;

    VecType sign = arg & VecType::gen_sign_mask();
    VecType abs_arg = arg & VecType::gen_abs_mask();

    VecType y = abs_arg * four_over_pi;

    int_vec j = y.truncate_to_int();

    /* cephes: j=(j+1) & (~1) */
    j = (j + int_vec(1)) & int_vec(~1);
    y = j.convert_to_float();

    /* sign based on quadrant */
    VecType swap_sign_bit = slli(j & int_vec(4), 29);
    sign = sign ^ swap_sign_bit;

    /* polynomial mask */
    VecType poly_mask = VecType (mask_eq(j & int_vec(2), int_vec(0)));

    /* black magic */
    static float DP1 = 0.78515625;
    static float DP2 = 2.4187564849853515625e-4;
    static float DP3 = 3.77489497744594108e-8;
    VecType base = ((abs_arg - y * DP1) - y * DP2) - y * DP3;

    /* [0..pi/4] */
    VecType z = base * base;
    VecType p1 = ((  2.443315711809948E-005 * z
        - 1.388731625493765E-003) * z
        + 4.166664568298827E-002) * z * z
        -0.5f * z + 1.0
        ;

    /* [pi/4..pi/2] */
    VecType p2 = ((-1.9515295891E-4 * z
         + 8.3321608736E-3) * z
         - 1.6666654611E-1) * z * base + base;

    VecType approximation =  select(p1, p2, poly_mask);

    return approximation ^ sign;
}
开发者ID:mrotondo,项目名称:poopworm,代码行数:47,代码来源:vec_math.hpp


示例9: VecType

//==========================
//	NW	N			N	NE
//	  \	|			|  /
//		a-----------b
//	  /	|			|  \
//	SW	S			S	SE
//==========================
int Stick::extrudeLines(const PathType& path, float width)
{
	if (path.size() < 2)
	{
		return EXTRUDE_FAIL;
	}
	
	int pointSize = path.size();
	int lineSize = pointSize - 1;

	_indexList.resize( lineSize*IDEX_FACTOR );

	for (int idx=0; idx < lineSize; idx++)
	{
		const VecType& a = path[idx];
		const VecType& b = path[idx+1];

		VecType e = (b-a);
		e.normalize();
		e *= width;

		VecType N = VecType(-e.y(), e.x(), 0);
		VecType S = -N;
		VecType NE = N + e;
		VecType NW = N - e;

		VecType SW = -NE;
		VecType SE = -NW;

		_vertexList.push_back( Vertex(a + SW) );
		_vertexList.push_back( Vertex(a + NW) );
		_vertexList.push_back( Vertex(a + S) );
		_vertexList.push_back( Vertex(a + N) );

		_vertexList.push_back( Vertex(b + S) );
		_vertexList.push_back( Vertex(b + N) );
		_vertexList.push_back( Vertex(b + SE) );
		_vertexList.push_back( Vertex(b + NE) );
	}

	_generateTriangleTexCoord();
	_generateTriangesIndices();

	return EXTRUDE_SUCCESS;	
}
开发者ID:dizuo,项目名称:xrender,代码行数:52,代码来源:stick.cpp


示例10: perform

	inline typename boost::disable_if_c<VecType::has_compare_bitmask, VecType >::type
	perform(VecType arg) const
	{
		typedef VecType vec;

		vec result;
		for (int i = 0; i != result.size; ++i)
			result.set(i, sc_scurve(arg.get(i)));
		return result;
	}
开发者ID:HuaxingXu,项目名称:supercollider,代码行数:10,代码来源:UnaryOpUGens.cpp


示例11: vec_exp_float

always_inline VecType vec_exp_float(VecType const & arg)
{
    typedef typename VecType::int_vec int_vec;

    /* Express e**x = e**g 2**n
     *   = e**g e**( n loge(2) )
     *   = e**( g + n loge(2) )
     */

    // black magic
    VecType x = arg;
    VecType z = round(VecType(1.44269504088896341f) * x);
    int_vec n = z.truncate_to_int();
    x -= z*VecType(0.693359375f);
    x -= z*VecType(-2.12194440e-4f);

    /* Theoretical peak relative error in [-0.5, +0.5] is 3.5e-8. */
    VecType p = VecType(VecType::gen_one()) +
        x * (1.00000035762786865234375f +
        x * (0.4999996721744537353515625f +
        x * (0.16665561497211456298828125f +
        x * (4.167006909847259521484375e-2f +
        x * (8.420792408287525177001953125e-3f +
        x * 1.386119984090328216552734375e-3f)))));

    /* multiply by power of 2 */
    VecType approx = ldexp_float(p, n);

    /* handle min/max boundaries */
    const VecType maxlogf(88.72283905206835f);
//    const VecType minlogf(-103.278929903431851103f);
	const VecType minlogf = -maxlogf;
    const VecType max_float(std::numeric_limits<float>::max());
    const VecType zero = VecType::gen_zero();

    VecType too_large = mask_gt(arg, maxlogf);
    VecType too_small = mask_lt(arg, minlogf);

    VecType ret = select(approx, max_float, too_large);
    ret = select(ret, zero, too_small);

    return ret;
}
开发者ID:ELVIS-Project,项目名称:VISIntervalSonifier,代码行数:43,代码来源:vec_math.hpp


示例12: compare_float_mask

void compare_float_mask(VecType const & v, unsigned int mask)
{
   for (int i = 0; i != v.size; ++i) {
        union {
            float f;
            unsigned int i;
        } x;
        x.f = v.get(i);
        BOOST_REQUIRE_EQUAL( x.i, mask);
    }
}
开发者ID:mrotondo,项目名称:poopworm,代码行数:11,代码来源:vec_test.cpp


示例13: vec_tan_float

always_inline VecType vec_tan_float(VecType const & arg)
{
    typedef typename VecType::int_vec int_vec;
    const typename VecType::float_type four_over_pi = 1.27323954473516268615107010698011489627567716592367;

    VecType sign = arg & VecType::gen_sign_mask();
    VecType abs_arg = arg & VecType::gen_abs_mask();

    VecType y = abs_arg * four_over_pi;
    int_vec j = y.truncate_to_int();

    /* cephes: j=(j+1) & (~1) */
    j = (j + int_vec(1)) & int_vec(~1);
    y = j.convert_to_float();

    /* approximation mask */
    VecType poly_mask = VecType (mask_eq(j & int_vec(2), int_vec(0)));

    /* black magic */
    static float DP1 = 0.78515625;
    static float DP2 = 2.4187564849853515625e-4;
    static float DP3 = 3.77489497744594108e-8;
    VecType base = ((abs_arg - y * DP1) - y * DP2) - y * DP3;

    VecType x = base; VecType x2 = x*x;

    // sollya: fpminimax(tan(x), [|3,5,7,9,11,13|], [|24...|], [-pi/4,pi/4], x);
    VecType approx =
        x + x * x2 * (0.3333315551280975341796875 + x2 * (0.1333882510662078857421875 + x2 * (5.3409568965435028076171875e-2 + x2 * (2.443529665470123291015625e-2 + x2 * (3.1127030961215496063232421875e-3 + x2 * 9.3892104923725128173828125e-3)))));

    //VecType recip = -reciprocal(approx);
    VecType recip = -1.0 / approx;

    VecType approximation = select(recip, approx, poly_mask);

    return approximation ^ sign;
}
开发者ID:mrotondo,项目名称:poopworm,代码行数:37,代码来源:vec_math.hpp


示例14: result

  PartialVolumeAnalysisClusteringCalculator::ClusterResultType
      PartialVolumeAnalysisClusteringCalculator::CalculateCurves(ParamsType params, VecType xVals) const
  {

    int arraysz = xVals.size();
    ClusterResultType result(arraysz);

    for( int j=0; j<2; j++)
    {
      for(int i=0; i<arraysz; i++)
      {
        double d   = xVals(i)-params.means[j];
        double amp = params.ps[j]/sqrt(2*PVA_PI*params.sigmas[j]);

        result.vals[j](i) = amp*exp(-0.5 * (d*d)/params.sigmas[j]);
      }
    }

    for(int i=0; i<arraysz; i++)
    {
      result.mixedVals[0](i) = 0;
    }

    for(double t=0; t<=1; t = t + 1.0/(m_StepsNumIntegration-1.0))
    {
      for(int i=0; i<arraysz; i++)
      {
        double d = xVals(i)-(t*params.means[0]+(1-t)*params.means[1]);
        double v = t*params.sigmas[0]+(1-t)*params.sigmas[1];
        double p = 1.0 - params.ps[0] - params.ps[1];
        double amp = (1.0/m_StepsNumIntegration) * p / sqrt(2.0*PVA_PI*v);

        result.mixedVals[0](i) = result.mixedVals[0](i) + amp*exp(-0.5 * (d*d)/v);

        //        MITK_INFO << "d=" << d << "v=" <<v << "p=" << p << "amp=" << amp << "result=" << amp*exp(-0.5 * (d*d)/v) << std::endl;
      }
      //      MITK_INFO << "t=" << t << std::endl;
      //      params.Print();
      //      result.Print();
    }

    for(int i=0; i<arraysz; i++)
    {
      result.combiVals(i) = result.mixedVals[0](i) + result.vals[0](i) + result.vals[1](i);
    }

    return result;
  }
开发者ID:GHfangxin,项目名称:MITK,代码行数:48,代码来源:mitkPartialVolumeAnalysisClusteringCalculator.cpp


示例15: switch

void Warp::resize_1d(const VecType &in, const InterpType interp_type, 
        double inv_scale, VecType *out) const
{
    // For the anti-aliasing filter
    double scale = 1.0f/inv_scale;
    if(scale>1){
        scale = 1;
    }
    int length = in.rows();

    switch(interp_type){
    case Warp::NEAREST:
    {
        for(double i = 0; i < out->rows(); ++i  )
        {
            double u = i*inv_scale + 0.5f*(-1.0f+inv_scale);
            int l = floor(u);
            int r = l+1;
            if(u-l > r-u ) {
                if((r >=0) && (r<length)){
                    (*out)(i) = in(r);
                }
            }else {
                if((l >=0) && (l<length)){
                    (*out)(i) = in(l);
                }
            }
        }
        break;
    }
    case Warp::BILINEAR:
    {
        int kernel_width = 1;
        for(double i = 0; i < out->rows(); ++i  )
        {
            double u = i*inv_scale + 0.5f*(-1.0f+inv_scale);
            int l = floor(u-kernel_width/2);
            int r = l+kernel_width;
            double val = 0;
            // if(i == out->rows()-1){
            //     printf("%f,%d,%d\n",u,l,r);
            // }
            double w = 0;
            double weight = 0;
            for(int x = l; x<=r; ++x)
            {
                if(x<0 || x>=length){
                    continue;
                }
                w = kernel_linear(u-x,scale);
                val += w*in(x);
                weight += w;
            }
            if(weight>0)
            {
                val/= weight;
            }
            (*out)(i) = val;
        }
        break;
    }
    case Warp::BICUBIC:
    {
        int kernel_width = 4;
        for(double i = 0; i < out->rows(); ++i  )
        {
            double u = i*inv_scale + 0.5f*(-1.0f+inv_scale);
            int l = floor(u-kernel_width/2);
            int r = l+kernel_width;
            double val = 0;
            double w = 0;
            double weight = 0;
            for(int x = l; x<=r; ++x)
            {
                if(x<0 || x>=length){
                    continue;
                }
                w = kernel_cubic(u-x,scale);
                val += w*in(x);
                weight += w;
                // printf("%d, %.2f ", x, w);
            }
            // printf("\n");
            if(weight>0)
            {
                val/= weight;
            }
            (*out)(i) = val;
        }
        break;
    }
    } // switch
}
开发者ID:mgharbi,项目名称:xform_cpp,代码行数:93,代码来源:Warp.cpp


示例16: float

int RoadComposer::extrude_lines(const Point* point_list, int point_num, int width, float (&tex_coord)[4], 
							  V2F2F* vertex_page, int vertex_size,
							  IType* index_page, int index_size,
							  int index_off)
{
	if (point_num < 2)
	{
		return EXTRUDE_FAIL;
	}
	int line_size = point_num - 1;
	
	int v_cursor = 0;

	for (int idx=0; idx < line_size; idx++)
	{
		const Point& p0 = point_list[idx];
		const Point& p1 = point_list[idx+1];
		
		VecType a(p0.x, p0.y);
		VecType b(p1.x, p1.y);

		VecType e = (b-a);
		e.normalize();
		e *= width;

		VecType N = VecType(-e.y(), e.x());
		VecType S = -N;
		VecType NE = N + e;
		VecType NW = N - e;

		VecType SW = -NE;
		VecType SE = -NW;

		if (v_cursor + LINE_MAX_VERT_SIZE > vertex_size)
		{
			return EXTRUDE_FAIL;			
		}

		ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(a + SW).getValue() );
		v_cursor++;

		ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(a + NW).getValue() );
		v_cursor++;

		ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(a + S).getValue() );
		v_cursor++;

		ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(a + N).getValue() );
		v_cursor++;

		ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(b + S).getValue() );
		v_cursor++;

		ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(b + N).getValue() );
		v_cursor++;

		if (idx==line_size-1)
		{
			// 最后一段增加尾部
			ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(b + S).getValue() );
			v_cursor++;

			ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(b + N).getValue() );
			v_cursor++;

			ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(b + SE).getValue() );
			v_cursor++;

			ASSIGN_2F_ARRAY( vertex_page[v_cursor].xy, VecType(b + NE).getValue() );
			v_cursor++;
		}
	}
	
	_generate_triangle_texCoord(line_size, vertex_size, vertex_page, tex_coord);

	return _generate_trianges_indices(line_size, index_size, index_page, index_off);;
}
开发者ID:dizuo,项目名称:xrender,代码行数:77,代码来源:road_composer.cpp


示例17: topLeft

 VecType2 topLeft() const { return position.xy(); }
开发者ID:aonorin,项目名称:nytl,代码行数:1,代码来源:rect.hpp


示例18: DEBUG

bool Legalizer::runOnMachineFunction(MachineFunction &MF) {
  // If the ISel pipeline failed, do not bother running that pass.
  if (MF.getProperties().hasProperty(
          MachineFunctionProperties::Property::FailedISel))
    return false;
  DEBUG(dbgs() << "Legalize Machine IR for: " << MF.getName() << '\n');
  init(MF);
  const TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
  MachineOptimizationRemarkEmitter MORE(MF, /*MBFI=*/nullptr);
  LegalizerHelper Helper(MF);

  // FIXME: an instruction may need more than one pass before it is legal. For
  // example on most architectures <3 x i3> is doubly-illegal. It would
  // typically proceed along a path like: <3 x i3> -> <3 x i8> -> <8 x i8>. We
  // probably want a worklist of instructions rather than naive iterate until
  // convergence for performance reasons.
  bool Changed = false;
  MachineBasicBlock::iterator NextMI;
  using VecType = SmallSetVector<MachineInstr *, 8>;
  VecType WorkList;
  VecType CombineList;
  for (auto &MBB : MF) {
    for (auto MI = MBB.begin(); MI != MBB.end(); MI = NextMI) {
      // Get the next Instruction before we try to legalize, because there's a
      // good chance MI will be deleted.
      NextMI = std::next(MI);

      // Only legalize pre-isel generic instructions: others don't have types
      // and are assumed to be legal.
      if (!isPreISelGenericOpcode(MI->getOpcode()))
        continue;
      unsigned NumNewInsns = 0;
      WorkList.clear();
      CombineList.clear();
      Helper.MIRBuilder.recordInsertions([&](MachineInstr *MI) {
        // Only legalize pre-isel generic instructions.
        // Legalization process could generate Target specific pseudo
        // instructions with generic types. Don't record them
        if (isPreISelGenericOpcode(MI->getOpcode())) {
          ++NumNewInsns;
          WorkList.insert(MI);
          CombineList.insert(MI);
        }
      });
      WorkList.insert(&*MI);
      LegalizerCombiner C(Helper.MIRBuilder, MF.getRegInfo(),
                          Helper.getLegalizerInfo());
      bool Changed = false;
      LegalizerHelper::LegalizeResult Res;
      do {
        assert(!WorkList.empty() && "Expecting illegal ops");
        while (!WorkList.empty()) {
          NumNewInsns = 0;
          MachineInstr *CurrInst = WorkList.pop_back_val();
          Res = Helper.legalizeInstrStep(*CurrInst);
          // Error out if we couldn't legalize this instruction. We may want to
          // fall back to DAG ISel instead in the future.
          if (Res == LegalizerHelper::UnableToLegalize) {
            Helper.MIRBuilder.stopRecordingInsertions();
            if (Res == LegalizerHelper::UnableToLegalize) {
              reportGISelFailure(MF, TPC, MORE, "gisel-legalize",
                                 "unable to legalize instruction", *CurrInst);
              return false;
            }
          }
          Changed |= Res == LegalizerHelper::Legalized;
          // If CurrInst was legalized, there's a good chance that it might have
          // been erased. So remove it from the Combine List.
          if (Res == LegalizerHelper::Legalized)
            CombineList.remove(CurrInst);

#ifndef NDEBUG
          if (NumNewInsns)
            for (unsigned I = WorkList.size() - NumNewInsns,
                          E = WorkList.size();
                 I != E; ++I)
              DEBUG(dbgs() << ".. .. New MI: " << *WorkList[I];);
#endif
        }
        // Do the combines.
        while (!CombineList.empty()) {
          NumNewInsns = 0;
          MachineInstr *CurrInst = CombineList.pop_back_val();
          SmallVector<MachineInstr *, 4> DeadInstructions;
          Changed |= C.tryCombineInstruction(*CurrInst, DeadInstructions);
          for (auto *DeadMI : DeadInstructions) {
            DEBUG(dbgs() << ".. Erasing Dead Instruction " << *DeadMI);
            CombineList.remove(DeadMI);
            WorkList.remove(DeadMI);
            DeadMI->eraseFromParent();
          }
#ifndef NDEBUG
          if (NumNewInsns)
            for (unsigned I = CombineList.size() - NumNewInsns,
                          E = CombineList.size();
                 I != E; ++I)
              DEBUG(dbgs() << ".. .. Combine New MI: " << *CombineList[I];);
#endif
        }
      } while (!WorkList.empty());
//.........这里部分代码省略.........
开发者ID:PolyJIT,项目名称:llvm,代码行数:101,代码来源:Legalizer.cpp


示例19: FeedBackward

  /**
   * Ordinary feed backward pass of a neural network, calculating the function
   * f(x) by propagating x backwards trough f. Using the results from the feed
   * forward pass.
   *
   * @param inputActivation Input data used for calculating the function f(x).
   * @param error The backpropagated error.
   * @param delta The calculating delta using the partial derivative of the
   * error with respect to a weight.
   */
  void FeedBackward(const VecType& /* unused */,
                    const VecType& error,
                    VecType& delta)
  {
    size_t queryOffset = seqLen - offset - 1;

    VecType outGateDerivative;
    GateActivationFunction::deriv(outGateAct.unsafe_col(queryOffset),
        outGateDerivative);

    VecType stateActivation;
    StateActivationFunction::fn(state.unsafe_col(queryOffset), stateActivation);

    outGateError.col(queryOffset) = outGateDerivative % error % stateActivation;

    VecType stateDerivative;
    StateActivationFunction::deriv(stateActivation, stateDerivative);

    stateError.col(queryOffset) = error % outGateAct.col(queryOffset) %
        stateDerivative;

    if (queryOffset < (seqLen - 1))
    {
      stateError.col(queryOffset) += stateError.col(queryOffset + 1) %
          forgetGateAct.col(queryOffset + 1);

      if (peepholes)
      {
        stateError.col(queryOffset) += inGateError.col(queryOffset + 1) %
            inGatePeepholeWeights;
        stateError.col(queryOffset) += forgetGateError.col(queryOffset + 1) %
            forgetGatePeepholeWeights;
      }
    }

    if (peepholes)
    {
      stateError.col(queryOffset) += outGateError.col(queryOffset) %
          outGatePeepholeWeights;
    }

    VecType cellDerivative;
    StateActivationFunction::deriv(cellAct.col(queryOffset), cellDerivative);

    VecType cellError = inGateAct.col(queryOffset) % cellDerivative %
        stateError.col(queryOffset);

    if (queryOffset > 0)
    {
      VecType forgetGateDerivative;
      GateActivationFunction::deriv(forgetGateAct.col(queryOffset),
          forgetGateDerivative);

      forgetGateError.col(queryOffset) = forgetGateDerivative %
          stateError.col(queryOffset) % state.col(queryOffset - 1);
    }

    VecType inGateDerivative;
    GateActivationFunction::deriv(inGateAct.col(queryOffset), inGateDerivative);

    inGateError.col(queryOffset) = inGateDerivative %
        stateError.col(queryOffset) % cellAct.col(queryOffset);

    if (peepholes)
    {
      outGateDerivative += outGateError.col(queryOffset) %
          state.col(queryOffset);
      if (queryOffset > 0)
      {
        inGatePeepholeDerivatives += inGateError.col(queryOffset) %
            state.col(queryOffset - 1);
        forgetGatePeepholeDerivatives += forgetGateError.col(queryOffset) %
            state.col(queryOffset - 1);
      }
    }

    delta = arma::zeros<VecType>(layerSize * 4);
    delta.subvec(0, layerSize - 1) = inGateError.col(queryOffset);
    delta.subvec(layerSize, (layerSize * 2) - 1) =
        forgetGateError.col(queryOffset);
    delta.subvec(layerSize * 2, (layerSize * 3) - 1) = cellError;
    delta.subvec(layerSize * 3, (layerSize * 4) - 1) =
        outGateError.col(queryOffset);

    offset = (offset + 1) % seqLen;

    if (peepholes && offset == 0)
    {
      inGatePeepholeGradient = (inGatePeepholeWeights.t() *
          (inGateError.col(queryOffset) % inGatePeepholeDerivatives)) *
//.........这里部分代码省略.........
开发者ID:riveridea,项目名称:mlpack,代码行数:101,代码来源:lstm_layer.hpp


示例20: bottomLeft

	VecType2 bottomLeft() const { return position.xy() + VecType2(0, size.y);}
开发者ID:aonorin,项目名称:nytl,代码行数:1,代码来源:rect.hpp



注:本文中的VecType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Vec_DP类代码示例发布时间:2022-05-31
下一篇:
C++ VecString类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap