class SoftmaxWithLossLayer : public LossLayer<Dtype> {
public:
explicit SoftmaxWithLossLayer(const LayerParameter& param)
- : LossLayer<Dtype>(param),
- softmax_layer_(new SoftmaxLayer<Dtype>(param)) {}
+ : LossLayer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
/// The internal SoftmaxLayer used to map predictions to a distribution.
- shared_ptr<SoftmaxLayer<Dtype> > softmax_layer_;
+ shared_ptr<Layer<Dtype> > softmax_layer_;
/// prob stores the output probability predictions from the SoftmaxLayer.
Blob<Dtype> prob_;
/// bottom vector holder used in call to the underlying SoftmaxLayer::Forward
#include <vector>
#include "caffe/layer.hpp"
+#include "caffe/layer_factory.hpp"
#include "caffe/util/math_functions.hpp"
#include "caffe/vision_layers.hpp"
void SoftmaxWithLossLayer<Dtype>::LayerSetUp(
const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
LossLayer<Dtype>::LayerSetUp(bottom, top);
+ LayerParameter softmax_param(this->layer_param_);
+ softmax_param.set_type(LayerParameter_LayerType_SOFTMAX);
+ softmax_layer_.reset(LayerRegistry<Dtype>::CreateLayer(softmax_param));
softmax_bottom_vec_.clear();
softmax_bottom_vec_.push_back(bottom[0]);
softmax_top_vec_.clear();