diff --git a/dlib/dnn.h b/dlib/dnn.h index c5ded7770..bc38dc4b7 100644 --- a/dlib/dnn.h +++ b/dlib/dnn.h @@ -31,6 +31,7 @@ #include "cuda/tensor_tools.h" #include "dnn/utilities.h" #include "dnn/validation.h" +#include "dnn/visitors.h" #endif // DLIB_DNn_ diff --git a/dlib/dnn/visitors.h b/dlib/dnn/visitors.h new file mode 100644 index 000000000..832129004 --- /dev/null +++ b/dlib/dnn/visitors.h @@ -0,0 +1,518 @@ +// Copyright (C) 2022 Davis E. King (davis@dlib.net) +// License: Boost Software License See LICENSE.txt for the full license. +#ifndef DLIB_DNn_VISITORS_H_ +#define DLIB_DNn_VISITORS_H_ + +#include "input.h" +#include "layers.h" +#include "loss.h" + +namespace dlib +{ + namespace impl + { + class visitor_net_to_dot + { + public: + + visitor_net_to_dot(std::ostream& out) : out(out) {} + +// ---------------------------------------------------------------------------------------- + + template + void operator()(size_t i, input_layer_type& l) + { + start_node(i, "input"); + end_node(); + from = i; + } + +// ---------------------------------------------------------------------------------------- + + template + void operator()(size_t i, const add_loss_layer&) + { + start_node(i, "loss"); + end_node(); + update(i); + } + +// ---------------------------------------------------------------------------------------- + + template