Commit 9482271e authored by Davis King's avatar Davis King

Made it so you can skip giving layer detail objects to a network's constructor

if they should be default constructed.
parent 3f542861
......@@ -589,6 +589,25 @@ namespace dlib
subnetwork->disable_output_and_gradient_getters();
}
template <typename T, typename ...U>
struct details_constructable_from : public std::is_constructible<LAYER_DETAILS,T> {};
template <
typename ...T,
typename = typename std::enable_if<!details_constructable_from<T...>::value>::type
>
add_layer(
T&& ...args
) :
subnetwork(new subnet_type(std::forward<T>(args)...)),
this_layer_setup_called(false),
gradient_input_is_stale(true),
get_output_and_gradient_input_disabled(false)
{
if (this_layer_operates_inplace())
subnetwork->disable_output_and_gradient_getters();
}
template <typename ...T>
add_layer(
LAYER_DETAILS&& layer_det,
......
......@@ -235,6 +235,19 @@ namespace dlib
- #subnet() == subnet_type(args)
!*/
template <typename ...T>
add_layer(
T&& ...args
);
/*!
ensures
- This version of the constructor is only called if layer_details_type
can't be constructed from the first thing in args. In this case, the
args are simply passed on to the sub layers in their entirety.
- #layer_details() == layer_details_type()
- #subnet() == subnet_type(args)
!*/
template <typename ...T>
add_layer(
layer_details_type&& layer_det,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment