本文整理汇总了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]);
}
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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);
}
}
示例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_);
}
示例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);
}
示例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);
}