27 #ifndef LBANN_LAYER_REGULARIZER_DROPOUT_HPP_INCLUDED 28 #define LBANN_LAYER_REGULARIZER_DROPOUT_HPP_INCLUDED 31 #ifdef LBANN_HAS_DNN_LIB 34 #endif // LBANN_HAS_DNN_LIB 50 template <
typename TensorDataType, data_layout T_layout, El::Device Dev>
67 #ifdef LBANN_HAS_DNN_LIB
69 m_tensors_dnn_desc(this)
77 #ifdef LBANN_HAS_DNN_LIB
79 m_tensors_dnn_desc(other.m_tensors_dnn_desc)
82 #ifdef LBANN_HAS_DNN_LIB 83 m_tensors_dnn_desc.set_layer(
this);
84 m_states = other.m_states;
85 m_reserve_space = other.m_reserve_space;
86 if (other.m_dropout_dnn_desc !=
nullptr) {
87 setup_dropout_dnn_desc();
89 #endif // LBANN_HAS_DNN_LIB 97 ? std::unique_ptr<AbsDistMatrixType>(other.
m_mask->Copy())
99 #ifdef LBANN_HAS_DNN_LIB 100 m_tensors_dnn_desc = other.m_tensors_dnn_desc;
101 m_tensors_dnn_desc.set_layer(
this);
102 m_states = other.m_states;
103 m_reserve_space = other.m_reserve_space;
104 if (other.m_dropout_dnn_desc !=
nullptr) {
105 setup_dropout_dnn_desc();
107 #endif // LBANN_HAS_DNN_LIB 114 std::string
get_type()
const override {
return "dropout"; }
134 template <
typename ArchiveT>
158 #ifndef LBANN_HAS_DNN_LIB 162 #ifdef LBANN_DETERMINISTIC 163 if (this->
get_comm()->am_trainer_master()) {
169 "does not guarantee sequential consistency");
171 #endif // LBANN_DETERMINISTIC 174 setup_dropout_dnn_desc();
176 #endif // LBANN_HAS_DNN_LIB 209 #ifdef LBANN_HAS_DNN_LIB 212 void setup_dropout_dnn_desc()
216 size_t size = dnn_lib::get_dropout_states_size();
217 m_states.Resize((size +
sizeof(TensorDataType) - 1) /
218 sizeof(TensorDataType),
224 m_states.Height() *
sizeof(TensorDataType),
227 #endif // LBANN_HAS_DNN_LIB 232 std::unique_ptr<AbsDistMatrixType>
m_mask;
234 #ifdef LBANN_HAS_DNN_LIB 236 dnn_lib::DropoutDescriptor m_dropout_dnn_desc;
240 El::Matrix<TensorDataType, El::Device::GPU> m_states;
242 El::Matrix<TensorDataType, El::Device::GPU> m_reserve_space;
243 #endif // LBANN_HAS_DNN_LIB 246 template <
typename T, data_layout L, El::Device D>
251 #ifndef LBANN_DROPOUT_LAYER_INSTANTIATE 252 #define PROTO_DEVICE(T, Device) \ 253 extern template class dropout<T, data_layout::DATA_PARALLEL, Device>; \ 254 extern template class dropout<T, data_layout::MODEL_PARALLEL, Device> 258 #endif // LBANN_DROPOUT_LAYER_INSTANTIATE 262 #endif // LBANN_LAYER_REGULARIZER_DROPOUT_HPP_INCLUDED dropout * copy() const override
Copy function. This function dynamically allocates memory for a layer instance and instantiates a cop...
description get_description() const override
Human-readable description.
virtual void setup_dims()
Setup tensor dimensions Called by the 'setup' function. If there are any input tensors, the base method sets all uninitialized output tensor dimensions equal to the first input tensor dimensions.
El::Device get_device_allocation() const override
Get the device allocation for the data tensors. We assume that the decice allocation of the previous ...
lbann_comm * get_comm() const
data_layout get_data_layout() const override
Get data layout of the data tensors. We assume that the data layouts of the previous activations...
void serialize(ArchiveT &ar)
std::vector< int > get_input_dims(size_t input_index=0) const
Get input tensor dimensions.
Generates nicely formatted description messages.
int get_backprop_requirements() const override
Returns the necessary tensors for computing backpropagation.
virtual description get_description() const
Human-readable description.
dropout(const dropout &other)
constexpr El::Device Device
void write_specific_proto(lbann_data::Layer &proto) const final
const OutputAbsDistMatrixType & get_activations(const Layer &child) const override
~dropout() override=default
dropout & operator=(const dropout &other)
void set_output_dims(std::vector< int > dims, size_t output_index=0)
Set output tensor dimensions.
virtual void setup_gpu()
Setup GPU objects. Called by the 'setup' function if the layer is on GPUs.
bool can_run_inplace() const override
If True, the computation can run in-place (feeding each input activations tensor as the corresponding...
std::string get_name() const
Get the layer instance's name.
void set_keep_prob(EvalType keep_prob)
set prob for keep each unit.
El::AbstractDistMatrix< TensorDataType > AbsDistMatrixType
The tensor type expected in this object.
void setup_dims() override
Setup tensor dimensions Called by the 'setup' function. If there are any input tensors, the base method sets all uninitialized output tensor dimensions equal to the first input tensor dimensions.
std::string get_type() const override
Get the layer type's name.
Probabilistically drop layer outputs.
data_layout
Data layout that is optimized for different modes of parallelism.
#define LBANN_WARNING(...)
bool using_gpus() const noexcept
Whether the layer is using a GPU implementation.
std::unique_ptr< AbsDistMatrixType > m_mask
void setup_data(size_t max_mini_batch_size) override
LBANN_DEFINE_LAYER_BUILDER(elu)
rng_gen & get_generator()
void setup_gpu() override
Setup GPU objects. Called by the 'setup' function if the layer is on GPUs.
EvalType get_keep_prob() const
get prob for keep each unit.
void fp_compute() override
Apply layer operation. Called by the 'forward_prop' function. Given the input tensors, the output tensors are populated with computed values.
data_type_layer & operator=(data_type_layer &&other)=default
dropout(EvalType keep_prob=EvalType(0.5))
void setup_data(size_t max_mini_batch_size) override
Setup layer data. Called by the 'setup' function. Memory is allocated for distributed matrices...
void bp_compute() override
Compute objective funciton gradients. Called by the 'back_prop' function. Given the input...