当前位置: 首页>>代码示例>>C++>>正文


C++ BlobShape类代码示例

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


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

示例1: TYPED_TEST

TYPED_TEST(ReshapeLayerTest, TestForwardAfterReshape) {
  typedef typename TypeParam::Dtype Dtype;
  LayerParameter layer_param;
  BlobShape* shape = layer_param.mutable_reshape_param()->mutable_shape();
  shape->add_dim(6);
  shape->add_dim(2);
  shape->add_dim(3);
  shape->add_dim(5);
  ReshapeLayer<Dtype> layer(layer_param);
  layer.SetUp(this->blob_bottom_vec_, this->blob_top_vec_);
  layer.Forward(this->blob_bottom_vec_, this->blob_top_vec_);
  // We know the above produced the correct result from TestForward.
  // Reshape the bottom and call layer.Reshape, then try again.
  vector<int> new_bottom_shape(1, 2 * 3 * 6 * 5);
  this->blob_bottom_->Reshape(new_bottom_shape);
  layer.Reshape(this->blob_bottom_vec_, this->blob_top_vec_);
  FillerParameter filler_param;
  GaussianFiller<Dtype> filler(filler_param);
  filler.Fill(this->blob_bottom_);
  layer.Forward(this->blob_bottom_vec_, this->blob_top_vec_);
  for (int i = 0; i < this->blob_bottom_->count(); ++i) {
    EXPECT_EQ(this->blob_top_->cpu_data()[i],
              this->blob_bottom_->cpu_data()[i]);
  }
}
开发者ID:hanshizhong1105,项目名称:caffe-sc,代码行数:25,代码来源:test_reshape_layer.cpp

示例2: CV_Assert

    Blob::Blob(InputArray image, int dstCn)
    {
        CV_Assert(dstCn == -1 || dstCn > 0);
        std::vector<Mat> inMats = extractMatVector(image);
        BlobShape dstShape = getBlobShpae(inMats, dstCn);

        m.create(dstShape.dims(), dstShape.ptr(), CV_32F);

        std::vector<Mat> wrapBuf(dstShape[-3]);
        int elemSize = (int)m.elemSize();
        uchar *ptr = this->ptr();
        for (size_t i = 0; i < inMats.size(); i++)
        {
            Mat inMat = inMats[i];

            if (inMat.dims <= 2)
            {
                inMat.convertTo(inMat, m.type());

                wrapBuf.resize(0);
                for (int cn = 0; cn < inMat.channels(); cn++)
                {
                    wrapBuf.push_back(Mat(inMat.rows, inMat.cols, m.type(), ptr));
                    ptr += elemSize * inMat.total();
                }

                cv::split(inMat, wrapBuf);
            }
            else
            {
                inMat.convertTo(Mat(inMat.dims, inMat.size, m.type(), ptr), m.type());
                ptr += elemSize * inMat.total();
            }
        }
    }
开发者ID:headupinclouds,项目名称:opencv_contrib,代码行数:35,代码来源:blob.cpp

示例3: Reshape

void Blob<Dtype>::Reshape(const BlobShape& shape) {
  CHECK_LE(shape.dim_size(), kMaxBlobAxes);
  vector<int> shape_vec(shape.dim_size());
  for (int i = 0; i < shape.dim_size(); ++i) {
    shape_vec[i] = shape.dim(i);
  }
  Reshape(shape_vec);
}
开发者ID:ArtHacker123,项目名称:mini-caffe,代码行数:8,代码来源:blob.cpp

示例4:

BlobShape ModelServer<DType>::blob_shape_by_name(string name) {
  const vector<int>& shape = solver->net()->blob_by_name(name)->shape();
  BlobShape ret;
  for (uint32_t i = 0; i < shape.size(); ++i) {
    ret.add_dim(shape[i]);
  }
  return ret;
}
开发者ID:0hm,项目名称:caffe,代码行数:8,代码来源:ModelServer.cpp

示例5: outShape

    void FullyConnectedLayer::reshape(const Blob &inp, Blob &out)
    {
        BlobShape inpShape = inp.shape();
        BlobShape outShape(axis+1, inpShape.ptr());
        outShape[axis] = numOutputs;

        out.create(outShape, inp.type());
    }
开发者ID:AnhLe595,项目名称:opencv_contrib,代码行数:8,代码来源:fully_connected_layer.cpp

示例6:

const vector<int>  NDimDataLayer<Dtype>::blob2vec(const BlobShape& b) const
{
  CHECK_LE(b.dim_size(), kMaxBlobAxes);
  vector<int> shape_vec(b.dim_size());
  for (int i = 0, n = b.dim_size(); i < n; ++i) {
    shape_vec[i] = b.dim(i);
  }
  return shape_vec;
}
开发者ID:jlc206,项目名称:caffe,代码行数:9,代码来源:ndim_data_layer.cpp

示例7: equal

inline bool BlobShape::equal(const BlobShape &other) const
{
    if (this->dims() != other.dims())
        return false;

    for (int i = 0; i < other.dims(); i++)
    {
        if (sz[i] != other.sz[i])
            return false;
    }

    return true;
}
开发者ID:2php,项目名称:opencv_contrib,代码行数:13,代码来源:blob.inl.hpp

示例8: fill

    void Blob::fill(const BlobShape &shape, int type, void *data, bool deepCopy)
    {
        CV_Assert(type == CV_32F || type == CV_64F);

        if (deepCopy)
        {
            m.create(shape.dims(), shape.ptr(), type);
            memcpy(m.data, data, m.total() * m.elemSize());
        }
        else
        {
            m = Mat(shape.dims(), shape.ptr(), type, data);
        }
    }
开发者ID:headupinclouds,项目名称:opencv_contrib,代码行数:14,代码来源:blob.cpp

示例9: SetUp

  virtual void SetUp() {
    BlobShape shape;
    shape.add_dim(1);  // Batch
    shape.add_dim(8);  // Channels
    shape.add_dim(4);  // Depth
    shape.add_dim(4);  // Height
    shape.add_dim(4);  // Width
    blob_bottom_->Reshape(shape);

    shape.add_dim(1);  // Batch
    shape.add_dim(8);  // Channels
    shape.add_dim(2);  // Depth
    shape.add_dim(2);  // Height
    shape.add_dim(2);  // Width
    blob_top_->Reshape(shape);

    // fill the values
    blob_bottom_vec_.push_back(blob_bottom_);
    blob_top_vec_.push_back(blob_top_);
  }
开发者ID:ifp-uiuc,项目名称:caffe,代码行数:20,代码来源:test_pooling_nd_layer.cpp

示例10: create

 void Blob::create(const BlobShape &shape, int type)
 {
     CV_Assert(type == CV_32F || type == CV_64F);
     m.create(shape.dims(), shape.ptr(), type);
 }
开发者ID:headupinclouds,项目名称:opencv_contrib,代码行数:5,代码来源:blob.cpp

示例11: shape

void Blob<Dtype>::reshape(const BlobShape& blob_shape) {
	vector<int> shape(blob_shape.dim_size());
	for (int i = 0; i < shape.size(); i++) shape[i] = blob_shape.dim(i);
	reshape(shape);
}
开发者ID:qianxinchun,项目名称:Dragon,代码行数:5,代码来源:blob.cpp


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