提交 3616ef77 编写于 作者: H hedaoyuan

Remove ExpandConvBaseLayer.

上级 b3a50d53
...@@ -36,7 +36,35 @@ inline bool isDepthwiseConv(int channels, int groups) { ...@@ -36,7 +36,35 @@ inline bool isDepthwiseConv(int channels, int groups) {
bool ExpandConvLayer::init(const LayerMap &layerMap, bool ExpandConvLayer::init(const LayerMap &layerMap,
const ParameterMap &parameterMap) { const ParameterMap &parameterMap) {
/* Initialize the basic convolutional parent class */ /* Initialize the basic convolutional parent class */
ExpandConvBaseLayer::init(layerMap, parameterMap); ConvBaseLayer::init(layerMap, parameterMap);
int index = 0;
for (auto &inputConfig : config_.inputs()) {
const ConvConfig &conf = inputConfig.conv_conf();
/* Consistent caffe mode for multiple input */
caffeMode_ = conf.caffe_mode();
// create a new weight
size_t height, width;
height = filterPixels_[index] * filterChannels_[index];
width = (!isDeconv_) ? numFilters_ : channels_[index];
CHECK_EQ(parameters_[index]->getSize(), width * height);
Weight *w = new Weight(height, width, parameters_[index]);
weights_.emplace_back(w);
index++;
}
if (biasParameter_.get()) {
if (sharedBiases_) {
CHECK_EQ((size_t)numFilters_, biasParameter_->getSize());
biases_ =
std::unique_ptr<Weight>(new Weight(numFilters_, 1, biasParameter_));
} else {
biases_ =
std::unique_ptr<Weight>(new Weight(getSize(), 1, biasParameter_));
}
}
getOutputSize();
size_t numInputs = config_.inputs_size(); size_t numInputs = config_.inputs_size();
inputShape_.resize(numInputs); inputShape_.resize(numInputs);
...@@ -108,6 +136,12 @@ bool ExpandConvLayer::init(const LayerMap &layerMap, ...@@ -108,6 +136,12 @@ bool ExpandConvLayer::init(const LayerMap &layerMap,
return true; return true;
} }
size_t ExpandConvLayer::getOutputSize() {
CHECK_NE(inputLayers_.size(), 0UL);
size_t layerSize = ConvBaseLayer::calOutputSize();
return layerSize;
}
// i is the index of input layers // i is the index of input layers
#define BACKWARD_INPUT(i, inputs, outputs) \ #define BACKWARD_INPUT(i, inputs, outputs) \
backward_[2 * i]->calc(inputs, outputs) backward_[2 * i]->calc(inputs, outputs)
......
...@@ -28,10 +28,9 @@ namespace paddle { ...@@ -28,10 +28,9 @@ namespace paddle {
* The config file api is img_conv_layer. * The config file api is img_conv_layer.
*/ */
class ExpandConvLayer : public ExpandConvBaseLayer { class ExpandConvLayer : public ConvBaseLayer {
public: public:
explicit ExpandConvLayer(const LayerConfig& config) explicit ExpandConvLayer(const LayerConfig& config) : ConvBaseLayer(config) {}
: ExpandConvBaseLayer(config) {}
~ExpandConvLayer() {} ~ExpandConvLayer() {}
...@@ -41,6 +40,8 @@ public: ...@@ -41,6 +40,8 @@ public:
void forward(PassType passType) override; void forward(PassType passType) override;
void backward(const UpdateCallback& callback) override; void backward(const UpdateCallback& callback) override;
size_t getOutputSize();
protected: protected:
std::vector<TensorShape> inputShape_; std::vector<TensorShape> inputShape_;
std::vector<TensorShape> filterShape_; std::vector<TensorShape> filterShape_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册