Commit 7c6a800b authored by Davis King's avatar Davis King

Made add_loss_layer constructor more flexible. Now you can construct

from objects that are implicitly convertible to a loss details object
just like you can for computational layers.
parent b09ddc3a
......@@ -2190,11 +2190,25 @@ namespace dlib
{
}
template <typename T, typename ...U>
struct disable_forwarding_constr
{
const static bool value = std::is_constructible<LOSS_DETAILS,T>::value;
};
template <typename ...T>
struct disable_forwarding_constr<add_loss_layer<T...>>
{
const static bool value = true;
};
template <
typename ...T,
typename = typename std::enable_if<!disable_forwarding_constr<typename std::remove_reference<T>::type...>::value>::type
>
add_loss_layer(
T ...args
T&& ...args
) :
subnetwork(std::move(args)...)
subnetwork(std::forward<T>(args)...)
{
}
......
......@@ -660,7 +660,7 @@ namespace dlib
);
/*!
ensures
- #loss_details() == layer_det
- #loss_details() == loss_details_type(layer_det)
- #subnet() == subnet_type(args)
!*/
......@@ -671,16 +671,19 @@ namespace dlib
);
/*!
ensures
- #loss_details() == layer_det
- #loss_details() == loss_details_type(layer_det)
- #subnet() == subnet_type(args)
!*/
template <typename ...T>
add_loss_layer(
T ...args
T&& ...args
);
/*!
ensures
- This version of the constructor is only called if loss_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.
- #loss_details() == loss_details_type()
- #subnet() == subnet_type(args)
!*/
......
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