Commit 3a91295e authored by Joachim's avatar Joachim
Browse files

Merge branch 'master' of https://github.com/davisking/dlib

parents 22164e5d 75f66582
......@@ -4,6 +4,7 @@
#define DLIB_THREAD_POOl_CPPh_
#include "thread_pool_extension.h"
#include <memory>
namespace dlib
{
......@@ -287,7 +288,7 @@ namespace dlib
uint64 thread_pool_implementation::
add_task_internal (
const bfp_type& bfp,
shared_ptr<function_object_copy>& item
std::shared_ptr<function_object_copy>& item
)
{
auto_mutex M(m);
......
......@@ -3,6 +3,10 @@
#ifndef DLIB_THREAD_POOl_Hh_
#define DLIB_THREAD_POOl_Hh_
#include <exception>
#include <memory>
#include <thread>
#include "thread_pool_extension_abstract.h"
#include "multithreaded_object_extension.h"
#include "../member_function_pointer.h"
......@@ -11,10 +15,6 @@
#include "auto_mutex_extension.h"
#include "../uintn.h"
#include "../array.h"
#include "../smart_pointers_thread_safe.h"
#include "../smart_pointers.h"
#include <exception>
#include <thread>
namespace dlib
{
......@@ -88,7 +88,7 @@ namespace dlib
inline void wait () const;
mutable uint64 task_id;
mutable shared_ptr_thread_safe<thread_pool_implementation> tp;
mutable std::shared_ptr<thread_pool_implementation> tp;
T var;
};
......@@ -314,7 +314,7 @@ namespace dlib
uint64 add_task_internal (
const bfp_type& bfp,
shared_ptr<function_object_copy>& item
std::shared_ptr<function_object_copy>& item
);
/*!
ensures
......@@ -326,7 +326,7 @@ namespace dlib
uint64 add_task_internal (
const bfp_type& bfp
) { shared_ptr<function_object_copy> temp; return add_task_internal(bfp, temp); }
) { std::shared_ptr<function_object_copy> temp; return add_task_internal(bfp, temp); }
/*!
ensures
- adds a task to call the given bfp object.
......@@ -452,7 +452,7 @@ namespace dlib
member_function_pointer<long,long> mfp2;
bfp_type bfp;
shared_ptr<function_object_copy> function_copy;
std::shared_ptr<function_object_copy> function_copy;
mutable std::exception_ptr eptr; // non-null if the task threw an exception
void propagate_exception() const
......@@ -489,7 +489,7 @@ namespace dlib
class thread_pool
{
/*!
This object is just a shell that holds a shared_ptr_thread_safe
This object is just a shell that holds a std::shared_ptr
to the real thread_pool_implementation object. The reason for doing
it this way is so that we can allow any mixture of destruction orders
between thread_pool objects and futures. Whoever gets destroyed
......@@ -596,7 +596,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<F>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<F>(function_object);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
......@@ -627,7 +627,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<const T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<const T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item,funct);
......@@ -644,7 +644,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item,funct);
......@@ -693,7 +693,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<F>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<F>(function_object);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, arg1.get());
......@@ -731,7 +731,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item,funct,arg1.get());
......@@ -770,7 +770,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<const T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<const T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item,funct,arg1.get());
......@@ -831,7 +831,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<F>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<F>(function_object);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, arg1.get(), arg2.get());
......@@ -877,7 +877,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, funct, arg1.get(), arg2.get());
......@@ -923,7 +923,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<const T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<const T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, funct, arg1.get(), arg2.get());
......@@ -994,7 +994,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<F>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<F>(function_object);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, arg1.get(), arg2.get(), arg3.get());
......@@ -1048,7 +1048,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, funct, arg1.get(), arg2.get(), arg3.get());
......@@ -1102,7 +1102,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<const T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<const T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, funct, arg1.get(), arg2.get(), arg3.get());
......@@ -1183,7 +1183,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<F>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<F>(function_object);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, arg1.get(), arg2.get(), arg3.get(), arg4.get());
......@@ -1245,7 +1245,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, funct, arg1.get(), arg2.get(), arg3.get(), arg4.get());
......@@ -1307,7 +1307,7 @@ namespace dlib
{
thread_pool_implementation::function_object_copy_instance<const T>* ptr = 0;
ptr = new thread_pool_implementation::function_object_copy_instance<const T>(obj);
shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
std::shared_ptr<thread_pool_implementation::function_object_copy> function_copy(ptr);
bfp_type temp;
temp.set(ptr->item, funct, arg1.get(), arg2.get(), arg3.get(), arg4.get());
......@@ -1355,7 +1355,7 @@ namespace dlib
private:
shared_ptr_thread_safe<thread_pool_implementation> impl;
std::shared_ptr<thread_pool_implementation> impl;
// restricted functions
thread_pool(thread_pool&); // copy constructor
......
......@@ -208,9 +208,9 @@ namespace dlib
// ----------------------------------------------------------------------------------------
shared_ptr_thread_safe<timer_global_clock> get_global_clock()
std::shared_ptr<timer_global_clock> get_global_clock()
{
static shared_ptr_thread_safe<timer_global_clock> d(new timer_global_clock);
static std::shared_ptr<timer_global_clock> d(new timer_global_clock);
return d;
}
......
......@@ -3,13 +3,14 @@
#ifndef DLIB_TIMEr_Hh_
#define DLIB_TIMEr_Hh_
#include <memory>
#include "../threads.h"
#include "../algs.h"
#include "../misc_api.h"
#include "timer_abstract.h"
#include "../uintn.h"
#include "../binary_search_tree.h"
#include "../smart_pointers_thread_safe.h"
#include "timer_heavy.h"
namespace dlib
......@@ -96,7 +97,7 @@ namespace dlib
mutex m;
friend shared_ptr_thread_safe<timer_global_clock> get_global_clock();
friend std::shared_ptr<timer_global_clock> get_global_clock();
private:
timer_global_clock();
......@@ -113,7 +114,7 @@ namespace dlib
- spawns timer tasks as is appropriate
!*/
};
shared_ptr_thread_safe<timer_global_clock> get_global_clock();
std::shared_ptr<timer_global_clock> get_global_clock();
/*!
ensures
- returns the global instance of the timer_global_clock object
......@@ -209,7 +210,7 @@ namespace dlib
// data members
T& ao;
const af_type af;
shared_ptr_thread_safe<timer_global_clock> gc;
std::shared_ptr<timer_global_clock> gc;
// restricted functions
timer(const timer&); // copy constructor
......
......@@ -49,7 +49,7 @@ namespace dlib
public:
// These typedefs are here for backwards compatibily with previous versions of
// These typedefs are here for backwards compatibly with previous versions of
// dlib.
typedef xml_parser kernel_1a;
typedef xml_parser kernel_1a_c;
......@@ -103,7 +103,10 @@ namespace dlib
const std::string& key
) const
{
return list[key];
if (is_in_list(key))
return list[key];
else
throw xml_attribute_list_error("No XML attribute named " + key + " is present in tag.");
}
bool at_start (
......
......@@ -6,10 +6,24 @@
#include <string>
#include "../interfaces/enumerable.h"
#include "../interfaces/map_pair.h"
#include "../error.h"
namespace dlib
{
// ----------------------------------------------------------------------------------------
class xml_attribute_list_error : public dlib::error
{
/*!
WHAT THIS OBJECT REPRESENTS
This is an exception object thrown by attribute_list objects if you try to
access a non-existent attribute.
!*/
public:
xml_attribute_list_error(const std::string& msg) : dlib::error(msg){}
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
......@@ -43,11 +57,12 @@ namespace dlib
const std::string& key
) const =0;
/*!
requires
- is_in_list(key) == true
ensures
- returns a const reference to the value associated with the
attribute named key.
if (is_in_list(key) == true) then
- returns a const reference to the value associated with the attribute
named key.
- else
- throws xml_attribute_list_error
!*/
protected:
......
......@@ -80,14 +80,6 @@
</section>
<section>
<name>Smart Pointers</name>
<item>scoped_ptr</item>
<item>shared_ptr</item>
<item>shared_ptr_thread_safe</item>
<item>weak_ptr</item>
</section>
<section>
<name>Interfaces</name>
<item>map_pair</item>
......@@ -482,29 +474,6 @@
</component>
<!-- ************************************************************************* -->
<component>
<name>weak_ptr</name>
<file>dlib/smart_pointers.h</file>
<spec_file>dlib/smart_pointers/weak_ptr_abstract.h</spec_file>
<description>
<p>
The weak_ptr class template stores a weak reference to an object that is
already managed by a shared_ptr. To access the object, a weak_ptr can
be converted to a shared_ptr using the member function lock().
</p>
<p>
This is an implementation of the std::tr1::weak_ptr template from the
document ISO/IEC PDTR 19768, Proposed Draft Technical Report on C++
Library Extensions. The only deviation from that document is that this
shared_ptr is declared inside the dlib namespace rather than std::tr1.
</p>
</description>
</component>
<!-- ************************************************************************* -->
<component>
......@@ -619,45 +588,6 @@
</description>
</component>
<!-- ************************************************************************* -->
<component>
<name>shared_ptr_thread_safe</name>
<file>dlib/smart_pointers_thread_safe.h</file>
<spec_file>dlib/smart_pointers/shared_ptr_thread_safe_abstract.h</spec_file>
<description>
<p>
This object represents a reference counted smart pointer just like
<a href="#shared_ptr">shared_ptr</a> except that it is threadsafe.
</p>
</description>
</component>
<!-- ************************************************************************* -->
<component>
<name>shared_ptr</name>
<file>dlib/smart_pointers.h</file>
<spec_file>dlib/smart_pointers/shared_ptr_abstract.h</spec_file>
<description>
<p>
This object represents a reference counted smart pointer. Each shared_ptr
contains a pointer to some object and when the last shared_ptr that points
to the object is destructed or reset() then the object is guaranteed to be
deleted.
</p>
<p>
This is an implementation of the std::tr1::shared_ptr template from the
document ISO/IEC PDTR 19768, Proposed Draft Technical Report on C++
Library Extensions. The only deviation from that document is that this
shared_ptr is declared inside the dlib namespace rather than std::tr1.
</p>
</description>
</component>
<!-- ************************************************************************* -->
<component>
......@@ -698,23 +628,6 @@
<!-- ************************************************************************* -->
<component>
<name>scoped_ptr</name>
<file>dlib/smart_pointers.h</file>
<spec_file>dlib/smart_pointers/scoped_ptr_abstract.h</spec_file>
<description>
This is a implementation of the scoped_ptr class found in the Boost C++
library. It is a simple smart pointer class which guarantees that the
pointer contained within it will always be deleted.
The class does not permit copying and so does not do any kind of
reference counting. Thus it is very simple and quite fast.
</description>
</component>
<!-- ************************************************************************* -->
<component checked="true">
<name>graph</name>
<file>dlib/graph.h</file>
......
......@@ -215,7 +215,7 @@
instead.</h3>
<ul><p>
You should not be calling new and delete in your own code. You should instead
be using objects like the std::vector, <a href="containers.html#scoped_ptr">scoped_ptr</a>,
be using objects like the std::vector, std::shared_ptr,
or any number of other objects that manage resources such as memory for you. If you want
an array use std::vector (or the checked <a href="containers.html#std_vector_c">std_vector_c</a>).
If you want to make a lookup table use a <a href="containers.html#map">map</a>. If you want
......@@ -234,7 +234,7 @@
to use the <a href="api.html#auto_mutex">auto_mutex</a> which will lock a mutex and automatically
unlock it for you. Or suppose you have made a TCP <a href="api.html#sockets">connection</a>
to another machine and you want to be certain the resources associated with that connection
are always released. You can easily accomplish this with RAII by using the scoped_ptr as
are always released. You can easily accomplish this with RAII by using the std::unique_ptr as
shown in <a href="sockstreambuf_ex.cpp.html">this</a> example program.
</p>
<p>
......@@ -271,7 +271,7 @@ double compute_sum_of_array_elements(const std::vector&lt;double&gt;&amp; array)
</p>
<p>
If you absolutely need pointer semantics then you can usually use a smart pointer like
<a href="containers.html#scoped_ptr">scoped_ptr</a> or <a href="containers.html#shared_ptr">shared_ptr</a>.
std::unique_ptr or std::shared_ptr.
If that still isn't good enough for you and you <i>really</i> need to use a normal C style pointer
then isolate your pointers inside a class or function so that they are contained in a small area of the code.
However, in practice the container classes in dlib and the STL are more than sufficient in nearly
......
......@@ -631,6 +631,7 @@
<item>get_rect</item>
<item>centered_rect</item>
<item>set_aspect_ratio</item>
<item>set_rect_area</item>
<item>center</item>
<item>dcenter</item>
<item>shrink_rect</item>
......@@ -1045,6 +1046,19 @@
</component>
<!-- ************************************************************************* -->
<component>
<name>set_rect_area</name>
<file>dlib/geometry.h</file>
<spec_file link="true">dlib/geometry/rectangle_abstract.h</spec_file>
<description>
This function reshapes a <a href="#rectangle">rectangle</a> so that
it has a user specified area.
</description>
</component>
<!-- ************************************************************************* -->
<component>
......
......@@ -1941,7 +1941,7 @@ Davis E. King. <a href="http://jmlr.csail.mit.edu/papers/volume10/king09a/king09
<component>
<name>shape_predictor_trainer</name>
<file>dlib/image_processing.h</file>
<spec_file link="true">dlib/image_processing/shape_predictor_abstract.h</spec_file>
<spec_file link="true">dlib/image_processing/shape_predictor_trainer_abstract.h</spec_file>
<description>
This object is a tool for training <a href="imaging.html#shape_predictor">shape_predictors</a>
based on annotated training images. Its implementation uses the algorithm described in:
......
......@@ -77,6 +77,7 @@
<term file="dlib/dnn/core_abstract.h.html" name="layer" include="dlib/dnn.h"/>
<term file="dlib/dnn/core_abstract.h.html" name="input_layer" include="dlib/dnn.h"/>
<term file="dlib/dnn/core_abstract.h.html" name="visit_layers" include="dlib/dnn.h"/>
<term file="dlib/dnn/core_abstract.h.html" name="visit_layers_until_tag" include="dlib/dnn.h"/>
<term file="dlib/dnn/core_abstract.h.html" name="visit_layer_parameters" include="dlib/dnn.h"/>
<term file="dlib/dnn/core_abstract.h.html" name="visit_layer_parameter_gradients" include="dlib/dnn.h"/>
<term file="dlib/dnn/core_abstract.h.html" name="visit_layers_backwards" include="dlib/dnn.h"/>
......@@ -169,6 +170,7 @@
<term file="linear_algebra.html" name="resize_rect_height" include="dlib/geometry.h"/>
<term file="linear_algebra.html" name="centered_rect" include="dlib/geometry.h"/>
<term file="linear_algebra.html" name="set_aspect_ratio" include="dlib/geometry.h"/>
<term file="linear_algebra.html" name="set_rect_area" include="dlib/geometry.h"/>
<term file="linear_algebra.html" name="center" include="dlib/geometry.h"/>
<term file="linear_algebra.html" name="nearest_point" include="dlib/geometry.h"/>
<term file="linear_algebra.html" name="nearest_rect" include="dlib/geometry.h"/>
......@@ -831,11 +833,8 @@
<term file="dlib/svm/sparse_vector_abstract.h.html" name="has_unsigned_keys" include="dlib/sparse_vector.h"/>
<term file="containers.html" name="remover" include="dlib/interfaces/remover.h"/>
<term file="containers.html" name="scoped_ptr" include="dlib/smart_pointers.h"/>
<term file="containers.html" name="set" include="dlib/set.h"/>
<term file="containers.html" name="shared_ptr" include="dlib/smart_pointers.h"/>
<term file="containers.html" name="stack" include="dlib/stack.h"/>
<term file="containers.html" name="weak_ptr" include="dlib/smart_pointers.h"/>
<term file="containers.html" name="any" include="dlib/any.h"/>
<term file="containers.html" name="any_function" include="dlib/any.h"/>
<term file="containers.html" name="any_trainer" include="dlib/any.h"/>
......@@ -1356,7 +1355,6 @@
<term file="containers.html" name="reference_counter" include="dlib/reference_counter.h"/>
<term file="containers.html" name="sequence" include="dlib/sequence.h"/>
<term file="containers.html" name="shared_ptr_thread_safe" include="dlib/smart_pointers_thread_safe.h"/>
<term file="containers.html" name="sliding_buffer" include="dlib/sliding_buffer.h"/>
<term file="containers.html" name="circular_buffer" include="dlib/sliding_buffer.h"/>
<term file="containers.html" name="static_map" include="dlib/static_map.h"/>
......
......@@ -60,6 +60,7 @@ target_link_libraries(assignment_learning_ex dlib::dlib)
# these commands from within the directory containing this CMakeLists.txt
# file:
# mkdir build
# cd build
# cmake ..
# cmake --build . --config Release
#
......
......@@ -21,13 +21,14 @@
examples and want to see a more in-depth example then by all means, continue reading. :)
*/
#include <dlib/gui_widgets.h>
#include <memory>
#include <sstream>
#include <string>
#include <dlib/gui_widgets.h>
#include <dlib/directed_graph.h>
#include <dlib/string.h>
#include <dlib/bayes_utils.h>
#include <dlib/smart_pointers.h>
#include <dlib/set.h>
#include <dlib/graph_utils.h>
#include <dlib/stl_checked.h>
......@@ -123,7 +124,7 @@ private:
widget_group cpt_group;
widget_group ppt_group;
scoped_ptr<bayesian_network_join_tree> solution;
std::unique_ptr<bayesian_network_join_tree> solution;
join_tree_type join_tree;
// The std_vector_c is an object identical to the std::vector except that it checks
// all its preconditions and throws a dlib::fatal_error if they are violated.
......
......@@ -19,10 +19,10 @@
dnn_metric_learning_on_images_ex.cpp examples.
*/
#include <dlib/dnn.h>
#include <dlib/gui_widgets.h>
#include <dlib/clustering.h>
#include <dlib/string.h>
#include <dlib/dnn.h>
#include <dlib/image_io.h>
#include <dlib/image_processing/frontal_face_detector.h>
......@@ -42,6 +42,7 @@ using namespace std;
// mini-batches were made larger (35x15 instead of 5x5), the iterations without progress
// was set to 10000, the jittering you can see below in jitter_image() was used during
// training, and the training dataset consisted of about 3 million images instead of 55.
// Also, the input layer was locked to images of size 150.
template <template <int,template<typename>class,int,typename> class block, int N, template<typename>class BN, typename SUBNET>
using residual = add_prev1<block<N,BN,1,tag1<SUBNET>>>;
......
......@@ -267,7 +267,6 @@ int main(int argc, char** argv) try
//dnn_trainer<net_type,adam> trainer(net,adam(0.0005, 0.9, 0.999), {0,1});
trainer.be_verbose();
trainer.set_synchronization_file("mnist_resnet_sync", std::chrono::seconds(100));
// While the trainer is running it keeps an eye on the training error. If
// it looks like the error hasn't decreased for the last 2000 iterations it
// will automatically reduce the learning rate by 0.1. You can change these
......@@ -277,6 +276,7 @@ int main(int argc, char** argv) try
trainer.set_learning_rate_shrink_factor(0.1);
// The learning rate will start at 1e-3.
trainer.set_learning_rate(1e-3);
trainer.set_synchronization_file("mnist_resnet_sync", std::chrono::seconds(100));
// Now, what if your training dataset is so big it doesn't fit in RAM? You
......
......@@ -157,6 +157,11 @@ int main(int argc, char** argv) try
cout << "testing num_wrong: " << num_wrong << endl;
cout << "testing accuracy: " << num_right/(double)(num_right+num_wrong) << endl;
// Finally, you can also save network parameters to XML files if you want to do
// something with the network in another tool. For example, you could use dlib's
// tools/convert_dlib_nets_to_caffe to convert the network to a caffe model.
net_to_xml(net, "lenet.xml");
}
catch(std::exception& e)
{
......
......@@ -15,9 +15,11 @@
http://www.jmarshall.com/easy/http/
*/
#include <iostream>
#include <memory>
#include <dlib/sockets.h>
#include <dlib/sockstreambuf.h>
#include <iostream>
using namespace std;
using namespace dlib;
......@@ -31,7 +33,7 @@ int main()
// are using a smart pointer here to contain the connection pointer
// returned from connect. Doing this ensures that the connection
// is deleted even if someone throws an exception somewhere in your code.
scoped_ptr<connection> con(connect("www.google.com",80));
std::unique_ptr<connection> con(connect("www.google.com",80));
{
......
......@@ -23,6 +23,7 @@ To exclude/include certain options in the cmake config use --yes and --no:
--yes DLIB_NO_GUI_SUPPORT: will set -DDLIB_NO_GUI_SUPPORT=yes
--no DLIB_NO_GUI_SUPPORT: will set -DDLIB_NO_GUI_SUPPORT=no
Additional options:
--compiler-flags: pass flags onto the compiler, e.g. --compiler-flag "-Os -Wall" passes -Os -Wall onto GCC.
--debug: makes a debug build
--cmake: path to specific cmake executable
--G or -G: name of a build system generator (equivalent of passing -G "name" to cmake)
......@@ -79,6 +80,8 @@ def _get_options():
for opt_idx, arg in enumerate(argv):
if opt_key == 'cmake':
_cmake_path = arg
elif opt_key == 'compiler-flags':
_cmake_extra.append('-DCMAKE_CXX_FLAGS={arg}'.format(arg=arg.strip()))
elif opt_key == 'yes':
_cmake_extra.append('-D{arg}=yes'.format(arg=arg.strip()))
elif opt_key == 'no':
......@@ -107,7 +110,7 @@ def _get_options():
opt_key = opt
sys.argv.remove(arg)
continue
elif opt in ['yes', 'no']:
elif opt in ['yes', 'no', 'compiler-flags']:
opt_key = opt
sys.argv.remove(arg)
continue
......
#
# This is a CMake makefile. You can find the cmake utility and
# information about it at http://www.cmake.org
#
cmake_minimum_required(VERSION 2.8.12)
set (target_name dtoc)
PROJECT(${target_name})
include(../../dlib/cmake)
ADD_EXECUTABLE(${target_name}
main.cpp
)
TARGET_LINK_LIBRARIES(${target_name} dlib::dlib )
INSTALL(TARGETS ${target_name}
RUNTIME DESTINATION bin
)
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