From e4d9026358aad2e4f3f03d1bca3570780d40914a Mon Sep 17 00:00:00 2001 From: "Gun.io Whitespace Robot" Date: Wed, 21 Dec 2011 19:35:36 -0500 Subject: [PATCH] Remove whitespace [Gun.io WhitespaceBot] --- SConstruct | 24 +- docs/Doxyfile | 1178 ++++++++--------- examples/mdrnn/mnist.cpp | 16 +- examples/xor/xor.cpp | 12 +- src/cpp/common/buffer.h | 32 +- src/cpp/common/common.h | 2 +- src/cpp/datasets/datasets.h | 4 +- src/cpp/datasets/sequence.cpp | 6 +- src/cpp/datasets/sequence.h | 12 +- src/cpp/datasets/supervised.h | 40 +- src/cpp/datasets/unsupervised.h | 30 +- src/cpp/optimization/backprop.cpp | 30 +- src/cpp/optimization/backprop.h | 84 +- src/cpp/optimization/descent/descender.cpp | 6 +- src/cpp/optimization/descent/descender.h | 40 +- .../optimization/descent/stepdescender.cpp | 8 +- src/cpp/optimization/descent/stepdescender.h | 40 +- src/cpp/structure/component.cpp | 2 +- src/cpp/structure/component.h | 128 +- .../connections/blockpermutation.cpp | 4 +- .../structure/connections/blockpermutation.h | 14 +- src/cpp/structure/connections/connection.cpp | 8 +- src/cpp/structure/connections/connection.h | 62 +- src/cpp/structure/connections/convolve.cpp | 38 +- src/cpp/structure/connections/convolve.h | 18 +- src/cpp/structure/connections/full.cpp | 60 +- src/cpp/structure/connections/full.h | 28 +- src/cpp/structure/connections/identity.cpp | 14 +- src/cpp/structure/connections/identity.h | 14 +- src/cpp/structure/connections/inconvolve.cpp | 38 +- src/cpp/structure/connections/inconvolve.h | 18 +- src/cpp/structure/connections/linear.cpp | 16 +- src/cpp/structure/connections/linear.h | 24 +- src/cpp/structure/connections/outconvolve.cpp | 40 +- src/cpp/structure/connections/outconvolve.h | 18 +- src/cpp/structure/connections/permutation.cpp | 14 +- src/cpp/structure/connections/permutation.h | 30 +- src/cpp/structure/modules/bias.cpp | 2 +- src/cpp/structure/modules/bias.h | 6 +- src/cpp/structure/modules/cosine.cpp | 14 +- src/cpp/structure/modules/cosine.h | 2 +- src/cpp/structure/modules/doublegate.cpp | 6 +- src/cpp/structure/modules/doublegate.h | 8 +- src/cpp/structure/modules/errorscaling.cpp | 6 +- src/cpp/structure/modules/errorscaling.h | 6 +- src/cpp/structure/modules/gate.cpp | 4 +- src/cpp/structure/modules/gate.h | 6 +- src/cpp/structure/modules/linear.h | 4 +- src/cpp/structure/modules/lstm.cpp | 20 +- src/cpp/structure/modules/lstm.h | 14 +- src/cpp/structure/modules/mdlstm.cpp | 50 +- src/cpp/structure/modules/mdlstm.h | 40 +- src/cpp/structure/modules/module.cpp | 16 +- src/cpp/structure/modules/module.h | 42 +- src/cpp/structure/modules/multiplication.h | 6 +- src/cpp/structure/modules/partialsoftmax.h | 12 +- src/cpp/structure/modules/sigmoid.h | 6 +- src/cpp/structure/modules/softmax.h | 4 +- src/cpp/structure/modules/switch.h | 6 +- src/cpp/structure/modules/tanh.h | 8 +- src/cpp/structure/networks/basenetwork.cpp | 12 +- src/cpp/structure/networks/basenetwork.h | 26 +- .../structure/networks/mdrnns/basemdrnn.cpp | 4 +- src/cpp/structure/networks/mdrnns/basemdrnn.h | 8 +- src/cpp/structure/networks/mdrnns/mdrnn.cpp | 42 +- src/cpp/structure/networks/mdrnns/mdrnn.h | 110 +- src/cpp/structure/networks/network.cpp | 60 +- src/cpp/structure/networks/network.h | 28 +- src/cpp/structure/parametrized.cpp | 14 +- src/cpp/structure/parametrized.h | 42 +- src/cpp/tests/test_datasets.cpp | 40 +- src/cpp/tests/test_optimzation.cpp | 60 +- src/cpp/tests/test_structure.cpp | 648 ++++----- src/cpp/tests/test_utilities.cpp | 22 +- src/cpp/utilities/utilities.cpp | 74 +- src/cpp/utilities/utilities.h | 4 +- src/swig/cppbridge.i | 252 ++-- 77 files changed, 1943 insertions(+), 1943 deletions(-) diff --git a/SConstruct b/SConstruct index f6e85b6..b5b8891 100644 --- a/SConstruct +++ b/SConstruct @@ -15,7 +15,7 @@ if sys.platform == 'darwin': elif sys.platform == 'linux2': libname = 'libarac.so' frameworksflags = '' - linkflags = '' + linkflags = '' else: raise SystemExit("Cannot build on %s." % sys.platform) @@ -27,15 +27,15 @@ NUMPYPATH = numpy.distutils.misc_util.get_numpy_include_dirs() # First compile and link the library. libenv = Environment(LIBS=['m', 'blas'], CPPPATH=CPPPATH, LIBPATH=LIBPATH, SHLIBPREFIX="", CCFLAGS=CCFLAGS) -library_globs = ['src/cpp/*.cpp', - 'src/cpp/common/*.cpp', - 'src/cpp/utilities/*.cpp', - 'src/cpp/datasets/*.cpp', - 'src/cpp/optimization/*.cpp', - 'src/cpp/optimization/descent/*.cpp', - 'src/cpp/structure/*.cpp', - 'src/cpp/structure/connections/*.cpp', - 'src/cpp/structure/modules/*.cpp', +library_globs = ['src/cpp/*.cpp', + 'src/cpp/common/*.cpp', + 'src/cpp/utilities/*.cpp', + 'src/cpp/datasets/*.cpp', + 'src/cpp/optimization/*.cpp', + 'src/cpp/optimization/descent/*.cpp', + 'src/cpp/structure/*.cpp', + 'src/cpp/structure/connections/*.cpp', + 'src/cpp/structure/modules/*.cpp', 'src/cpp/structure/networks/*.cpp', 'src/cpp/structure/networks/mdrnns/*.cpp'] lib = libenv.SharedLibrary(libname, sum([Glob(i) for i in library_globs], [])) @@ -51,10 +51,10 @@ swigenv = Environment(SWIGFLAGS=['-python', '-c++', '-outdir', 'src/python/arac' FRAMEWORKSFLAGS=frameworksflags, LINKFLAGS=linkflags, LIBPATH=LIBPATH, - LDMODULEPREFIX='src/python/arac/_', + LDMODULEPREFIX='src/python/arac/_', LDMODULESUFFIX = '.so', ) -swig = swigenv.LoadableModule('cppbridge', +swig = swigenv.LoadableModule('cppbridge', ['src/swig/cppbridge.i']) # Declare some dependencies. diff --git a/docs/Doxyfile b/docs/Doxyfile index 51dc790..1d2ffa7 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -14,211 +14,211 @@ # Project related configuration options #--------------------------------------------------------------------------- -# This tag specifies the encoding used for all characters in the config file -# that follow. The default is UTF-8 which is also the encoding used for all -# text before the first occurrence of this tag. Doxygen uses libiconv (or the -# iconv built into libc) for the transcoding. See +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = arac -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = output -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, -# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), -# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, -# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, # and Ukrainian. OUTPUT_LANGUAGE = English -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. -STRIP_FROM_INC_PATH = +STRIP_FROM_INC_PATH = -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like regular Qt-style comments +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO -# If the QT_AUTOBRIEF tag is set to YES then Doxygen will -# interpret the first line (until the first dot) of a Qt-style -# comment as the brief description. If set to NO, the comments -# will behave just like regular Qt-style comments (thus requiring +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member +# If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = NO -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO -# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for -# Java. For instance, namespaces will be presented as packages, qualified +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO -# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran -# sources only. Doxygen will then generate output that is more tailored for +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO -# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL -# sources. Doxygen will then generate output that is tailored for +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want -# to include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO @@ -228,42 +228,42 @@ BUILTIN_STL_SUPPORT = NO CPP_CLI_SUPPORT = NO -# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. -# Doxygen will parse them like normal C++ but will assume all classes use public +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO -# For Microsoft's IDL there are propget and propput attributes to indicate getter -# and setter methods for a property. Setting this option to YES (the default) -# will make doxygen to replace the get and set methods by a property in the -# documentation. This will only work if the methods are indeed getting or -# setting a simple type. If this is not the case, or you want to show the +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES -# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum -# is documented as struct, union, or enum with the name of the typedef. So -# typedef struct TypeS {} TypeT, will appear in the documentation as a struct -# with name TypeT. When disabled the typedef will appear as a member of a file, -# namespace, or class. And the struct will be named TypeS. This can typically -# be useful for C code in case the coding convention dictates that all compound +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO @@ -272,368 +272,368 @@ TYPEDEF_HIDES_STRUCT = NO # Build related configuration options #--------------------------------------------------------------------------- -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO -# If the EXTRACT_STATIC tag is set to YES all static members of a file +# If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO -# If this flag is set to YES, the members of anonymous namespaces will be -# extracted and appear in the documentation as a namespace called -# 'anonymous_namespace{file}', where file will be replaced with the base -# name of the file that contains the anonymous namespace. By default +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO -# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the -# hierarchy of group names into alphabetical order. If set to NO (the default) +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the +# Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES -# The ENABLED_SECTIONS tag can be used to enable conditional +# The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. -ENABLED_SECTIONS = +ENABLED_SECTIONS = -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. -# This will remove the Files entry from the Quick Index and from the +# This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES -# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from -# the version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. -FILE_VERSION_FILTER = +FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- -# The QUIET tag can be used to turn on/off the messages that are generated +# The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../src/cpp/ +INPUT = ../src/cpp/ -# This tag can be used to specify the character encoding of the source files -# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is -# also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 -FILE_PATTERNS = +FILE_PATTERNS = -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = +EXCLUDE = -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the -# output. The symbol name can be a fully qualified name, a word, or if the -# wildcard * is used, a substring. Examples: ANamespace, AClass, +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = +IMAGE_PATH = -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. -INPUT_FILTER = +INPUT_FILTER = -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. -FILTER_PATTERNS = +FILTER_PATTERNS = -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO @@ -642,32 +642,32 @@ FILTER_SOURCE_FILES = NO # configuration options related to source browsing #--------------------------------------------------------------------------- -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO -# Setting the INLINE_SOURCES tag to YES will include the body +# Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES -# If the REFERENCED_BY_RELATION tag is set to YES -# then for each documented function all documented +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO -# If the REFERENCES_RELATION tag is set to YES -# then for each documented function all documented entities +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO @@ -679,16 +679,16 @@ REFERENCES_RELATION = NO REFERENCES_LINK_SOURCE = YES -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES @@ -697,129 +697,129 @@ VERBATIM_HEADERS = YES # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a # standard header. -HTML_HEADER = +HTML_HEADER = -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a # standard footer. -HTML_FOOTER = +HTML_FOOTER = -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! -HTML_STYLESHEET = +HTML_STYLESHEET = -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO -# If the GENERATE_DOCSET tag is set to YES, additional index files -# will be generated that can be used as input for Apple's Xcode 3 -# integrated development environment, introduced with OSX 10.5 (Leopard). -# To create a documentation set, doxygen will generate a Makefile in the -# HTML output directory. Running make will produce the docset in that -# directory and running "make install" will install the docset in -# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. GENERATE_DOCSET = NO -# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the -# feed. A documentation feed provides an umbrella under which multiple -# documentation sets from a single provider (such as a company or product suite) +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" -# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that -# should uniquely identify the documentation set bundle. This should be a -# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project -# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML -# documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. -HHC_LOCATION = +HHC_LOCATION = -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO @@ -828,26 +828,26 @@ GENERATE_CHI = NO # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. -CHM_INDEX_ENCODING = +CHM_INDEX_ENCODING = -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO -# The TOC_EXPAND flag can be set to YES to add extra items for group members +# The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO -# This tag can be used to set the number of enum values (range [1..20]) +# This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 @@ -855,11 +855,11 @@ ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to FRAME, a side panel will be generated -# containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. Other possible values +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values # for this tag are: HIERARCHIES, which will generate the Groups, Directories, # and Class Hiererachy pages using a tree view instead of an ordered list; # ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which @@ -869,16 +869,16 @@ ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = NONE -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 -# Use this tag to change the font size of Latex formulas included -# as images in the HTML documentation. The default is 10. Note that -# when you change the font size after a successful doxygen run you need -# to manually remove any form_*.png images from the HTML output directory +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 @@ -887,74 +887,74 @@ FORMULA_FONTSIZE = 10 # configuration options related to the LaTeX output #--------------------------------------------------------------------------- -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. -EXTRA_PACKAGES = +EXTRA_PACKAGES = -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! -LATEX_HEADER = +LATEX_HEADER = -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO @@ -963,68 +963,68 @@ LATEX_HIDE_INDICES = NO # configuration options related to the RTF output #--------------------------------------------------------------------------- -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. -RTF_STYLESHEET_FILE = +RTF_STYLESHEET_FILE = -# Set optional variables used in the generation of an rtf document. +# Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. -RTF_EXTENSIONS_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man -# The MAN_EXTENSION tag determines the extension that is added to +# The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO @@ -1033,33 +1033,33 @@ MAN_LINKS = NO # configuration options related to the XML output #--------------------------------------------------------------------------- -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +XML_SCHEMA = -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +XML_DTD = -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES @@ -1068,10 +1068,10 @@ XML_PROGRAMLISTING = YES # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO @@ -1080,338 +1080,338 @@ GENERATE_AUTOGEN_DEF = NO # configuration options related to the Perl module output #--------------------------------------------------------------------------- -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. -PERLMOD_MAKEVAR_PREFIX = +PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- -# Configuration options related to the preprocessor +# Configuration options related to the preprocessor #--------------------------------------------------------------------------- -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = +INCLUDE_PATH = -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. -INCLUDE_FILE_PATTERNS = +INCLUDE_FILE_PATTERNS = -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator # instead of the = operator. -PREDEFINED = +PREDEFINED = -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. -EXPAND_AS_DEFINED = +EXPAND_AS_DEFINED = -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- -# Configuration::additions related to external references +# Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen +# If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. -TAGFILES = +TAGFILES = -# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES -# The PERL_PATH should be the absolute path and name of the perl script +# The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- -# Configuration options related to the dot tool +# Configuration options related to the dot tool #--------------------------------------------------------------------------- -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see -# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the -# documentation. The MSCGEN_PATH tag allows you to specify the directory where -# the mscgen tool resides. If left empty the tool is assumed to be found in the +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +MSCGEN_PATH = -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO -# By default doxygen will write a font called FreeSans.ttf to the output -# directory and reference it in all dot files that doxygen generates. This -# font does not include all possible unicode characters however, so when you need -# these (or just want a differently looking font) you can specify the font name -# using DOT_FONTNAME. You need need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = FreeSans -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. -DOT_FONTPATH = +DOT_FONTPATH = -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO -# If set to YES, the inheritance and collaboration graphs will show the +# If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT options are set to YES then -# doxygen will generate a call dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable call graphs +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then -# doxygen will generate a caller dependency graph for every global function -# or class method. Note that enabling this option will significantly increase -# the time of a run. So in most cases it will be better to enable caller +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png -# The tag DOT_PATH can be used to specify the path where the dot tool can be +# The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. -DOT_PATH = +DOT_PATH = -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the # \dotfile command). -DOTFILE_DIRS = +DOTFILE_DIRS = -# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen if the -# number of direct children of the root node in a graph is already larger than -# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that the size of a graph can be further restricted by +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is enabled by default, which results in a transparent -# background. Warning: Depending on the platform used, enabling this option -# may lead to badly anti-aliased labels on the edges of a graph (i.e. they +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is enabled by default, which results in a transparent +# background. Warning: Depending on the platform used, enabling this option +# may lead to badly anti-aliased labels on the edges of a graph (i.e. they # become hard to read). DOT_TRANSPARENT = YES -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::additions related to the search engine +# Configuration::additions related to the search engine #--------------------------------------------------------------------------- -# The SEARCHENGINE tag specifies whether or not a search engine should be +# The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO diff --git a/examples/mdrnn/mnist.cpp b/examples/mdrnn/mnist.cpp index b70ba6d..fe283e5 100644 --- a/examples/mdrnn/mnist.cpp +++ b/examples/mdrnn/mnist.cpp @@ -22,10 +22,10 @@ SupervisedDataset make_dataset() SupervisedDataset ds(insize, insize * outsize); double* sample_p = new double[insize]; double* target_p = new double[outsize]; - + memset(sample_p, 0, sizeof(double) * insize); memset(target_p, 0, sizeof(double) * outsize * insize); - + ds.append(sample_p, target_p); return ds; } @@ -35,15 +35,15 @@ Network make_network() { int hidden = 5; Network net; - + Mdrnn* inlayer_p = new Mdrnn(2, hidden); - + inlayer_p->set_sequence_shape(0, 28); inlayer_p->set_sequence_shape(1, 28); inlayer_p->set_block_shape(0, 1); inlayer_p->set_block_shape(1, 1); inlayer_p->sort(); - + PartialSoftmaxLayer* outlayer_p = \ new PartialSoftmaxLayer(insize * outsize, outsize); @@ -55,16 +55,16 @@ Network make_network() << std::endl; WeightShareConnection* con_p = new WeightShareConnection( - inlayer_p, outlayer_p, + inlayer_p, outlayer_p, hidden, outsize); net.add_module(inlayer_p, Network::InputModule); net.add_module(outlayer_p, Network::OutputModule); net.add_connection(con_p); - + net.randomize(); - + return net; } diff --git a/examples/xor/xor.cpp b/examples/xor/xor.cpp index 848d12b..81e4a14 100644 --- a/examples/xor/xor.cpp +++ b/examples/xor/xor.cpp @@ -19,7 +19,7 @@ SupervisedDataset make_dataset() data_p[0] = 0; data_p[1] = 0; data_p[2] = 0; - + data_p[3] = 0; data_p[4] = 1; data_p[5] = 1; @@ -31,12 +31,12 @@ SupervisedDataset make_dataset() data_p[9] = 1; data_p[10] = 1; data_p[11] = 0; - + ds.append(data_p, data_p + 2); ds.append(data_p + 3, data_p + 5); ds.append(data_p + 6, data_p + 8); ds.append(data_p + 9, data_p + 11); - + return ds; } @@ -51,7 +51,7 @@ Network make_network() FullConnection* con1_p = new FullConnection(inlayer_p, hidden_p); FullConnection* con2_p = new FullConnection(hidden_p, outlayer_p); FullConnection* con3_p = new FullConnection(bias_p, hidden_p); - + net.add_module(inlayer_p, Network::InputModule); net.add_module(hidden_p); net.add_module(bias_p); @@ -59,9 +59,9 @@ Network make_network() net.add_connection(con1_p); net.add_connection(con2_p); net.add_connection(con3_p); - + net.randomize(); - + return net; } diff --git a/src/cpp/common/buffer.h b/src/cpp/common/buffer.h index aa2989b..71bed61 100644 --- a/src/cpp/common/buffer.h +++ b/src/cpp/common/buffer.h @@ -16,35 +16,35 @@ namespace arac { namespace common { /// -/// Buffer objects hold pointers to arrays which are serving as -/// inputs/outputs/errors/etc. to modules. +/// Buffer objects hold pointers to arrays which are serving as +/// inputs/outputs/errors/etc. to modules. /// /// A buffer is organized in different rows which are held as a vector of double -/// pointers. -/// A buffer may either "own" its arrays or not own them. In the first case, the -/// buffer frees the memory of the arrays on destruction. +/// pointers. +/// A buffer may either "own" its arrays or not own them. In the first case, the +/// buffer frees the memory of the arrays on destruction. /// class Buffer { public: - + Buffer(size_t rowsize, bool owner=true); virtual ~Buffer(); - + /// /// Add the contents at the given pointer to the last buffer row. If an /// index is given, the content will be added to that buffer row. /// void add(double* addend_p, int index=-1); - + /// /// Append an empty row to the buffer's contents. /// void expand(); - + /// - /// Set all the contents to zero. + /// Set all the contents to zero. /// void clear(); @@ -58,9 +58,9 @@ class Buffer /// does not own the memory. /// void free_memory(); - + /// - /// Add the given pointer as a row. Attention: This removes ownership + /// Add the given pointer as a row. Attention: This removes ownership /// for all buffers. /// void append(double* row); @@ -112,7 +112,7 @@ class Buffer bool _contmemory; // Index that says up to which row the buffer has been used recently. Is - // being reset by .clear() and clear_at(). Is updated by append(), + // being reset by .clear() and clear_at(). Is updated by append(), // add and operator []. // The index is an exclusive upper bound. size_t _dirtyindex; @@ -128,7 +128,7 @@ Buffer::rowsize() } -inline +inline void Buffer::set_rowsize(size_t value) { @@ -137,13 +137,13 @@ Buffer::set_rowsize(size_t value) inline -size_t +size_t Buffer::size() { return _content.size(); } - + inline double* Buffer::operator[] (size_t index) diff --git a/src/cpp/common/common.h b/src/cpp/common/common.h index caa1109..e3d6be6 100644 --- a/src/cpp/common/common.h +++ b/src/cpp/common/common.h @@ -14,7 +14,7 @@ namespace arac { namespace common { - + typedef std::vector DoublePtrVec; diff --git a/src/cpp/datasets/datasets.h b/src/cpp/datasets/datasets.h index d823b78..b5ee277 100644 --- a/src/cpp/datasets/datasets.h +++ b/src/cpp/datasets/datasets.h @@ -12,13 +12,13 @@ namespace arac { namespace datasets { - + typedef SupervisedDataset SupervisedSequentialDataset; typedef SupervisedDataset SupervisedSemiSequentialDataset; typedef SupervisedDataset SupervisedSimpleDataset; typedef UnsupervisedDataset UnsupervisedSimpleDataset; typedef UnsupervisedDataset UnsupervisedSequenceDataset; - + } } // Namespace diff --git a/src/cpp/datasets/sequence.cpp b/src/cpp/datasets/sequence.cpp index 5cc5d1b..ce541e0 100644 --- a/src/cpp/datasets/sequence.cpp +++ b/src/cpp/datasets/sequence.cpp @@ -12,11 +12,11 @@ Sequence::Sequence(int length, int itemsize, double* data_p) : _length(length), _itemsize(itemsize), _data_p(data_p) -{ +{ } -Sequence::~Sequence() +Sequence::~Sequence() { - + } \ No newline at end of file diff --git a/src/cpp/datasets/sequence.h b/src/cpp/datasets/sequence.h index 45b316e..07dacb0 100644 --- a/src/cpp/datasets/sequence.h +++ b/src/cpp/datasets/sequence.h @@ -12,19 +12,19 @@ namespace arac { namespace datasets { - -class Sequence + +class Sequence { public: - + Sequence(int length, int itemsize, double* data_p); virtual ~Sequence(); - + int length() const; int itemsize() const; double* operator[](int index); - + private: int _length; int _itemsize; @@ -32,7 +32,7 @@ class Sequence }; -inline +inline int Sequence::length() const { diff --git a/src/cpp/datasets/supervised.h b/src/cpp/datasets/supervised.h index e25e9fe..92d9bbf 100644 --- a/src/cpp/datasets/supervised.h +++ b/src/cpp/datasets/supervised.h @@ -13,34 +13,34 @@ namespace arac { namespace datasets { - + /// -/// SupervisedDataset objects hold pairs of data, each of possibly different +/// SupervisedDataset objects hold pairs of data, each of possibly different /// types. /// template class SupervisedDataset : public UnsupervisedDataset { - public: - + public: + /// /// Create a new SupervisedDataset object with the given samplesize and /// the given targetsize. /// SupervisedDataset(int samplesize, int targetsize); - - /// + + /// /// Destroy the SupervisedDataset object. /// virtual ~SupervisedDataset(); - + /// /// Return the amount of rows in the dataset. /// virtual int size(); - + /// /// Return the the size of a target. /// @@ -50,7 +50,7 @@ class SupervisedDataset : public UnsupervisedDataset /// Add another row to the dataset. /// void append(SampleType sample, TargetType target); - + /// /// Return the (sample, target) pair of the dataset at the given index. /// @@ -61,7 +61,7 @@ class SupervisedDataset : public UnsupervisedDataset /// bool has_importance(); - /// + /// /// Return the importance of a sample/target pair. /// TargetType importance(int index); @@ -70,15 +70,15 @@ class SupervisedDataset : public UnsupervisedDataset /// Set the importance of a sample/target pair. /// void set_importance(int index, TargetType importance); - + private: - + /// /// Size of a single target. /// int _targetsize; - - /// + + /// /// Vector that holds the (sample, target) pairs. /// std::vector > _rows; @@ -96,20 +96,20 @@ class SupervisedDataset : public UnsupervisedDataset template -SupervisedDataset::SupervisedDataset(int samplesize, +SupervisedDataset::SupervisedDataset(int samplesize, int targetsize) : UnsupervisedDataset(samplesize), _targetsize(targetsize), _has_importance(false) { - + } template SupervisedDataset::~SupervisedDataset() { - + } @@ -133,7 +133,7 @@ SupervisedDataset::append( template -std::pair& +std::pair& SupervisedDataset::operator[](int index) { assert(index < size()); @@ -161,7 +161,7 @@ SupervisedDataset::importance(int index) template inline void -SupervisedDataset::set_importance(int index, +SupervisedDataset::set_importance(int index, TargetType importance) { _has_importance = true; @@ -172,7 +172,7 @@ SupervisedDataset::set_importance(int index, template inline -int +int SupervisedDataset::size() { return _rows.size(); diff --git a/src/cpp/datasets/unsupervised.h b/src/cpp/datasets/unsupervised.h index 5fb3c1b..1745b34 100644 --- a/src/cpp/datasets/unsupervised.h +++ b/src/cpp/datasets/unsupervised.h @@ -11,28 +11,28 @@ namespace arac { namespace datasets { - + /// /// UnsupervisedDataset objects hold single data rows. /// template -class UnsupervisedDataset +class UnsupervisedDataset { - public: + public: /// /// Create a new UnsupervisedDataset object where each sample is of /// the given samplesize. /// UnsupervisedDataset(int samplesize); - + /// /// Destroy the UnsupervisedDataset object. /// virtual ~UnsupervisedDataset(); - + /// /// Return the the size of a sample. /// @@ -42,24 +42,24 @@ class UnsupervisedDataset /// Return the number of rows currently in the dataset. /// virtual int size(); - + /// /// Return a reference to the sample at the given index. /// const SampleType& operator[](int index); - + private: - + /// /// The size of a sample. /// int _samplesize; - + /// /// Vector that holds the samples in the dataset. /// std::vector _rows; - + }; @@ -67,19 +67,19 @@ template UnsupervisedDataset::UnsupervisedDataset(int samplesize) : _samplesize(samplesize) { - + } template UnsupervisedDataset::~UnsupervisedDataset() { - + } template inline -int +int UnsupervisedDataset::samplesize() { return _samplesize; @@ -88,7 +88,7 @@ UnsupervisedDataset::samplesize() template inline -int +int UnsupervisedDataset::size() { return _rows.size(); @@ -97,7 +97,7 @@ UnsupervisedDataset::size() template inline -const SampleType& +const SampleType& UnsupervisedDataset::operator[](int index) { return _rows[index]; diff --git a/src/cpp/optimization/backprop.cpp b/src/cpp/optimization/backprop.cpp index 2d85dce..0ce0b12 100644 --- a/src/cpp/optimization/backprop.cpp +++ b/src/cpp/optimization/backprop.cpp @@ -15,10 +15,10 @@ using arac::optimization::SequentialBackprop; using arac::structure::Parametrized; -SimpleBackprop::SimpleBackprop(BaseNetwork& network, +SimpleBackprop::SimpleBackprop(BaseNetwork& network, SupervisedDataset& dataset) : - Backprop(network, dataset) {} - + Backprop(network, dataset) {} + SimpleBackprop::~SimpleBackprop() {} @@ -50,7 +50,7 @@ SimpleBackprop::process_sample(double* sample_p, double* target_p, SemiSequentialBackprop::SemiSequentialBackprop( BaseNetwork& network, SupervisedDataset& dataset) : - Backprop(network, dataset) + Backprop(network, dataset) { _output_p = new double[dataset.targetsize()]; } @@ -68,7 +68,7 @@ SemiSequentialBackprop::process_sample(Sequence input, double* target_p) for (int i = 0; i < input.length(); i++) { const double* output_p = network().activate(input[i]); - // Sum the outputs + // Sum the outputs for (int j = 0; j < dataset().targetsize(); j++) { _output_p[j] += output_p[j]; @@ -88,7 +88,7 @@ SemiSequentialBackprop::process_sample(Sequence input, double* target_p) void -SemiSequentialBackprop::process_sample(Sequence input, double* target_p, +SemiSequentialBackprop::process_sample(Sequence input, double* target_p, double* importance_p) { memset(_output_p, 0, sizeof(double) * dataset().targetsize()); @@ -97,7 +97,7 @@ SemiSequentialBackprop::process_sample(Sequence input, double* target_p, for (int i = 0; i < input.length(); i++) { const double* output_p = network().activate(input[i]); - // Sum the outputs + // Sum the outputs for (int j = 0; j < dataset().targetsize(); j++) { _output_p[j] += output_p[j]; @@ -117,7 +117,7 @@ SemiSequentialBackprop::process_sample(Sequence input, double* target_p, SequentialBackprop::SequentialBackprop( - BaseNetwork& network, + BaseNetwork& network, SupervisedDataset& dataset) : Backprop(network, dataset) {} @@ -125,7 +125,7 @@ SequentialBackprop::SequentialBackprop( SequentialBackprop::~SequentialBackprop() {} -void +void SequentialBackprop::process_sample(Sequence input, Sequence target) { // Process the sequence and save the outputs. @@ -137,8 +137,8 @@ SequentialBackprop::process_sample(Sequence input, Sequence target) // Iterate over the outputs and targets in parallel. std::vector::const_reverse_iterator output_iter; int i = target.length() - 1; - for (output_iter = _outputs.rbegin(); - output_iter != _outputs.rend(); + for (output_iter = _outputs.rbegin(); + output_iter != _outputs.rend(); output_iter++) { // Calculate the error for this timestep. @@ -152,10 +152,10 @@ SequentialBackprop::process_sample(Sequence input, Sequence target) i -= 1; } } - -void -SequentialBackprop::process_sample(Sequence input, Sequence target, + +void +SequentialBackprop::process_sample(Sequence input, Sequence target, Sequence importance) { // Process the sequence and save the outputs. @@ -167,7 +167,7 @@ SequentialBackprop::process_sample(Sequence input, Sequence target, // Iterate over the outputs and targets in parallel. std::vector::const_reverse_iterator output_iter; int i = target.length() - 1; - for (output_iter = _outputs.rbegin(); + for (output_iter = _outputs.rbegin(); output_iter != _outputs.rend(); output_iter++) { diff --git a/src/cpp/optimization/backprop.h b/src/cpp/optimization/backprop.h index 26db3ad..ce52494 100644 --- a/src/cpp/optimization/backprop.h +++ b/src/cpp/optimization/backprop.h @@ -25,8 +25,8 @@ using arac::optimization::descent::StepDescender; namespace arac { namespace optimization { - - + + /// /// Template class for Backprop optimizers. /// @@ -36,30 +36,30 @@ namespace optimization { template class Backprop { - public: - + public: + /// /// Backprop implementaion specific dataset type on which a network /// is to be trained. /// typedef SupervisedDataset DatasetType; - + /// /// Create a new Backprop optimizer object with which the given network /// can be trained on the given dataset. /// Backprop(BaseNetwork& network, DatasetType& dataset); - + /// /// Destroy the Backprop object. /// virtual ~Backprop(); - + /// /// Return a reference to the network of the optimizer. /// BaseNetwork& network(); - + /// /// Return a reference to the dataset of the optimizer. /// @@ -69,21 +69,21 @@ class Backprop /// Return the learningrate of the trainer. /// double learningrate(); - + /// /// Set the learningrate of the trainer. /// - void set_learningrate(const double value); + void set_learningrate(const double value); /// /// Return the momentum of the trainer. /// double momentum(); - + /// /// Set the momentum of the trainer. /// - void set_momentum(const double value); + void set_momentum(const double value); /// /// Return a pointer to the last error vector. @@ -94,7 +94,7 @@ class Backprop /// Return a pointer to the last loss. /// double loss(); - + /// /// Pick a random sample from the dataset and perform one step of /// backpropagation. @@ -112,9 +112,9 @@ class Backprop /// former is to be implemented by subclasses. /// void train_stochastic_batch(); - + protected: - + /// /// Adapt the parameters of this network. /// @@ -124,36 +124,36 @@ class Backprop /// Network to be optimized optimizer. /// BaseNetwork& _network; - + /// /// Dataset the network is to be optimized upon. /// DatasetType& _dataset; - + /// /// Descender object that is used to follow the gradient. /// // TODO: this should be of the abstract Descender class. StepDescender _descender; - + /// /// The last error during process_sample. /// double* _error_p; - + /// /// Method that processes a sample from the dataset and its target. This - /// method has to be implemented for each (SampleType, TargetType) + /// method has to be implemented for each (SampleType, TargetType) /// combination. /// virtual void process_sample(SampleType inpt, TargetType target) = 0; - + /// - /// Method that processes a sample from the dataset and its target, - /// additionally scaling the error at the targets according to an + /// Method that processes a sample from the dataset and its target, + /// additionally scaling the error at the targets according to an /// importance. - /// - virtual void process_sample(SampleType inpt, TargetType target, + /// + virtual void process_sample(SampleType inpt, TargetType target, TargetType importance) = 0; private: @@ -164,7 +164,7 @@ class Backprop template -Backprop::Backprop(BaseNetwork& network, +Backprop::Backprop(BaseNetwork& network, DatasetType& dataset) : _network(network), _dataset(dataset), @@ -199,7 +199,7 @@ Backprop::dataset() { return _dataset; } - + template double @@ -254,7 +254,7 @@ void Backprop::train_stochastic() { int index = rand() % dataset().size(); - + network().clear(); network().clear_derivatives(); SampleType sample = dataset()[index].first; @@ -294,14 +294,14 @@ Backprop::train_stochastic_batch() } std::vector::const_iterator index_iter; - for (index_iter = indices.begin(); + for (index_iter = indices.begin(); index_iter != indices.end(); ++index_iter) { int index = *index_iter; network().clear(); network().clear_derivatives(); - + SampleType sample = dataset()[index].first; TargetType target = dataset()[index].second; if (dataset().has_importance()) @@ -313,7 +313,7 @@ Backprop::train_stochastic_batch() this->process_sample(sample, target); } learn(); - + // Update loss. for (int i = 0; i < network().outsize(); ++i) { @@ -324,7 +324,7 @@ Backprop::train_stochastic_batch() template -void +void Backprop::learn() { _descender.notify(); @@ -337,17 +337,17 @@ Backprop::learn() /// -/// SimpleBackprop optimizers are used to train a feedforward network on a +/// SimpleBackprop optimizers are used to train a feedforward network on a /// dataset that consists of independet sample and target vectors. /// - -class SimpleBackprop : public Backprop + +class SimpleBackprop : public Backprop { public: - SimpleBackprop(BaseNetwork& network, + SimpleBackprop(BaseNetwork& network, SupervisedDataset& dataset); ~SimpleBackprop(); - + protected: virtual void process_sample(double* input_p, double* target_p); virtual void process_sample(double* input_p, double* target_p, @@ -356,13 +356,13 @@ class SimpleBackprop : public Backprop /// -/// SemiSequentialBackprop optimizers are used to train networks that map +/// SemiSequentialBackprop optimizers are used to train networks that map /// sequences to vectors. /// class SemiSequentialBackprop : public Backprop { - + public: SemiSequentialBackprop(BaseNetwork& network, SupervisedDataset& dataset); @@ -385,7 +385,7 @@ class SemiSequentialBackprop : public Backprop class SequentialBackprop : public Backprop { public: - SequentialBackprop(BaseNetwork& network, + SequentialBackprop(BaseNetwork& network, SupervisedDataset& dataset); ~SequentialBackprop(); @@ -393,13 +393,13 @@ class SequentialBackprop : public Backprop virtual void process_sample(Sequence input, Sequence target); virtual void process_sample(Sequence input, Sequence target, Sequence importance); - + private: std::vector _outputs; }; - + } } diff --git a/src/cpp/optimization/descent/descender.cpp b/src/cpp/optimization/descent/descender.cpp index 38a9fc9..a04e2e0 100644 --- a/src/cpp/optimization/descent/descender.cpp +++ b/src/cpp/optimization/descent/descender.cpp @@ -19,8 +19,8 @@ Descender::Descender(BaseNetwork& network) { _targets.push_back(*param_iter); } - - + + } @@ -32,5 +32,5 @@ Descender::Descender(Parametrized& parametrized) Descender::~Descender() { - + } \ No newline at end of file diff --git a/src/cpp/optimization/descent/descender.h b/src/cpp/optimization/descent/descender.h index 543319c..a90c9c0 100644 --- a/src/cpp/optimization/descent/descender.h +++ b/src/cpp/optimization/descent/descender.h @@ -13,54 +13,54 @@ namespace arac { namespace optimization { namespace descent { - - + + /// -/// Class for performing a gradient descent on Network and Parametrized +/// Class for performing a gradient descent on Network and Parametrized /// objects. /// -/// The descender watches objects and when .update() is called, inspects the +/// The descender watches objects and when .update() is called, inspects the /// the objects derivatives, possibly performing an update. (A descender might /// decide not to update always.) -/// - +/// + class Descender { public: - + /// - /// Create a Descender object that watches a Network object and the + /// Create a Descender object that watches a Network object and the /// contained Network and Parametrized objects. /// Descender(arac::structure::networks::BaseNetwork& net); - + /// /// Create a Descender object that watches a Parametrized object. /// Descender(arac::structure::Parametrized& parametrized); - + /// /// Destroy the Descender object. /// virtual ~Descender(); - - /// + + /// /// Return a vector of watched Parametrized objects. /// std::vector& targets(); - + /// - /// Notify the Descender object that the derivatives of the watched - /// objects have changed. If the Descender object performs an update, + /// Notify the Descender object that the derivatives of the watched + /// objects have changed. If the Descender object performs an update, /// true is returned, otherwise false. /// /// Must be implemented by subclass. virtual bool notify() = 0; - + private: - + std::vector _targets; - + }; @@ -70,8 +70,8 @@ Descender::targets() { return _targets; } - - + + } } } // Namespace. diff --git a/src/cpp/optimization/descent/stepdescender.cpp b/src/cpp/optimization/descent/stepdescender.cpp index acbf330..6e59899 100644 --- a/src/cpp/optimization/descent/stepdescender.cpp +++ b/src/cpp/optimization/descent/stepdescender.cpp @@ -13,7 +13,7 @@ using arac::optimization::descent::Descender; using arac::optimization::descent::StepDescender; -StepDescender::StepDescender(BaseNetwork& network, +StepDescender::StepDescender(BaseNetwork& network, double stepratio, double momentum) : Descender(network), _stepratio(stepratio), @@ -23,7 +23,7 @@ StepDescender::StepDescender(BaseNetwork& network, } -StepDescender::StepDescender(Parametrized& parametrized, +StepDescender::StepDescender(Parametrized& parametrized, double stepratio, double momentum) : Descender(parametrized), _stepratio(stepratio), @@ -43,7 +43,7 @@ StepDescender::init_updatehistory() { _n_params = 0; std::vector::iterator param_iter; - for (param_iter = targets().begin(); + for (param_iter = targets().begin(); param_iter != targets().end(); param_iter++) { @@ -75,6 +75,6 @@ StepDescender::notify() // Apply update. param.get_parameters()[j] += update; } - } + } return true; } diff --git a/src/cpp/optimization/descent/stepdescender.h b/src/cpp/optimization/descent/stepdescender.h index f37c5bb..fcfda41 100644 --- a/src/cpp/optimization/descent/stepdescender.h +++ b/src/cpp/optimization/descent/stepdescender.h @@ -15,57 +15,57 @@ namespace arac { namespace optimization { namespace descent { - - + + /// -/// The StepDescender follows the derivatives with a step that is defined by +/// The StepDescender follows the derivatives with a step that is defined by /// the magnitude of the derivative times the stepratio of the StepDescender /// object. -/// - +/// + class StepDescender : public Descender { public: - + /// - /// Create a Descender object that watches a Network object and the + /// Create a Descender object that watches a Network object and the /// contained Network and Parametrized objects. /// - StepDescender(arac::structure::networks::BaseNetwork& net, + StepDescender(arac::structure::networks::BaseNetwork& net, double stepratio, double momentum=0.0); - + /// /// Create a Descender object that watches a Parametrized object. /// StepDescender(arac::structure::Parametrized& parametrized, double stepratio, double momentum=0.0); - + /// /// Destroy the Descender object. /// virtual ~StepDescender(); - + /// - /// Perform an update on the parameters by moving a step along the + /// Perform an update on the parameters by moving a step along the /// derivative. The stepsize is given by the magnitude of the derivative /// and the stepratio. /// virtual bool notify(); - + /// /// Return the current stepratio. /// double stepratio(); - + /// /// Set the current stepratio. /// void set_stepratio(const double stepratio); - - - /// + + + /// /// Return the momentum. /// double momentum(); @@ -74,11 +74,11 @@ class StepDescender : public Descender /// Set the momentum. /// void set_momentum(const double value); - + private: - + void init_updatehistory(); - + double _stepratio; double _momentum; double* _updates_p; diff --git a/src/cpp/structure/component.cpp b/src/cpp/structure/component.cpp index 893fc67..3bd394c 100644 --- a/src/cpp/structure/component.cpp +++ b/src/cpp/structure/component.cpp @@ -7,7 +7,7 @@ namespace arac { namespace structure { -Component::Component() : +Component::Component() : _timestep(0), _sequencelength(0), _mode(Component::Simple) diff --git a/src/cpp/structure/component.h b/src/cpp/structure/component.h index 389edb7..0ce88b0 100644 --- a/src/cpp/structure/component.h +++ b/src/cpp/structure/component.h @@ -10,30 +10,30 @@ namespace arac { namespace structure { -/// -/// A Component object is the very basic part of an arac architecture. +/// +/// A Component object is the very basic part of an arac architecture. /// /// Each component is characterized by its forward and backward methods, which -/// are processing data in a network of arac components. +/// are processing data in a network of arac components. /// -/// The process of feeding information forward is done via the forward method, +/// The process of feeding information forward is done via the forward method, /// while propagating errors back is done via the backward method. /// /// Components also have a mode: a sequential component can keep a history of /// the processed data and thus incorporate time delay features in contrast to a -/// non sequential component. A component that is error agnostic ignores any -/// behaviour that has to do with backpropagation. For example, it does not +/// non sequential component. A component that is error agnostic ignores any +/// behaviour that has to do with backpropagation. For example, it does not /// backwards its own errors and does not calculate derivatives. /// -class Component +class Component { - public: - + public: + /// /// The modes a component can be in, /// - enum Mode + enum Mode { /// The component is not sequential and is not error agnostic. Simple = 0, @@ -42,107 +42,107 @@ class Component /// The component is sequential and does not ignore errors. Sequential = 2, - /// SequentialErrorAgnostic - the component is sequential and + /// SequentialErrorAgnostic - the component is sequential and SequentialErrorAgnostic = 3, }; - + Component(); - + virtual ~Component(); - + /// /// Run the forward pass of a component. - /// + /// virtual void forward(); - - /// + + /// /// Run the forward pass of a component. - /// + /// virtual void backward(); - - /// + + /// /// Run the side effects of a components forward pass. - /// + /// virtual void dry_forward(); - - /// + + /// /// Run the side effects of a components backward pass. - /// + /// virtual void dry_backward(); - - /// + + /// /// Set the mode of the module. virtual void set_mode(Mode mode); - - /// + + /// /// Set the timestep to zero. virtual void clear(); - - /// + + /// /// Get the mode of the module. - /// + /// Mode get_mode(); - - /// + + /// /// Tell if the module is sequential. - /// + /// bool sequential(); - - /// + + /// /// Return the current timestep. - /// + /// int timestep(); - /// + /// /// Return the sequence length of the current sequence. - /// + /// int sequencelength(); - - /// + + /// /// Tell if the module is error agnostic. - /// + /// bool error_agnostic(); - + protected: - /// + /// /// Run the side effects of a component before the actual forward. - /// + /// virtual void pre_forward(); - /// + /// /// Run the side effects of a component before the actual backward. - /// + /// virtual void pre_backward(); - /// + /// /// Run the side effects of a component after the actual forward. - /// + /// virtual void post_forward(); - /// + /// /// Run the side effects of a component after the actual backward. - /// + /// virtual void post_backward(); - /// - /// Do the actual forward. This method should be implemented by + /// + /// Do the actual forward. This method should be implemented by /// subclasses. - /// + /// virtual void _forward() = 0; - - /// - /// Do the actual Backward. This method should be implemented by + + /// + /// Do the actual Backward. This method should be implemented by /// subclasses. - /// + /// virtual void _backward() = 0; private: - + int _timestep; int _sequencelength; Mode _mode; - + }; @@ -157,7 +157,7 @@ Component::forward() inline -void +void Component::backward() { pre_backward(); @@ -237,7 +237,7 @@ Component::post_backward() } -inline +inline Component::Mode Component::get_mode() { @@ -245,7 +245,7 @@ Component::get_mode() } -inline +inline void Component::set_mode(Component::Mode mode) { @@ -278,7 +278,7 @@ Component::sequencelength() inline -bool +bool Component::error_agnostic() { return _mode & Component::ErrorAgnostic; diff --git a/src/cpp/structure/connections/blockpermutation.cpp b/src/cpp/structure/connections/blockpermutation.cpp index 4c56100..a67fbf6 100644 --- a/src/cpp/structure/connections/blockpermutation.cpp +++ b/src/cpp/structure/connections/blockpermutation.cpp @@ -15,7 +15,7 @@ using arac::utilities::block_permutation; BlockPermutationConnection::BlockPermutationConnection( - Module* incoming_p, Module* outgoing_p, + Module* incoming_p, Module* outgoing_p, std::vector sequence_shape, std::vector block_shape) : PermutationConnection(incoming_p, outgoing_p) @@ -30,5 +30,5 @@ BlockPermutationConnection::BlockPermutationConnection( BlockPermutationConnection::~BlockPermutationConnection() { - + } diff --git a/src/cpp/structure/connections/blockpermutation.h b/src/cpp/structure/connections/blockpermutation.h index 0979510..8e28e86 100644 --- a/src/cpp/structure/connections/blockpermutation.h +++ b/src/cpp/structure/connections/blockpermutation.h @@ -14,7 +14,7 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; @@ -24,22 +24,22 @@ using namespace arac::structure::modules; class BlockPermutationConnection : public PermutationConnection { - public: - + public: + /// /// Create a new PermutationConnection object. /// - BlockPermutationConnection(Module* incoming_p, Module* outgoing_p, + BlockPermutationConnection(Module* incoming_p, Module* outgoing_p, std::vector sequence_shape, std::vector block_shape); - /// + /// /// Destroy the PermutationConnection object. /// virtual ~BlockPermutationConnection(); -}; +}; + - } } } diff --git a/src/cpp/structure/connections/connection.cpp b/src/cpp/structure/connections/connection.cpp index 124ff1f..75ee530 100644 --- a/src/cpp/structure/connections/connection.cpp +++ b/src/cpp/structure/connections/connection.cpp @@ -9,7 +9,7 @@ using arac::structure::connections::Connection; Connection::Connection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) : _incoming_p(incoming_p), _outgoing_p(outgoing_p), @@ -23,7 +23,7 @@ Connection::Connection(Module* incoming_p, Module* outgoing_p, assert(_incomingstop <= incoming()->outsize()); assert(_outgoingstart <= outgoing()->insize()); assert(_outgoingstop <= outgoing()->insize()); -} +} Connection::Connection(Module* incoming_p, Module* outgoing_p) : @@ -35,13 +35,13 @@ Connection::Connection(Module* incoming_p, Module* outgoing_p) : _outgoingstop(outgoing_p->insize()), _recurrent(false) { - + } Connection::~Connection() { - + } diff --git a/src/cpp/structure/connections/connection.h b/src/cpp/structure/connections/connection.h index ff30690..a579590 100644 --- a/src/cpp/structure/connections/connection.h +++ b/src/cpp/structure/connections/connection.h @@ -16,79 +16,79 @@ namespace arac { namespace structure { namespace connections { - - + + using namespace arac::structure::modules; -/// +/// /// A connection connects two modules by taking the ouput of the incoming /// module, transforming it and adding it to the input of the outgoing module. /// /// It is possible to connect only parts of two modules. For example, one could -/// connect the second half of the incoming module to the first half of the +/// connect the second half of the incoming module to the first half of the /// outgoing module. /// class Connection : public arac::structure::Component { - public: - + public: + /// /// Create a new connection object. The exact slices of the connections /// can be specified by setting the indices; the default is to connect /// over the full length. - /// + /// Connection(Module* incoming, Module* outgoing, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); Connection(Module* incoming, Module* outgoing); virtual ~Connection(); - + /// /// Set the incoming start index. /// void set_incomingstart(int n); - + /// /// Set the incoming stop index. /// void set_incomingstop(int n); - + /// /// Set the outgoing start index. /// void set_outgoingstart(int n); - + /// /// Set the outgoing stop index. /// void set_outgoingstop(int n); - + /// /// Return the incoming start index. /// int get_incomingstart(); - + /// /// Return the incoming stop index. /// int get_incomingstop(); - + /// /// Return the outgoing start index. /// int get_outgoingstart(); - + /// /// Return the outgoing stop index. /// int get_outgoingstop(); - + /// /// Set the grade of recurrency. /// void set_recurrent(int recurrent); - + /// /// Return the grade of recurrency. /// @@ -98,38 +98,38 @@ class Connection : public arac::structure::Component /// Return a pointer to the incoming module. /// Module* incoming(); - + /// /// Return a pointer to the outgoing module. /// Module* outgoing(); - + protected: - + void _forward(); void _backward(); virtual void forward_process(double* sink_p, const double* source_p) = 0; virtual void backward_process(double* sink_p, const double* source_p) = 0; - + Module* _incoming_p; Module* _outgoing_p; - + int _incomingstart; int _incomingstop; int _outgoingstart; int _outgoingstop; - + int _recurrent; }; - - + + inline void Connection::set_incomingstart(int n) { _incomingstart = n; - + } @@ -178,7 +178,7 @@ int Connection::get_outgoingstart() { return _outgoingstart; - + } @@ -208,7 +208,7 @@ Connection::set_recurrent(int recurrent) inline -Module* +Module* Connection::incoming() { return _incoming_p; @@ -216,13 +216,13 @@ Connection::incoming() inline -Module* +Module* Connection::outgoing() { return _outgoing_p; } - + } } } diff --git a/src/cpp/structure/connections/convolve.cpp b/src/cpp/structure/connections/convolve.cpp index a388734..829bf38 100644 --- a/src/cpp/structure/connections/convolve.cpp +++ b/src/cpp/structure/connections/convolve.cpp @@ -19,7 +19,7 @@ using arac::structure::Parametrized; using arac::structure::modules::Module; -ConvolveConnection::ConvolveConnection(Module* incoming_p, Module* outgoing_p, +ConvolveConnection::ConvolveConnection(Module* incoming_p, Module* outgoing_p, int inchunk, int outchunk) : Connection(incoming_p, outgoing_p), Parametrized(inchunk * outchunk), @@ -36,7 +36,7 @@ ConvolveConnection::ConvolveConnection(Module* incoming_p, Module* outgoing_p, ConvolveConnection::~ConvolveConnection() { - + } @@ -46,29 +46,29 @@ ConvolveConnection::forward_process(double* sink_p, const double* source_p) for (int i = 0; i < _n_chunks; i++) { cblas_dgemv( - CblasRowMajor, - // Do not transpose the matrix since we want to multiply from + CblasRowMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix - _outchunk, + _outchunk, _inchunk, // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector _inchunk, // Pointer to the vector source_p + (i * _inchunk), // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p + (i * _outchunk), // Incrementer. - 1); + 1); } } @@ -78,36 +78,36 @@ ConvolveConnection::backward_process(double* sink_p, const double* source_p) { int indim = _incomingstop - _incomingstart; int outdim = _outgoingstop - _outgoingstart; - + double* input_p = _incoming_p->output()[timestep() - 1] \ + _incomingstart; double* derivs_p = get_derivatives(); for (int i = 0; i < _n_chunks; i++) { - cblas_dgemv(CblasColMajor, - // Do not transpose the matrix since we want to multiply from + cblas_dgemv(CblasColMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix - _inchunk, + _inchunk, _outchunk, // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector _inchunk, // Pointer to the vector source_p + (i * _outchunk), // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p + (i * _inchunk), // Incrementer. - 1); + 1); for (int j = 0; j < _outchunk; j++) { diff --git a/src/cpp/structure/connections/convolve.h b/src/cpp/structure/connections/convolve.h index 55803d7..cc44db9 100644 --- a/src/cpp/structure/connections/convolve.h +++ b/src/cpp/structure/connections/convolve.h @@ -16,7 +16,7 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; using arac::structure::Parametrized; @@ -27,12 +27,12 @@ using arac::structure::Parametrized; class ConvolveConnection : public Connection, public Parametrized { - public: - + public: + /// /// Create a new ConvolveConnection object. /// - ConvolveConnection(Module* incoming_p, Module* outgoing_p, + ConvolveConnection(Module* incoming_p, Module* outgoing_p, int inchunk, int outchunk); /// @@ -41,12 +41,12 @@ class ConvolveConnection : public Connection, public Parametrized /// ConvolveConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p); - - /// + + /// /// Destroy the ConvolveConnection object. /// virtual ~ConvolveConnection(); - + protected: virtual void forward_process(double* sink_p, const double* source_p); virtual void backward_process(double* sink_p, const double* source_p); @@ -54,8 +54,8 @@ class ConvolveConnection : public Connection, public Parametrized int _n_chunks; int _inchunk; int _outchunk; -}; - +}; + } } } diff --git a/src/cpp/structure/connections/full.cpp b/src/cpp/structure/connections/full.cpp index f63fd61..2b46662 100644 --- a/src/cpp/structure/connections/full.cpp +++ b/src/cpp/structure/connections/full.cpp @@ -22,35 +22,35 @@ FullConnection::FullConnection(Module* incoming_p, Module* outgoing_p) : Connection(incoming_p, outgoing_p), Parametrized(incoming_p->outsize() * outgoing_p->insize()) { - + } FullConnection::FullConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) : - Connection(incoming_p, outgoing_p, - incomingstart, incomingstop, + Connection(incoming_p, outgoing_p, + incomingstart, incomingstop, outgoingstart, outgoingstop), Parametrized((incomingstop - incomingstart) * (outgoingstop - outgoingstart)) { - + } FullConnection::FullConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) : - Connection(incoming_p, outgoing_p, + Connection(incoming_p, outgoing_p, incomingstart, incomingstop, outgoingstart, outgoingstop), Parametrized((incomingstop - incomingstart) * (outgoingstop - outgoingstart), - parameters_p, derivatives_p) + parameters_p, derivatives_p) { -} +} + - FullConnection::~FullConnection() { } @@ -62,29 +62,29 @@ FullConnection::forward_process(double* sink_p, const double* source_p) int indim = _incomingstop - _incomingstart; int outdim = _outgoingstop - _outgoingstart; - cblas_dgemv(CblasRowMajor, - // Do not transpose the matrix since we want to multiply from + cblas_dgemv(CblasRowMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix - outdim, + outdim, indim, // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector indim, // Pointer to the vector source_p, // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p, // Incrementer. - 1); + 1); } @@ -92,42 +92,42 @@ void FullConnection::backward_process(double* sink_p, const double* source_p) { int indim = _incomingstop - _incomingstart; int outdim = _outgoingstop - _outgoingstart; - + double* input_p = _incoming_p->output()[incoming()->timestep() - 1] \ + _incomingstart; - cblas_dgemv(CblasColMajor, - // Do not transpose the matrix since we want to multiply from + cblas_dgemv(CblasColMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix - indim, + indim, outdim, // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector indim, // Pointer to the vector source_p, // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p, // Incrementer. - 1); + 1); - cblas_dger(CblasColMajor, + cblas_dger(CblasColMajor, indim, outdim, 1.0, input_p, - 1, + 1, source_p, - 1, + 1, get_derivatives(), indim); } diff --git a/src/cpp/structure/connections/full.h b/src/cpp/structure/connections/full.h index 1e6d6e3..74b8b0b 100644 --- a/src/cpp/structure/connections/full.h +++ b/src/cpp/structure/connections/full.h @@ -15,21 +15,21 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; using arac::structure::Parametrized; /// -/// FullConnection objects connect two layers by connecting each component of -/// the input to each component of the output, weighted by an individual +/// FullConnection objects connect two layers by connecting each component of +/// the input to each component of the output, weighted by an individual /// parameter. /// class FullConnection : public Connection, public Parametrized { - public: - + public: + /// /// Create a new FullConnection object. /// @@ -39,29 +39,29 @@ class FullConnection : public Connection, public Parametrized /// Create a new FullConnection object of the given slices. /// FullConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); - + /// /// Create a new FullConnection object of the given slices and use the /// supplied arrays as parameters and derivatives. /// FullConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); - - /// + + /// /// Destroy the FullConnection object. /// virtual ~FullConnection(); - + protected: - + virtual void forward_process(double* sink_p, const double* source_p); virtual void backward_process(double* sink_p, const double* source_p); -}; - +}; + } } } diff --git a/src/cpp/structure/connections/identity.cpp b/src/cpp/structure/connections/identity.cpp index babaff6..3592cbe 100644 --- a/src/cpp/structure/connections/identity.cpp +++ b/src/cpp/structure/connections/identity.cpp @@ -16,24 +16,24 @@ using arac::structure::modules::Module; IdentityConnection::IdentityConnection(Module* incoming_p, Module* outgoing_p) : Connection(incoming_p, outgoing_p) { - + } IdentityConnection::IdentityConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) : - Connection(incoming_p, outgoing_p, - incomingstart, incomingstop, + Connection(incoming_p, outgoing_p, + incomingstart, incomingstop, outgoingstart, outgoingstop) { - + } IdentityConnection::~IdentityConnection() { - + } @@ -42,7 +42,7 @@ IdentityConnection::forward_process(double* sink_p, const double* source_p) { int indim = _incomingstop - _incomingstart; int outdim = _outgoingstop - _outgoingstart; - + int size = (_incomingstop - _incomingstart); for(int i = 0; i < size; i++) { diff --git a/src/cpp/structure/connections/identity.h b/src/cpp/structure/connections/identity.h index 17f5e9f..bd16f08 100644 --- a/src/cpp/structure/connections/identity.h +++ b/src/cpp/structure/connections/identity.h @@ -14,7 +14,7 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; using arac::structure::Component; @@ -23,13 +23,13 @@ using arac::structure::Component; /// An identity connection connects two modules by adding the output of the /// íncoming module to the input of the outgoing module. /// -class IdentityConnection : public Connection +class IdentityConnection : public Connection { public: - + /// /// Create a new IdentityConnection between two modules, where the - /// output size of the incoming module equals the input size of the + /// output size of the incoming module equals the input size of the /// outgoing module. /// IdentityConnection(Module* incoming_p, Module* outgoing_p); @@ -39,12 +39,12 @@ class IdentityConnection : public Connection /// be of the same length. /// IdentityConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); virtual ~IdentityConnection(); - + protected: - + virtual void forward_process(double* sink_p, const double* source_p); virtual void backward_process(double* sink_p, const double* source_p); }; diff --git a/src/cpp/structure/connections/inconvolve.cpp b/src/cpp/structure/connections/inconvolve.cpp index d0c2e5b..e0dab39 100644 --- a/src/cpp/structure/connections/inconvolve.cpp +++ b/src/cpp/structure/connections/inconvolve.cpp @@ -19,7 +19,7 @@ using arac::structure::Parametrized; using arac::structure::modules::Module; -InConvolveConnection::InConvolveConnection(Module* incoming_p, Module* outgoing_p, +InConvolveConnection::InConvolveConnection(Module* incoming_p, Module* outgoing_p, int chunk) : Connection(incoming_p, outgoing_p), Parametrized(chunk * outgoing_p->insize()), @@ -33,7 +33,7 @@ InConvolveConnection::InConvolveConnection(Module* incoming_p, Module* outgoing_ InConvolveConnection::~InConvolveConnection() { - + } @@ -43,29 +43,29 @@ InConvolveConnection::forward_process(double* sink_p, const double* source_p) for (int i = 0; i < _n_chunks; i++) { cblas_dgemv( - CblasRowMajor, - // Do not transpose the matrix since we want to multiply from + CblasRowMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix - _outgoing_p->insize(), + _outgoing_p->insize(), _chunk, // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector _chunk, // Pointer to the vector source_p + (i * _chunk), // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p, // Incrementer. - 1); + 1); } } @@ -75,36 +75,36 @@ InConvolveConnection::backward_process(double* sink_p, const double* source_p) { int indim = _incomingstop - _incomingstart; int outdim = _outgoingstop - _outgoingstart; - + double* input_p = _incoming_p->output()[timestep() - 1] \ + _incomingstart; double* derivs_p = get_derivatives(); for (int i = 0; i < _n_chunks; i++) { - cblas_dgemv(CblasColMajor, - // Do not transpose the matrix since we want to multiply from + cblas_dgemv(CblasColMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix - _chunk, + _chunk, _outgoing_p->insize(), // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector _chunk, // Pointer to the vector source_p, // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p + (i * _chunk), // Incrementer. - 1); + 1); for (int j = 0; j < _outgoing_p->insize(); j++) { diff --git a/src/cpp/structure/connections/inconvolve.h b/src/cpp/structure/connections/inconvolve.h index 5850fc8..7c604af 100644 --- a/src/cpp/structure/connections/inconvolve.h +++ b/src/cpp/structure/connections/inconvolve.h @@ -16,7 +16,7 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; using arac::structure::Parametrized; @@ -27,12 +27,12 @@ using arac::structure::Parametrized; class InConvolveConnection : public Connection, public Parametrized { - public: - + public: + /// /// Create a new InConvolveConnection object. /// - InConvolveConnection(Module* incoming_p, Module* outgoing_p, + InConvolveConnection(Module* incoming_p, Module* outgoing_p, int inchunk); /// @@ -41,20 +41,20 @@ class InConvolveConnection : public Connection, public Parametrized /// InConvolveConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p); - - /// + + /// /// Destroy the InConvolveConnection object. /// virtual ~InConvolveConnection(); - + protected: virtual void forward_process(double* sink_p, const double* source_p); virtual void backward_process(double* sink_p, const double* source_p); int _n_chunks; int _chunk; -}; - +}; + } } } diff --git a/src/cpp/structure/connections/linear.cpp b/src/cpp/structure/connections/linear.cpp index 6bc8a9e..734d154 100644 --- a/src/cpp/structure/connections/linear.cpp +++ b/src/cpp/structure/connections/linear.cpp @@ -22,10 +22,10 @@ LinearConnection::LinearConnection(Module* incoming_p, Module* outgoing_p) : LinearConnection::LinearConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) : - Connection(incoming_p, outgoing_p, - incomingstart, incomingstop, + Connection(incoming_p, outgoing_p, + incomingstart, incomingstop, outgoingstart, outgoingstop), Parametrized(incoming_p->insize()) { @@ -35,17 +35,17 @@ LinearConnection::LinearConnection(Module* incoming_p, Module* outgoing_p, LinearConnection::LinearConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) : - Connection(incoming_p, outgoing_p, + Connection(incoming_p, outgoing_p, incomingstart, incomingstop, outgoingstart, outgoingstop), - Parametrized((incomingstop - incomingstart), parameters_p, derivatives_p) + Parametrized((incomingstop - incomingstart), parameters_p, derivatives_p) { // TODO: make sure the sizes of the modules and slices are correct. -} +} + - LinearConnection::~LinearConnection() { if (parameters_owner()) diff --git a/src/cpp/structure/connections/linear.h b/src/cpp/structure/connections/linear.h index 89b3f87..6654ed6 100644 --- a/src/cpp/structure/connections/linear.h +++ b/src/cpp/structure/connections/linear.h @@ -15,21 +15,21 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; using arac::structure::Parametrized; -/// -/// A LinearConnection is a parametrized connection which processes the input +/// +/// A LinearConnection is a parametrized connection which processes the input /// from the incoming module to the outgoing module by multiplying it with a -/// specific parameter for each component. +/// specific parameter for each component. /// class LinearConnection : public Connection, public Parametrized { - public: - + public: + /// /// Create a new LinearConnection object. The outsize of the incoming /// module and the insize of the outgoing module have to be equal. @@ -41,7 +41,7 @@ class LinearConnection : public Connection, public Parametrized /// length. /// LinearConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); /// @@ -50,16 +50,16 @@ class LinearConnection : public Connection, public Parametrized /// LinearConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); virtual ~LinearConnection(); - + protected: - + virtual void forward_process(double* sink_p, const double* source_p); virtual void backward_process(double* sink_p, const double* source_p); -}; - +}; + } } } diff --git a/src/cpp/structure/connections/outconvolve.cpp b/src/cpp/structure/connections/outconvolve.cpp index ea58086..68dce9c 100644 --- a/src/cpp/structure/connections/outconvolve.cpp +++ b/src/cpp/structure/connections/outconvolve.cpp @@ -19,8 +19,8 @@ using arac::structure::Parametrized; using arac::structure::modules::Module; -OutConvolveConnection::OutConvolveConnection(Module* incoming_p, - Module* outgoing_p, +OutConvolveConnection::OutConvolveConnection(Module* incoming_p, + Module* outgoing_p, int chunk) : Connection(incoming_p, outgoing_p), Parametrized(chunk * incoming()->outsize()), @@ -34,7 +34,7 @@ OutConvolveConnection::OutConvolveConnection(Module* incoming_p, OutConvolveConnection::~OutConvolveConnection() { - + } @@ -44,29 +44,29 @@ OutConvolveConnection::forward_process(double* sink_p, const double* source_p) for (int i = 0; i < _n_chunks; i++) { cblas_dgemv( - CblasRowMajor, - // Do not transpose the matrix since we want to multiply from + CblasRowMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix _chunk, - _incoming_p->outsize(), + _incoming_p->outsize(), // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector _incoming_p->outsize(), // Pointer to the vector source_p, // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p + (i * _chunk), // Incrementer. - 1); + 1); } } @@ -76,35 +76,35 @@ OutConvolveConnection::backward_process(double* sink_p, const double* source_p) { int indim = _incomingstop - _incomingstart; int outdim = _outgoingstop - _outgoingstart; - + double* input_p = _incoming_p->output()[timestep() - 1] \ + _incomingstart; double* derivs_p = get_derivatives(); for (int i = 0; i < _n_chunks; i++) { - cblas_dgemv(CblasColMajor, - // Do not transpose the matrix since we want to multiply from + cblas_dgemv(CblasColMajor, + // Do not transpose the matrix since we want to multiply from // the right CblasNoTrans, // Dimensions of the matrix _incoming_p->outsize(), - _chunk, + _chunk, // Scalar for the matrix - 1.0, + 1.0, // Pointer to the matrix - get_parameters(), + get_parameters(), // Dimension of the vector _incoming_p->outsize(), // Pointer to the vector source_p + (i * _chunk), // Some incrementer. - 1, + 1, // Scalar of the target vector - 1.0, + 1.0, // Pointer to the target vector sink_p, // Incrementer. - 1); + 1); for (int j = 0; j < _chunk; j++) { diff --git a/src/cpp/structure/connections/outconvolve.h b/src/cpp/structure/connections/outconvolve.h index 7f42161..22bd4ae 100644 --- a/src/cpp/structure/connections/outconvolve.h +++ b/src/cpp/structure/connections/outconvolve.h @@ -16,7 +16,7 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; using arac::structure::Parametrized; @@ -27,12 +27,12 @@ using arac::structure::Parametrized; class OutConvolveConnection : public Connection, public Parametrized { - public: - + public: + /// /// Create a new OutConvolveConnection object. /// - OutConvolveConnection(Module* incoming_p, Module* outgoing_p, + OutConvolveConnection(Module* incoming_p, Module* outgoing_p, int outchunk); /// @@ -41,20 +41,20 @@ class OutConvolveConnection : public Connection, public Parametrized /// OutConvolveConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p); - - /// + + /// /// Destroy the OutConvolveConnection object. /// virtual ~OutConvolveConnection(); - + protected: virtual void forward_process(double* sink_p, const double* source_p); virtual void backward_process(double* sink_p, const double* source_p); int _n_chunks; int _chunk; -}; - +}; + } } } diff --git a/src/cpp/structure/connections/permutation.cpp b/src/cpp/structure/connections/permutation.cpp index 2fd50df..9cc6dba 100644 --- a/src/cpp/structure/connections/permutation.cpp +++ b/src/cpp/structure/connections/permutation.cpp @@ -13,14 +13,14 @@ using arac::structure::modules::Module; PermutationConnection::PermutationConnection( - Module* incoming_p, Module* outgoing_p) : + Module* incoming_p, Module* outgoing_p) : Connection(incoming_p, outgoing_p) { - + } -PermutationConnection::PermutationConnection(Module* incoming_p, Module* outgoing_p, +PermutationConnection::PermutationConnection(Module* incoming_p, Module* outgoing_p, std::vector permutation) : Connection(incoming_p, outgoing_p), _permutation(permutation) @@ -34,7 +34,7 @@ PermutationConnection::PermutationConnection(Module* incoming_p, Module* outgoin PermutationConnection::~PermutationConnection() { - + } @@ -44,7 +44,7 @@ PermutationConnection::invert() std::vector old = permutation(); std::vector::const_iterator permiter; int i = 0; - for (permiter = old.begin(), i = 0; + for (permiter = old.begin(), i = 0; permiter != old.end(); permiter++, i++) { @@ -58,7 +58,7 @@ PermutationConnection::forward_process(double* sink_p, const double* source_p) { std::vector::const_iterator intiter; int i; - for (intiter = permutation().begin(), i = 0; + for (intiter = permutation().begin(), i = 0; intiter != permutation().end(); intiter++, i++) { @@ -72,7 +72,7 @@ PermutationConnection::backward_process(double* sink_p, const double* source_p) { std::vector::const_iterator intiter; int i; - for (intiter = permutation().begin(), i = 0; + for (intiter = permutation().begin(), i = 0; intiter != permutation().end(); intiter++, i++) { diff --git a/src/cpp/structure/connections/permutation.h b/src/cpp/structure/connections/permutation.h index 06ab466..25b5193 100644 --- a/src/cpp/structure/connections/permutation.h +++ b/src/cpp/structure/connections/permutation.h @@ -14,7 +14,7 @@ namespace arac { namespace structure { namespace connections { - + using namespace arac::structure::modules; @@ -24,41 +24,41 @@ using namespace arac::structure::modules; class PermutationConnection : public Connection { - public: - + public: + /// /// Create a new PermutationConnection object. /// PermutationConnection(Module* incoming_p, Module* outgoing_p); - - PermutationConnection(Module* incoming_p, Module* outgoing_p, + + PermutationConnection(Module* incoming_p, Module* outgoing_p, std::vector permutation); - /// + /// /// Destroy the PermutationConnection object. /// virtual ~PermutationConnection(); - + const std::vector& permutation() const; std::vector& permutation(); - + void set_permutation(std::vector perm); - + /// /// Invert the current permutation. /// void invert(); - + protected: std::vector _permutation; - + void forward_process(double* sink_p, const double* source_p); void backward_process(double* sink_p, const double* source_p); -}; +}; inline -const std::vector& +const std::vector& PermutationConnection::permutation() const { return _permutation; @@ -66,7 +66,7 @@ PermutationConnection::permutation() const inline -std::vector& +std::vector& PermutationConnection::permutation() { return _permutation; @@ -81,7 +81,7 @@ PermutationConnection::set_permutation(std::vector permutation) _permutation = permutation; } - + } } } diff --git a/src/cpp/structure/modules/bias.cpp b/src/cpp/structure/modules/bias.cpp index cbf9a63..9abe1a3 100644 --- a/src/cpp/structure/modules/bias.cpp +++ b/src/cpp/structure/modules/bias.cpp @@ -9,7 +9,7 @@ using arac::structure::modules::Bias; using arac::structure::Component; -Bias::Bias() : +Bias::Bias() : Module(1, 1) { set_mode(Component::ErrorAgnostic); diff --git a/src/cpp/structure/modules/bias.h b/src/cpp/structure/modules/bias.h index 9e09c84..5a2953a 100644 --- a/src/cpp/structure/modules/bias.h +++ b/src/cpp/structure/modules/bias.h @@ -18,7 +18,7 @@ using arac::structure::modules::Module; /// -/// Bias objects are objects that have a constant output of 1.0. +/// Bias objects are objects that have a constant output of 1.0. /// class Bias : public Module { @@ -28,7 +28,7 @@ class Bias : public Module /// Create a new Bias object. /// Bias(); - + /// /// Destroy the Bias object. /// @@ -38,7 +38,7 @@ class Bias : public Module virtual void _forward(); virtual void _backward(); - + }; diff --git a/src/cpp/structure/modules/cosine.cpp b/src/cpp/structure/modules/cosine.cpp index af22a1a..9ba1ecb 100644 --- a/src/cpp/structure/modules/cosine.cpp +++ b/src/cpp/structure/modules/cosine.cpp @@ -32,10 +32,10 @@ CosineLayer::~CosineLayer() void CosineLayer::_forward() { - // Calculate the dot product. + // Calculate the dot product. double* input_p = input()[timestep()]; - double length = cblas_ddot(insize(), - input_p, 1.0, + double length = cblas_ddot(insize(), + input_p, 1.0, input_p, 1.0); length = sqrt(length); @@ -50,10 +50,10 @@ CosineLayer::_forward() void CosineLayer::_backward() { - // Calculate the dot product. + // Calculate the dot product. double* input_p = input()[timestep() - 1]; - double dotprod = cblas_ddot(insize(), - input_p, 1.0, + double dotprod = cblas_ddot(insize(), + input_p, 1.0, input_p, 1.0); double invdotprodroot = 1 / sqrt(dotprod); double invdotprodrootcubed = 1 / pow(sqrt(dotprod), 3); @@ -84,4 +84,4 @@ CosineLayer::expand() _intererror_p->expand(); Module::expand(); } - + diff --git a/src/cpp/structure/modules/cosine.h b/src/cpp/structure/modules/cosine.h index 4965f8d..50c983c 100644 --- a/src/cpp/structure/modules/cosine.h +++ b/src/cpp/structure/modules/cosine.h @@ -27,7 +27,7 @@ class CosineLayer : public Module { public: - /// + /// /// Create a CosineLayer object of the given size. /// CosineLayer(int size); diff --git a/src/cpp/structure/modules/doublegate.cpp b/src/cpp/structure/modules/doublegate.cpp index 39a6e9a..f2a6013 100644 --- a/src/cpp/structure/modules/doublegate.cpp +++ b/src/cpp/structure/modules/doublegate.cpp @@ -41,11 +41,11 @@ DoubleGateLayer::_backward() for (int i = 0; i < size; i++) { - inerror_p[i] = sigmoidprime(input_p[i]) - * input_p[i + size] + inerror_p[i] = sigmoidprime(input_p[i]) + * input_p[i + size] * outerror_p[i]; inerror_p[i] -= sigmoidprime(input_p[i]) - * input_p[i + size] + * input_p[i + size] * outerror_p[i + size]; } for(int i = 0; i < size; i++) diff --git a/src/cpp/structure/modules/doublegate.h b/src/cpp/structure/modules/doublegate.h index 69b35e4..4941809 100644 --- a/src/cpp/structure/modules/doublegate.h +++ b/src/cpp/structure/modules/doublegate.h @@ -29,9 +29,9 @@ class DoubleGateLayer : public Module /// Create a new DoubleGateLayer object of the gíven size. /// DoubleGateLayer(int size); - - /// - /// Destroy the DoubleGateLayer object. + + /// + /// Destroy the DoubleGateLayer object. /// virtual ~DoubleGateLayer(); @@ -50,7 +50,7 @@ inline DoubleGateLayer::DoubleGateLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/errorscaling.cpp b/src/cpp/structure/modules/errorscaling.cpp index 91ef710..a94691f 100644 --- a/src/cpp/structure/modules/errorscaling.cpp +++ b/src/cpp/structure/modules/errorscaling.cpp @@ -17,10 +17,10 @@ ErrorScalingLayer::ErrorScalingLayer(int size, std::vector scale) : assert(scale.size() == size); } - -ErrorScalingLayer::~ErrorScalingLayer() + +ErrorScalingLayer::~ErrorScalingLayer() { - + } diff --git a/src/cpp/structure/modules/errorscaling.h b/src/cpp/structure/modules/errorscaling.h index f65b91b..0408231 100644 --- a/src/cpp/structure/modules/errorscaling.h +++ b/src/cpp/structure/modules/errorscaling.h @@ -18,7 +18,7 @@ using arac::structure::modules::LinearLayer; /// -/// A ErrorScalingLayer object is of equal in- and outputsize. It does not +/// A ErrorScalingLayer object is of equal in- and outputsize. It does not /// transform, the input in any way - but the error is multiplied by constants /// determined by a vector during the backward pass. /// @@ -27,7 +27,7 @@ class ErrorScalingLayer : public LinearLayer { public: - /// + /// /// Create a ErrorScalingLayer object of the given size. /// ErrorScalingLayer(int size, std::vector scale); @@ -36,7 +36,7 @@ class ErrorScalingLayer : public LinearLayer protected: virtual void _backward(); - + std::vector _scale; }; diff --git a/src/cpp/structure/modules/gate.cpp b/src/cpp/structure/modules/gate.cpp index 9e0f62b..eee6e66 100644 --- a/src/cpp/structure/modules/gate.cpp +++ b/src/cpp/structure/modules/gate.cpp @@ -37,8 +37,8 @@ GateLayer::_backward() for (int i = 0; i < outsize(); i++) { - inerror_p[i] = sigmoidprime(input_p[i]) - * input_p[i + outsize()] + inerror_p[i] = sigmoidprime(input_p[i]) + * input_p[i + outsize()] * outerror_p[i]; } for(int i = 0; i < outsize(); i++) diff --git a/src/cpp/structure/modules/gate.h b/src/cpp/structure/modules/gate.h index 22c772c..98b136c 100644 --- a/src/cpp/structure/modules/gate.h +++ b/src/cpp/structure/modules/gate.h @@ -30,8 +30,8 @@ class GateLayer : public Module /// Create a new GateLayer object of the gíven size. /// GateLayer(int size); - - /// + + /// /// Destroy the GateLayer object. /// virtual ~GateLayer(); @@ -51,7 +51,7 @@ inline GateLayer::GateLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/linear.h b/src/cpp/structure/modules/linear.h index 49a2898..191d78b 100644 --- a/src/cpp/structure/modules/linear.h +++ b/src/cpp/structure/modules/linear.h @@ -26,7 +26,7 @@ class LinearLayer : public Module { public: - /// + /// /// Create a LinearLayer object of the given size. /// LinearLayer(int size); @@ -47,7 +47,7 @@ inline LinearLayer::LinearLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/lstm.cpp b/src/cpp/structure/modules/lstm.cpp index 0aef8fe..b9d2ee9 100644 --- a/src/cpp/structure/modules/lstm.cpp +++ b/src/cpp/structure/modules/lstm.cpp @@ -59,8 +59,8 @@ void LstmLayer::fill_internal_input() { // Copy input into internal MdlstmLayer. - memcpy(_mdlstm.input()[timestep()], - input()[timestep()], + memcpy(_mdlstm.input()[timestep()], + input()[timestep()], insize() * sizeof(double)); } @@ -73,8 +73,8 @@ LstmLayer::fill_internal_state() double* state_p = _mdlstm.input()[timestep()] + insize(); if (timestep() > 0) { - memcpy(state_p, - state()[timestep() - 1], + memcpy(state_p, + state()[timestep() - 1], outsize() * sizeof(double)); } else @@ -88,8 +88,8 @@ void LstmLayer::retrieve_internal_output() { // Copy information back. - memcpy(output()[timestep()], - _mdlstm.output()[timestep()], + memcpy(output()[timestep()], + _mdlstm.output()[timestep()], outsize() * sizeof(double)); } @@ -97,7 +97,7 @@ LstmLayer::retrieve_internal_output() void LstmLayer::retrieve_internal_state() { - memcpy(state()[timestep()], + memcpy(state()[timestep()], _mdlstm.output()[timestep()] + outsize(), outsize() * sizeof(double)); } @@ -106,7 +106,7 @@ LstmLayer::retrieve_internal_state() void LstmLayer::fill_internal_outerror() { - memcpy(_mdlstm.outerror()[timestep() - 1], + memcpy(_mdlstm.outerror()[timestep() - 1], outerror()[timestep() - 1], outsize() * sizeof(double)); } @@ -121,7 +121,7 @@ LstmLayer::fill_internal_state_error() 0, outsize() * sizeof(double)); } - else + else { assert(timestep() < state_error().size()); memcpy(_mdlstm.outerror()[timestep() - 1] + outsize(), @@ -140,7 +140,7 @@ LstmLayer::retrieve_internal_inerror() } -void +void LstmLayer::retrieve_internal_state_error() { memcpy(state_error()[timestep() - 1], diff --git a/src/cpp/structure/modules/lstm.h b/src/cpp/structure/modules/lstm.h index a27b67d..a786f84 100644 --- a/src/cpp/structure/modules/lstm.h +++ b/src/cpp/structure/modules/lstm.h @@ -37,22 +37,22 @@ class LstmLayer : public Module /// LstmLayer(int size); virtual ~LstmLayer(); - + virtual void set_mode(arac::structure::Component::Mode mode); - + /// /// Return a reference to the state buffer. /// arac::common::Buffer& state(); arac::common::Buffer& state_error(); - + protected: - + virtual void _forward(); virtual void _backward(); virtual void expand(); - + void fill_internal_state(); void retrieve_internal_state(); void fill_internal_input(); @@ -61,7 +61,7 @@ class LstmLayer : public Module void retrieve_internal_inerror(); void fill_internal_state_error(); void retrieve_internal_state_error(); - + /// /// Since the lstm cell is a special case of the mdlstm cell, the lstm /// layer is implemented by wrapping an MdlstmLayer object. @@ -70,7 +70,7 @@ class LstmLayer : public Module arac::common::Buffer* _state_p; arac::common::Buffer* _state_error_p; - + }; inline diff --git a/src/cpp/structure/modules/mdlstm.cpp b/src/cpp/structure/modules/mdlstm.cpp index 241917c..730bb0b 100644 --- a/src/cpp/structure/modules/mdlstm.cpp +++ b/src/cpp/structure/modules/mdlstm.cpp @@ -41,7 +41,7 @@ MdlstmLayer::MdlstmLayer(int timedim, int size) : } -MdlstmLayer::~MdlstmLayer() +MdlstmLayer::~MdlstmLayer() { delete[] _inter_input_p; delete[] _input_state_p; @@ -94,11 +94,11 @@ MdlstmLayer::_forward() { clear_intermediates(); int size = _outsize / 2; - + double (*gate_squasher) (double) = sigmoid; double (*cell_squasher) (double) = tanh_; double (*output_squasher) (double) = tanh_; - + // Split the whole input into the right chunks double* inputbuffer_p = input()[timestep()]; int i = 0; @@ -111,7 +111,7 @@ MdlstmLayer::_forward() { forget_gate_unsquashed()[timestep()][j] = inputbuffer_p[i]; } - + for (int j = 0; j < size; j++, i++) { input_squashed()[timestep()][j] = cell_squasher(inputbuffer_p[i]); @@ -121,14 +121,14 @@ MdlstmLayer::_forward() { output_gate_unsquashed()[timestep()][j] = inputbuffer_p[i]; } - + for (int j = 0; j < size * _timedim ; j++, i++) { _input_state_p[j] = inputbuffer_p[i]; } - + // TODO: include peepholes - // Change the ingate values with respect to peepholes, if we have peephole + // Change the ingate values with respect to peepholes, if we have peephole // weights // if (mdlstml_p->peephole_input_weights.contents_p) // { @@ -142,7 +142,7 @@ MdlstmLayer::_forward() // } // } // } - // + // // if (mdlstml_p->peephole_forget_weights.contents_p) // { // for (int i = 0; i < size * _timedim; i++) @@ -151,7 +151,7 @@ MdlstmLayer::_forward() // mdlstml_p->peephole_forget_weights.contents_p[i] * inputstate_p[i]; // } // } - + // Squash the input gates. for (int i = 0; i < size; i++) { @@ -165,7 +165,7 @@ MdlstmLayer::_forward() forget_gate_squashed()[timestep()][i] = \ gate_squasher(forget_gate_unsquashed()[timestep()][i]); } - + // Calculate the current cell state. for (int i = 0; i < size; i++) { @@ -181,7 +181,7 @@ MdlstmLayer::_forward() int index = size * i + j; _output_state_p[j] += \ forget_gate_squashed()[timestep()][index] * _input_state_p[index]; - + } } @@ -195,7 +195,7 @@ MdlstmLayer::_forward() // mdlstml_p->peephole_output_weights.contents_p[i] * outputstate_p[i]; // } // } - + // Squash the output gates. for (int i = 0; i < size; i++) { @@ -219,7 +219,7 @@ MdlstmLayer::_backward() clear_intermediates(); int size = _outsize / 2; int this_timestep = timestep() - 1; - + double (*cell_squasher) (double) = tanh_; // double (*output_squasher) (double) = tanh_; double (*gate_squasher_prime) (double) = sigmoidprime; @@ -244,7 +244,7 @@ MdlstmLayer::_backward() // Shortcut double* output_error_buffer_p = outerror()[this_timestep]; - + // Splitting the errorbuffer into two parts. for (int i = 0; i < size; i++) { @@ -255,7 +255,7 @@ MdlstmLayer::_backward() { _output_state_error_p[i] = output_error_buffer_p[i + size]; } - + // Calculate the outgate error. for (int i = 0; i < size; i++) { @@ -274,7 +274,7 @@ MdlstmLayer::_backward() * tanhprime(outputstate_p[i]); // FIXME: use func-pointer here. _state_error_p[i] += nextstateerror_p[i]; } - + // TODO: integrate peepholes // if (mdlstml_p->peephole_output_weights.contents_p) // { @@ -285,7 +285,7 @@ MdlstmLayer::_backward() // * mdlstml_p->peephole_output_weights.contents_p[i]; // } // } - + // Calculate cell errors. for (int i = 0; i < size; i++) { @@ -294,7 +294,7 @@ MdlstmLayer::_backward() * cell_squasher_prime(_inter_input_p[i]) \ * _state_error_p[i]; } - + // Calc forget gate errors. for (int i = 0; i < _timedim; i++) { @@ -306,7 +306,7 @@ MdlstmLayer::_backward() * _input_state_p[i * size + j]; } } - + // FIXME: strangely, tests fail if this loop is removed. for (int i = 0; i < size * _timedim; i++) { @@ -319,7 +319,7 @@ MdlstmLayer::_backward() * _input_squashed[this_timestep][i] \ * _state_error_p[i]; } - + // FIXME: strangely, tests fail if this loop is removed. for (int i = 0; i < size; i++) { @@ -350,7 +350,7 @@ MdlstmLayer::_backward() // } // } // } - + for (int i = 0; i < _timedim; i++) { for (int j = 0; j < size; j++) @@ -369,12 +369,12 @@ MdlstmLayer::_backward() // } } } - + // FIXME: strangely, tests fail if this loop is removed. for (int i = 0; i < size * _timedim; i++) { } - + double* inerror_p = inerror()[this_timestep]; i = 0; for (int j = 0; j < size; j++, i++) @@ -386,7 +386,7 @@ MdlstmLayer::_backward() { inerror_p[i] = _forget_gate_error_p[j]; } - + for (int j = 0; j < size; j++, i++) { inerror_p[i] = _input_error_p[j]; @@ -396,7 +396,7 @@ MdlstmLayer::_backward() { inerror_p[i] = _output_gate_error_p[j]; } - + for (int j = 0; j < size * _timedim ; j++, i++) { inerror_p[i] = _input_state_error_p[j]; diff --git a/src/cpp/structure/modules/mdlstm.h b/src/cpp/structure/modules/mdlstm.h index 67c031f..7164e11 100644 --- a/src/cpp/structure/modules/mdlstm.h +++ b/src/cpp/structure/modules/mdlstm.h @@ -14,9 +14,9 @@ namespace structure { namespace modules { /// -/// MdlstmLayer objects implement the MDLSTM algorithm as introduced by Alex +/// MdlstmLayer objects implement the MDLSTM algorithm as introduced by Alex /// Graves. They are a generalization of the LSTM algorithm and suited for -/// multidimensional sequences. +/// multidimensional sequences. /// /// MdlstmLayer objects have a special input layout which is outlined below. /// @@ -27,7 +27,7 @@ namespace modules { /// Depending on how many "real" inputs the layer is given, there will be /// /// I = (3 + 2 * d) * s -/// +/// /// inputs over all, where s is the size (= the "true" input) and d is the /// dimensionality of the MDRNN. The input layout is as follows: /// @@ -60,7 +60,7 @@ class MdlstmLayer : public arac::structure::modules::Module /// Destroy the MdlstmLayer object. /// virtual ~MdlstmLayer(); - + /// /// Return a reference to the input_squashed Buffer. /// @@ -97,29 +97,29 @@ class MdlstmLayer : public arac::structure::modules::Module arac::common::Buffer& forget_gate_unsquashed(); private: - + // Set the intermediate buffers to zero. // TODO: find better name. void clear_intermediates(); - + virtual void _forward(); virtual void _backward(); - + virtual void expand(); - + int _timedim; - + arac::common::Buffer _input_squashed; - + arac::common::Buffer _input_gate_squashed; arac::common::Buffer _input_gate_unsquashed; - + arac::common::Buffer _output_gate_squashed; arac::common::Buffer _output_gate_unsquashed; - + arac::common::Buffer _forget_gate_squashed; arac::common::Buffer _forget_gate_unsquashed; - + // Intermediate buffers. double* _inter_input_p; double* _output_state_p; @@ -132,13 +132,13 @@ class MdlstmLayer : public arac::structure::modules::Module double* _input_error_p; double* _input_state_error_p; double* _state_error_p; - + double* _outputbuffer_p; }; inline -arac::common::Buffer& +arac::common::Buffer& MdlstmLayer::input_squashed() { return _input_squashed; @@ -146,11 +146,11 @@ MdlstmLayer::input_squashed() inline -arac::common::Buffer& +arac::common::Buffer& MdlstmLayer::output_gate_squashed() { return _output_gate_squashed; - + } @@ -163,7 +163,7 @@ MdlstmLayer::output_gate_unsquashed() inline -arac::common::Buffer& +arac::common::Buffer& MdlstmLayer::input_gate_squashed() { return _input_gate_squashed; @@ -171,7 +171,7 @@ MdlstmLayer::input_gate_squashed() inline -arac::common::Buffer& +arac::common::Buffer& MdlstmLayer::input_gate_unsquashed() { return _input_gate_unsquashed; @@ -187,7 +187,7 @@ MdlstmLayer::forget_gate_squashed() inline -arac::common::Buffer& +arac::common::Buffer& MdlstmLayer::forget_gate_unsquashed() { return _forget_gate_unsquashed; diff --git a/src/cpp/structure/modules/module.cpp b/src/cpp/structure/modules/module.cpp index eb78d9a..d46df3e 100644 --- a/src/cpp/structure/modules/module.cpp +++ b/src/cpp/structure/modules/module.cpp @@ -11,7 +11,7 @@ using arac::structure::Component; using arac::common::Buffer; -Module::Module() : +Module::Module() : _insize(0), _outsize(0), _input_p(0), @@ -24,7 +24,7 @@ Module::Module() : -Module::Module(int insize, int outsize) : +Module::Module(int insize, int outsize) : _insize(insize), _outsize(outsize), _input_p(0), @@ -36,9 +36,9 @@ Module::Module(int insize, int outsize) : } -Module::~Module() +Module::~Module() { - free_buffers(); + free_buffers(); } @@ -83,7 +83,7 @@ Module::clear() { _output_p->clear(); } - + if (!error_agnostic()) { if (_inerror_p != 0) @@ -97,7 +97,7 @@ Module::clear() } } -void +void Module::free_buffers() { if ((_input_p != 0) && (_input_p->owner())) @@ -105,13 +105,13 @@ Module::free_buffers() delete _input_p; _input_p = 0; } - + if ((_output_p != 0) && (_output_p->owner())) { delete _output_p; _output_p = 0; } - + if (!error_agnostic()) { if ((_inerror_p != 0) && _inerror_p->owner()) diff --git a/src/cpp/structure/modules/module.h b/src/cpp/structure/modules/module.h index 54de4d6..a4d3eab 100644 --- a/src/cpp/structure/modules/module.h +++ b/src/cpp/structure/modules/module.h @@ -13,25 +13,25 @@ namespace arac { namespace structure { namespace modules { - + /// -/// A module is something that has input data and produces output data out of +/// A module is something that has input data and produces output data out of /// this. The inputs and outputs do not necessarily have to be of the same size. -/// +/// class Module : public arac::structure::Component { public: Module(); - + /// /// Create a new module and allocate the necessary buffers. /// Module(int insize, int outsize); /// - /// Destroy the module. + /// Destroy the module. virtual ~Module(); @@ -39,7 +39,7 @@ class Module : public arac::structure::Component /// Interpret the input and produce the modules output by this. /// virtual void forward(); - + /// /// Add the contents at the given pointer to the input. /// @@ -49,7 +49,7 @@ class Module : public arac::structure::Component /// Add the contents at the given pointer to the outerror. /// void add_to_outerror(double* addend_p); - + /// /// Clear input, output, inerror and outerror by setting them to zero. /// @@ -59,27 +59,27 @@ class Module : public arac::structure::Component /// Return a reference to the input Buffer. /// arac::common::Buffer& input(); - + /// /// Return a reference the output Buffer. /// arac::common::Buffer& output(); - + /// /// Return a reference to the inerror Buffer. /// arac::common::Buffer& inerror(); - + /// /// Return a reference to the outerror Buffer. /// arac::common::Buffer& outerror(); - + /// /// Return the input size of the module. /// int insize(); - + /// /// Return the output size of the module. /// @@ -90,20 +90,20 @@ class Module : public arac::structure::Component /// bool last_timestep(); - + protected: /// /// Initialize all the buffers. /// virtual void init_buffers(); - + /// - /// Free the space used by the buffers. Do nothing if the buffers are + /// Free the space used by the buffers. Do nothing if the buffers are /// not the owners of the memory. /// virtual void free_buffers(); - + /// /// Expand the size of all the buffers by one row. /// @@ -111,7 +111,7 @@ class Module : public arac::structure::Component int _insize; int _outsize; - + arac::common::Buffer* _input_p; arac::common::Buffer* _output_p; arac::common::Buffer* _inerror_p; @@ -136,14 +136,14 @@ Module::outsize() inline -bool +bool Module::last_timestep() { return (timestep() == _input_p->size()); } -inline +inline void Module::add_to_input(double* addend_p) { @@ -151,7 +151,7 @@ Module::add_to_input(double* addend_p) } -inline +inline void Module::add_to_outerror(double* addend_p) { @@ -163,7 +163,7 @@ inline arac::common::Buffer& Module::input() { - return *_input_p; + return *_input_p; } diff --git a/src/cpp/structure/modules/multiplication.h b/src/cpp/structure/modules/multiplication.h index d88bb04..b02ce09 100644 --- a/src/cpp/structure/modules/multiplication.h +++ b/src/cpp/structure/modules/multiplication.h @@ -28,8 +28,8 @@ class MultiplicationLayer : public Module /// Create a new MultiplicationLayer object of the gíven size. /// MultiplicationLayer(int size); - - /// + + /// /// Destroy the MultiplicationLayer object. /// virtual ~MultiplicationLayer(); @@ -49,7 +49,7 @@ inline MultiplicationLayer::MultiplicationLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/partialsoftmax.h b/src/cpp/structure/modules/partialsoftmax.h index 19fabf1..3a30c79 100644 --- a/src/cpp/structure/modules/partialsoftmax.h +++ b/src/cpp/structure/modules/partialsoftmax.h @@ -17,9 +17,9 @@ using arac::structure::modules::Module; /// -/// A PartialSoftmaxLayer object softmaxes the output over slices. +/// A PartialSoftmaxLayer object softmaxes the output over slices. /// For example, a layer might have an input size of 4 - if the slicelength is -/// 2, the first two and the second two inputs will be transformed to each add +/// 2, the first two and the second two inputs will be transformed to each add /// up to 1.0 in the output. /// @@ -31,17 +31,17 @@ class PartialSoftmaxLayer : public Module /// Create a new PartialSoftmaxLayer object. /// PartialSoftmaxLayer(int size, int slicelength); - + /// /// Destroy the PartialSoftmaxLayer object. /// virtual ~PartialSoftmaxLayer(); protected: - + virtual void _forward(); virtual void _backward(); - + int _slicelength; }; @@ -55,7 +55,7 @@ inline PartialSoftmaxLayer::PartialSoftmaxLayer(int size, int slicelength) : { } - + } } } diff --git a/src/cpp/structure/modules/sigmoid.h b/src/cpp/structure/modules/sigmoid.h index 59c113d..87f4a81 100644 --- a/src/cpp/structure/modules/sigmoid.h +++ b/src/cpp/structure/modules/sigmoid.h @@ -24,14 +24,14 @@ class SigmoidLayer : public Module { public: - /// + /// /// Create a new SigmoidLayer object of the given size. /// SigmoidLayer(int size); virtual ~SigmoidLayer(); protected: - + virtual void _forward(); virtual void _backward(); }; @@ -45,7 +45,7 @@ inline SigmoidLayer::SigmoidLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/softmax.h b/src/cpp/structure/modules/softmax.h index 4aaf69a..c0defbf 100644 --- a/src/cpp/structure/modules/softmax.h +++ b/src/cpp/structure/modules/softmax.h @@ -27,7 +27,7 @@ class SoftmaxLayer : public Module /// Create a new SoftmaxLayer object. /// SoftmaxLayer(int size); - + /// /// Destroy the SoftmaxLayer object. /// @@ -48,7 +48,7 @@ inline SoftmaxLayer::SoftmaxLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/switch.h b/src/cpp/structure/modules/switch.h index f50cb68..e51d0e3 100644 --- a/src/cpp/structure/modules/switch.h +++ b/src/cpp/structure/modules/switch.h @@ -28,8 +28,8 @@ class SwitchLayer : public Module /// Create a new SwitchLayer object of the gíven size. /// SwitchLayer(int size); - - /// + + /// /// Destroy the SwitchLayer object. /// virtual ~SwitchLayer(); @@ -49,7 +49,7 @@ inline SwitchLayer::SwitchLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/modules/tanh.h b/src/cpp/structure/modules/tanh.h index e530043..22c1047 100644 --- a/src/cpp/structure/modules/tanh.h +++ b/src/cpp/structure/modules/tanh.h @@ -24,14 +24,14 @@ class TanhLayer : public Module { public: - /// + /// /// Create a new TanhLayer object of the given size. /// TanhLayer(int size); virtual ~TanhLayer(); - + protected: - + virtual void _forward(); virtual void _backward(); }; @@ -45,7 +45,7 @@ inline TanhLayer::TanhLayer(int size) : { } - + } } } diff --git a/src/cpp/structure/networks/basenetwork.cpp b/src/cpp/structure/networks/basenetwork.cpp index 7a75af5..f1c4b61 100644 --- a/src/cpp/structure/networks/basenetwork.cpp +++ b/src/cpp/structure/networks/basenetwork.cpp @@ -16,7 +16,7 @@ namespace networks { using arac::structure::networks::BaseNetwork; -BaseNetwork::BaseNetwork() : +BaseNetwork::BaseNetwork() : Module(), _dirty(true) { @@ -51,8 +51,8 @@ BaseNetwork::activate(const double* input_p) clear(); } // Copy this input into the inputbuffer. - memcpy((void*) input()[timestep()], - (void*) input_p, + memcpy((void*) input()[timestep()], + (void*) input_p, sizeof(double) * _insize); forward(); assert(timestep() > 0); @@ -71,8 +71,8 @@ BaseNetwork::activate(const double* input_p, double* output_p) const double* BaseNetwork::back_activate(const double* error_p) { - memcpy((void*) outerror()[timestep() - 1], - (void*) error_p, + memcpy((void*) outerror()[timestep() - 1], + (void*) error_p, sizeof(double) * _outsize); backward(); @@ -98,7 +98,7 @@ BaseNetwork::clear_derivatives() { (*param_iter)->clear_derivatives(); } - + std::vector::iterator net_iter; for (net_iter = networks().begin(); net_iter != networks().end(); diff --git a/src/cpp/structure/networks/basenetwork.h b/src/cpp/structure/networks/basenetwork.h index 0815c74..85846ec 100644 --- a/src/cpp/structure/networks/basenetwork.h +++ b/src/cpp/structure/networks/basenetwork.h @@ -16,7 +16,7 @@ namespace networks { /// -/// Base class for all kinds of networks. Networks are supposed to organize +/// Base class for all kinds of networks. Networks are supposed to organize /// components in a certain way to allow them to interact in a way defined by /// the network. /// @@ -25,16 +25,16 @@ class BaseNetwork : public arac::structure::modules::Module { public: - + BaseNetwork(); virtual ~BaseNetwork(); - + /// /// Copy the given input into the networks input buffer and call /// forward, returning a pointer to the result. /// virtual const double* activate(const double* input_p); - + /// /// Copy the given error into the networks input buffer and call /// backward, returning a pointer to the inerror. @@ -52,42 +52,42 @@ class BaseNetwork : public arac::structure::modules::Module /// backward. Copy the resulting inerror into the given array. /// virtual void back_activate(const double* outerror_p, double* inerror_p); - + virtual void forward(); /// - /// Initialize the network for processing. This method has to be + /// Initialize the network for processing. This method has to be /// overwritten by subclasses. /// virtual void sort() = 0; - + /// /// Return a vector to all the Parametrized objects in the Network. /// std::vector& parametrizeds(); - + /// /// Return a vector to all BaseNetwork objects in the Network. /// std::vector& networks(); - + /// /// Fill the parametrizers of all Parametrized objects in the network /// with random values. /// // TODO: allow specification of intervals. void randomize(); - + /// /// Set the derivatives of all the Parametrized objects in the network /// to zero. /// virtual void clear_derivatives(); - + protected: - + bool _dirty; - + std::vector _parametrizeds; std::vector _networks; diff --git a/src/cpp/structure/networks/mdrnns/basemdrnn.cpp b/src/cpp/structure/networks/mdrnns/basemdrnn.cpp index da45926..ae5aec4 100644 --- a/src/cpp/structure/networks/mdrnns/basemdrnn.cpp +++ b/src/cpp/structure/networks/mdrnns/basemdrnn.cpp @@ -11,11 +11,11 @@ using arac::structure::networks::mdrnns::BaseMdrnn; BaseMdrnn::BaseMdrnn(int timedim) : _timedim(timedim) { - + } BaseMdrnn::~BaseMdrnn() { - + } diff --git a/src/cpp/structure/networks/mdrnns/basemdrnn.h b/src/cpp/structure/networks/mdrnns/basemdrnn.h index 57fd334..8f46fe9 100644 --- a/src/cpp/structure/networks/mdrnns/basemdrnn.h +++ b/src/cpp/structure/networks/mdrnns/basemdrnn.h @@ -18,25 +18,25 @@ namespace mdrnns { /// /// Baseclass for all kinds of multidimensional recurrent neural networks. /// The common API is a time dimensions, which specifies the dimensionality of -/// the sequence. +/// the sequence. /// class BaseMdrnn : public BaseNetwork { public: - + /// /// Create a new BaseMdrnn object. /// BaseMdrnn(int timedim); - + /// /// Destroy the BaseMdrnn object. /// virtual ~BaseMdrnn(); protected: - + int _timedim; }; diff --git a/src/cpp/structure/networks/mdrnns/mdrnn.cpp b/src/cpp/structure/networks/mdrnns/mdrnn.cpp index 9c6ad99..e0b6eb0 100644 --- a/src/cpp/structure/networks/mdrnns/mdrnn.cpp +++ b/src/cpp/structure/networks/mdrnns/mdrnn.cpp @@ -10,7 +10,7 @@ namespace arac { namespace structure { namespace networks { namespace mdrnns { - + using namespace arac::structure::modules; @@ -25,12 +25,12 @@ Mdrnn::init_structure() _module_p->set_mode(Component::Sequential); FullConnection* feedcon_p = \ - new FullConnection(_inmodule_p, _module_p, + new FullConnection(_inmodule_p, _module_p, 0, blocksize(), 0, _hiddensize); feedcon_p->set_mode(Component::Sequential); _feedcon_p = feedcon_p; - + // Add a connection from the bias. _biascon_p = new FullConnection(&_bias, _module_p); _biascon_p->set_mode(Component::Sequential); @@ -47,12 +47,12 @@ Mdrnn::init_structure() _module_p->set_mode(Component::Sequential); FullConnection* feedcon_p = \ - new FullConnection(_inmodule_p, _module_p, + new FullConnection(_inmodule_p, _module_p, 0, blocksize(), 0, _hiddensize); feedcon_p->set_mode(Component::Sequential); _feedcon_p = feedcon_p; - + // Add a connection from the bias. _biascon_p = new FullConnection(&_bias, _module_p); _biascon_p->set_mode(Component::Sequential); @@ -69,12 +69,12 @@ Mdrnn::init_structure() _module_p->set_mode(Component::Sequential); FullConnection* feedcon_p = \ - new FullConnection(_inmodule_p, _module_p, + new FullConnection(_inmodule_p, _module_p, 0, blocksize(), 0, _hiddensize); feedcon_p->set_mode(Component::Sequential); _feedcon_p = feedcon_p; - + // Add a connection from the bias. _biascon_p = new FullConnection(&_bias, _module_p); _biascon_p->set_mode(Component::Sequential); @@ -89,22 +89,22 @@ Mdrnn::init_structure() _module_p = new MdlstmLayer(_timedim, _hiddensize); _module_p->set_mode(Component::Sequential); - // Use a FullConnection pointer first so it can be appended to the + // Use a FullConnection pointer first so it can be appended to the // parametrizeds vector. FullConnection* feedcon_p = \ - new FullConnection(_inmodule_p, _module_p, + new FullConnection(_inmodule_p, _module_p, 0, blocksize(), 0, (3 + _timedim) * _hiddensize); feedcon_p->set_mode(Component::Sequential); _feedcon_p = feedcon_p; - + // Add a connection from the bias. int full_con_instart = 0; int full_con_instop = _hiddensize; int full_con_outstart = 0; int full_con_outstop = (3 + _timedim) * _hiddensize; - _biascon_p = new FullConnection(&_bias, _module_p, - 0, 1, + _biascon_p = new FullConnection(&_bias, _module_p, + 0, 1, full_con_outstart, full_con_outstop); _biascon_p->set_mode(Component::Sequential); } @@ -121,25 +121,25 @@ Mdrnn::sort() delete_structure(); init_structure(); init_con_vectors(); - + // Also clear the parametrized vector. _parametrizeds.clear(); _parametrizeds.push_back(_feedcon_p); _parametrizeds.push_back(_biascon_p); - + // Initialize recurrent self connections. int recurrency = 1; - + int full_con_instart = 0; int full_con_instop = _hiddensize; int full_con_outstart = 0; int full_con_outstop = (3 + _timedim) * _hiddensize; - + int id_con_instart = full_con_instop; int id_con_instop = _module_p->outsize(); int id_con_outstart = full_con_outstop; int id_con_outstop = _module_p->insize(); - + for(int i = 0; i < _timedim; i++) { FullConnection* fcon_p = \ @@ -150,7 +150,7 @@ Mdrnn::sort() fcon_p->set_recurrent(recurrency); _connections[i].push_back(fcon_p); _parametrizeds.push_back(fcon_p); - + IdentityConnection* icon_p = \ new IdentityConnection(_module_p, _module_p, id_con_instart, id_con_instop, @@ -158,15 +158,15 @@ Mdrnn::sort() icon_p->set_mode(Component::Sequential); icon_p->set_recurrent(recurrency); _connections[i].push_back(icon_p); - - // Multiply with the current blocks-per-dimension so that each + + // Multiply with the current blocks-per-dimension so that each // connections jumps over one dimension. recurrency *= _sequence_shape_p[i] / _block_shape_p[i]; } // Ininitialize buffers. init_buffers(); - + // Indicate that the net is ready for use. _dirty = false; } diff --git a/src/cpp/structure/networks/mdrnns/mdrnn.h b/src/cpp/structure/networks/mdrnns/mdrnn.h index 013a91d..64416e8 100644 --- a/src/cpp/structure/networks/mdrnns/mdrnn.h +++ b/src/cpp/structure/networks/mdrnns/mdrnn.h @@ -31,10 +31,10 @@ namespace networks { namespace mdrnns { -/// -/// Template class to implement a grid of modules in order to process +/// +/// Template class to implement a grid of modules in order to process /// multidimensional sequences. -/// +/// /// The networks is presented the whole input at once. It holds an internal /// structure of modules, which this input will be distributed to on activation. /// @@ -43,8 +43,8 @@ template class Mdrnn : public BaseMdrnn { public: - - /// + + /// /// Create a new Mdrnn object for the given timedim with layers of size /// hiddensize. /// @@ -55,7 +55,7 @@ class Mdrnn : public BaseMdrnn /// Set the length of the current sequence in the given dimension. /// void set_sequence_shape(int dim, int val); - + /// /// Return the length of the current sequence in the given dimension. /// @@ -71,7 +71,7 @@ class Mdrnn : public BaseMdrnn /// Set the shape of a block along the given dimension. /// void set_block_shape(int dim, int val); - + /// /// Return the shape of a block along the given dimension. /// @@ -82,90 +82,90 @@ class Mdrnn : public BaseMdrnn int blocksize(); virtual void sort(); - + virtual void _forward(); - + virtual void _backward(); - + virtual void clear(); virtual void clear_derivatives(); - + FullConnection& feedcon(); FullConnection& biascon(); - + protected: - + void init_multiplied_sizes(); - + /// /// Create the hidden module. /// void init_structure(); - + /// /// Free the memory held by internal structure. /// void delete_structure(); - + // FIXME: This should be done with integers! void next_coords(int* coords); void update_sizes(); - + int _hiddensize; - + int _sequencelength; int _blocksize; - + int* _sequence_shape_p; int* _block_shape_p; - + /// - /// Size of the previous dimensions in memory; example: if a shape of + /// Size of the previous dimensions in memory; example: if a shape of /// (4, 4, 4) is given, each element holds the product of the previous - /// dimensions: (1, 4, 16) with the special case of the first element + /// dimensions: (1, 4, 16) with the special case of the first element /// being one. /// int* _multiplied_sizes_p; - + /// /// Mdrnn Objects are constructed as follows. The ordinary data/error /// buffers are used. Internally, a new input layer is connected to a - /// mesh of modules which are connected with each other recurrently. + /// mesh of modules which are connected with each other recurrently. /// // TODO: make this description better. // TODO: write getter/setter - arac::structure::modules::LinearLayer* _inmodule_p; - module_type* _module_p; + arac::structure::modules::LinearLayer* _inmodule_p; + module_type* _module_p; arac::structure::modules::Bias _bias; - + /// - /// The Connection object pointed at is supposed to connect _inmodule_p + /// The Connection object pointed at is supposed to connect _inmodule_p /// with _module_p. It feeds the input into the main module. - /// + /// // TODO: write getter/setter - arac::structure::connections::FullConnection* _feedcon_p; + arac::structure::connections::FullConnection* _feedcon_p; - /// + /// /// The connection from the bias to _module_p. - /// - arac::structure::connections::FullConnection* _biascon_p; + /// + arac::structure::connections::FullConnection* _biascon_p; /// /// Return a reference to the held object of module_type. /// module_type& module(); - + /// /// Vector of vectors which is used to store the connections along the - /// differen time dimensions. It has exactly _timedim + 1 items, of - /// which the last keeps connections that are invariant to the + /// differen time dimensions. It has exactly _timedim + 1 items, of + /// which the last keeps connections that are invariant to the /// timedimensions. /// typedef std::vector ConPtrVector; typedef std::vector ConPtrVectorVector; ConPtrVectorVector _connections; - + void init_con_vectors(); }; @@ -215,10 +215,10 @@ Mdrnn::set_block_shape(int dim, int val) { return; } - + _dirty = true; _block_shape_p[dim] = val; - + _blocksize = 1; for (int i = 0; i < _timedim; i++) { @@ -285,7 +285,7 @@ Mdrnn::next_coords(int* coords_p) coords_p[i] += 1; break; } - else + else { coords_p[i] = 0; } @@ -299,7 +299,7 @@ Mdrnn::Mdrnn(int timedim, int hiddensize) : _hiddensize(hiddensize), _inmodule_p(0), _module_p(0), - _feedcon_p(0), + _feedcon_p(0), _biascon_p(0) { _sequence_shape_p = new int[_timedim]; @@ -333,12 +333,12 @@ Mdrnn::delete_structure() { delete _module_p; } - + if (_inmodule_p != 0) { delete _inmodule_p; } - + if (_feedcon_p != 0) { delete _feedcon_p; @@ -348,7 +348,7 @@ Mdrnn::delete_structure() { delete _biascon_p; } - + ConPtrVectorVector::iterator con_vec_iter; ConPtrVector::iterator con_iter; for (con_vec_iter = _connections.begin(); @@ -388,13 +388,13 @@ Mdrnn::update_sizes() _blocksize *= _block_shape_p[i]; } assert(_blocksize > 0); - + _sequencelength = 1; for (int i = 0; i < _timedim; i++) { _sequencelength *= _sequence_shape_p[i]; } - + _sequencelength /= _blocksize; _insize = _sequencelength * _blocksize; _outsize = _sequencelength * _hiddensize; @@ -422,7 +422,7 @@ Mdrnn::sort() // shape etc. init_multiplied_sizes(); update_sizes(); - + delete_structure(); init_structure(); init_con_vectors(); @@ -440,7 +440,7 @@ Mdrnn::sort() FullConnection* con_p = new FullConnection(_module_p, _module_p); con_p->set_mode(Component::Sequential); con_p->set_recurrent(recurrency); - // Multiply with the current blocks-per-dimension so that each + // Multiply with the current blocks-per-dimension so that each // connections jumps over one dimension. recurrency *= _sequence_shape_p[i] / _block_shape_p[i]; _connections[i].push_back(con_p); @@ -449,7 +449,7 @@ Mdrnn::sort() // Ininitialize buffers. init_buffers(); - + // Indicate that the net is ready for use. _dirty = false; } @@ -458,7 +458,7 @@ template void Mdrnn::clear() { - + BaseMdrnn::clear(); _bias.clear(); _module_p->clear(); @@ -518,7 +518,7 @@ Mdrnn::_forward() con_iter != con_vec_iter->end(); con_iter++) { - // If the current coordinate is zero, we are at a border of the + // If the current coordinate is zero, we are at a border of the // input in that dimension. In that case, the connections may // not be forwarded, since we don't want to look around corners. // The bias, however, which is the last connection in the vector @@ -548,8 +548,8 @@ Mdrnn::_forward() // the states in the output layer.) for(int i = 0; i < sequencelength(); i++) { - memcpy(output()[timestep()] + i * _hiddensize, - _module_p->output()[i], + memcpy(output()[timestep()] + i * _hiddensize, + _module_p->output()[i], _hiddensize * sizeof(double)); } delete[] coords_p; @@ -596,8 +596,8 @@ Mdrnn::_backward() _inmodule_p->add_to_input(input()[timestep() - 1] + i * blocksize()); _inmodule_p->forward(); - // We do not use add_to_outerror here, since this is broken for - // MdlstmLayers: the second half of the MdlstmLayers should ne get an + // We do not use add_to_outerror here, since this is broken for + // MdlstmLayers: the second half of the MdlstmLayers should ne get an // error signal since it's internal states. // TODO: this should be fixed, actually. double* mod_outerr_p = _module_p->outerror()[_module_p->timestep() - 1]; diff --git a/src/cpp/structure/networks/network.cpp b/src/cpp/structure/networks/network.cpp index a8b3707..c368b33 100644 --- a/src/cpp/structure/networks/network.cpp +++ b/src/cpp/structure/networks/network.cpp @@ -19,7 +19,7 @@ Network::Network() : } -Network::~Network() +Network::~Network() { } @@ -30,13 +30,13 @@ Network::clear() { BaseNetwork::clear(); std::vector::iterator comp_iter; - for(comp_iter = _components_sorted.begin(); + for(comp_iter = _components_sorted.begin(); comp_iter != _components_sorted.end(); ++comp_iter) { (*comp_iter)->clear(); } - for(comp_iter = _components_rec.begin(); + for(comp_iter = _components_rec.begin(); comp_iter != _components_rec.end(); ++comp_iter) { @@ -97,21 +97,21 @@ Network::_forward() } // First forward recurrent components. std::vector::iterator comp_iter; - for(comp_iter = _components_rec.begin(); + for(comp_iter = _components_rec.begin(); comp_iter != _components_rec.end(); ++comp_iter) { (*comp_iter)->forward(); } - + // Forward the non recurrent components in the right order. - for(comp_iter = _components_sorted.begin(); + for(comp_iter = _components_sorted.begin(); comp_iter != _components_sorted.end(); ++comp_iter) { (*comp_iter)->forward(); } - + // Copy outputs into the outputbuffer. double* sink_p = output()[timestep()]; for(mod_iter = _outmodules.begin(); mod_iter != _outmodules.end(); mod_iter++) @@ -132,8 +132,8 @@ Network::_backward() int this_timestep = timestep() - 1; std::vector::iterator mod_iter; double* error_p = outerror()[this_timestep]; - for(mod_iter = _outmodules.begin(); - mod_iter != _outmodules.end(); + for(mod_iter = _outmodules.begin(); + mod_iter != _outmodules.end(); mod_iter++) { Module* module_p = *mod_iter; @@ -146,10 +146,10 @@ Network::_backward() } error_p += size; } - + // First backward recurrent components. std::vector::iterator iter; - for(iter = _components_rec.begin(); + for(iter = _components_rec.begin(); iter != _components_rec.end(); iter++) { @@ -160,10 +160,10 @@ Network::_backward() } comp_p->backward(); } - + // Backward non recurrent components in reverse topological order. std::vector::reverse_iterator riter; - for(riter = _components_sorted.rbegin(); + for(riter = _components_sorted.rbegin(); riter != _components_sorted.rend(); riter++) { @@ -174,7 +174,7 @@ Network::_backward() } comp_p->backward(); } - + double* inerror_p = inerror()[this_timestep]; for(mod_iter = _inmodules.begin(); mod_iter != _inmodules.end(); @@ -182,7 +182,7 @@ Network::_backward() { Module* module_p = *mod_iter; int size = module_p->insize(); - // No -1 on the timestep, since the modules have been backwarded + // No -1 on the timestep, since the modules have been backwarded // already. int mod_timestep = module_p->timestep(); double* source_p = module_p->inerror()[mod_timestep]; @@ -215,9 +215,9 @@ Network::incoming_count(std::map& count) pair item(mod_iter->first, 0); count.insert(item); } - + std::vector::iterator con_iter; - for(con_iter = _connections.begin(); + for(con_iter = _connections.begin(); con_iter != _connections.end(); con_iter++) { @@ -242,16 +242,16 @@ Network::sort() std::vector::iterator mod_iter; std::vector::iterator con_iter; - + // Mapping from nodes to the number of incoming connections. std::map count; std::map::iterator count_iter; incoming_count(count); - + // Make up a vector of all nodes with no incoming connections. std::vector roots; - for(count_iter = count.begin(); - count_iter != count.end(); + for(count_iter = count.begin(); + count_iter != count.end(); count_iter++) { Module* module_p = count_iter->first; @@ -268,7 +268,7 @@ Network::sort() Module* current = roots.back(); roots.pop_back(); sorted.push_back(current); - for(con_iter = _outgoing_connections[current].begin(); + for(con_iter = _outgoing_connections[current].begin(); con_iter != _outgoing_connections[current].end(); con_iter++) { @@ -284,7 +284,7 @@ Network::sort() } } } - + for(count_iter = count.begin(); count_iter != count.end(); count_iter++) { if (count_iter->second != 0) @@ -296,7 +296,7 @@ Network::sort() // Fill the list of sorted components correctly. _components_sorted.clear(); - + // Then fill in the rest in topological order. for(mod_iter = sorted.begin(); mod_iter != sorted.end(); mod_iter++) { @@ -315,7 +315,7 @@ Network::sort() } } } - + init_buffers(); _dirty = false; } @@ -327,16 +327,16 @@ Network::init_buffers() std::vector::iterator mod_iter; _insize = 0; - for(mod_iter = _inmodules.begin(); - mod_iter != _inmodules.end(); + for(mod_iter = _inmodules.begin(); + mod_iter != _inmodules.end(); mod_iter++) { _insize += (*mod_iter)->insize(); } - + _outsize = 0; - for(mod_iter = _outmodules.begin(); - mod_iter != _outmodules.end(); + for(mod_iter = _outmodules.begin(); + mod_iter != _outmodules.end(); mod_iter++) { _outsize += (*mod_iter)->outsize(); diff --git a/src/cpp/structure/networks/network.h b/src/cpp/structure/networks/network.h index c091f09..1d416da 100644 --- a/src/cpp/structure/networks/network.h +++ b/src/cpp/structure/networks/network.h @@ -19,8 +19,8 @@ namespace arac { namespace structure { namespace networks { - - + + using namespace arac::structure::modules; using namespace arac::structure::connections; using arac::structure::Component; @@ -33,8 +33,8 @@ using arac::structure::Parametrized; /// class Network : public BaseNetwork { - public: - + public: + /// /// Different roles that modules can take in a Network object. /// @@ -48,17 +48,17 @@ class Network : public BaseNetwork // Combination of InputModule and OutputModule. InputOutputModule = 3 }; - + /// /// Create a new Network object. /// Network(); - + /// /// Destroy the Network object. /// virtual ~Network(); - + /// /// Set the buffers of all the modules in the network to zero. /// @@ -68,26 +68,26 @@ class Network : public BaseNetwork /// Add a module of the given type to the Network object. /// void add_module(Module* module_p, ModuleType type=Simple); - + /// /// Add a connection to the Network object. /// void add_connection(Connection* con_p); virtual void sort(); - + protected: - + virtual void _forward(); virtual void _backward(); - + void add_component(Component* comp_p); /// /// Fill count with the amount of incoming edges for every module. /// void incoming_count(std::map& count); - + void init_buffers(); std::vector _inmodules; @@ -98,8 +98,8 @@ class Network : public BaseNetwork std::vector _connections; std::map > _outgoing_connections; }; - - + + } } } diff --git a/src/cpp/structure/parametrized.cpp b/src/cpp/structure/parametrized.cpp index 482d9b0..c3851b1 100644 --- a/src/cpp/structure/parametrized.cpp +++ b/src/cpp/structure/parametrized.cpp @@ -17,7 +17,7 @@ Parametrized::Parametrized() : _parameters_p(0), _derivatives_p(0) { - + } @@ -34,8 +34,8 @@ _derivatives_owner(true) } -Parametrized::Parametrized(int size, - double* parameters_p, +Parametrized::Parametrized(int size, + double* parameters_p, double* derivatives_p) : _size(size), _parameters_p(parameters_p), @@ -43,8 +43,8 @@ _derivatives_p(derivatives_p), _parameters_owner(false), _derivatives_owner(false) { - -} + +} Parametrized::~Parametrized() { @@ -90,8 +90,8 @@ Parametrized::set_parameters(double* parameters_p) _parameters_p = parameters_p; _parameters_owner = false; } - - + + double* Parametrized::get_derivatives() const { diff --git a/src/cpp/structure/parametrized.h b/src/cpp/structure/parametrized.h index 1f90839..42f38c8 100644 --- a/src/cpp/structure/parametrized.h +++ b/src/cpp/structure/parametrized.h @@ -8,53 +8,53 @@ namespace arac { namespace structure { - + /// /// Classes that inherit from parametrized gain the ability to hold learnable /// parameters. /// -class Parametrized +class Parametrized { - public: + public: /// /// Create a new Parametrized object. /// Parametrized(); - + /// /// Create a new Parametrized object of the given size. /// Parametrized(int size); - + /// /// Wrap the given array with a new Parametrized object of the given /// size. Parametrized(int size, double* parameters_p, double* derivatives_p); - + /// /// Destroy the Parametrized object. /// virtual ~Parametrized(); - - /// + + /// /// Return a pointer to the parameters of the object. /// double* get_parameters() const; - /// + /// /// Set the pointer to the parameters of the object. /// void set_parameters(double* parameters_p); - - /// + + /// /// Return a pointer to the derviatives of the object. /// double* get_derivatives() const; - - /// + + /// /// Set the pointer to the parameters of the object. /// void set_derivatives(double* derivatives_p); @@ -63,27 +63,27 @@ class Parametrized /// Set all the derivatives to zero. /// virtual void clear_derivatives(); - + /// /// Tell wether the objects owns the parameters. /// bool parameters_owner(); - + /// /// Tell wether the object owns the derivatives. /// bool derivatives_owner(); - + /// /// Return the number of parameters. /// int size(); - + /// Set the parameters to random values in (-interval, +interval). void randomize(double interval=0.1); - + protected: - + int _size; double* _parameters_p; double* _derivatives_p; @@ -98,8 +98,8 @@ Parametrized::size() { return _size; } - - + + } } diff --git a/src/cpp/tests/test_datasets.cpp b/src/cpp/tests/test_datasets.cpp index b4139ad..90e2098 100644 --- a/src/cpp/tests/test_datasets.cpp +++ b/src/cpp/tests/test_datasets.cpp @@ -21,12 +21,12 @@ TEST(TestSequence, TestConstruction) data_p[7] = 128; data_p[8] = 256; data_p[9] = 512; - + Sequence seq(5, 2, data_p); - + EXPECT_EQ(5, seq.length()); EXPECT_EQ(2, seq.itemsize()); - + EXPECT_DOUBLE_EQ(1, seq[0][0]) << "Sequence data not correct."; EXPECT_DOUBLE_EQ(2, seq[0][1]) << "Sequence data not correct."; EXPECT_DOUBLE_EQ(4, seq[1][0]) << "Sequence data not correct."; @@ -53,9 +53,9 @@ TEST(TestDataset_sequence_array, TestConstruction) first_data_p[7] = 128; first_data_p[8] = 256; first_data_p[9] = 512; - + Sequence first(5, 2, first_data_p); - + double* second_data_p = new double[8]; second_data_p[0] = -1; second_data_p[1] = -2; @@ -65,21 +65,21 @@ TEST(TestDataset_sequence_array, TestConstruction) second_data_p[5] = -32; second_data_p[6] = -64; second_data_p[7] = -128; - + Sequence second(4, 2, second_data_p); - + double* first_target = new double[1]; first_target[0] = 1; double* second_target = new double[1]; second_target[0] = -1; - + SupervisedSemiSequentialDataset ds(2, 1); ds.append(first, first_target); ds.append(second, second_target); - + EXPECT_EQ(2, ds.size()) << "Wrong size of dataset."; - + EXPECT_EQ(1, ds[0].first[0][0]); EXPECT_EQ(2, ds[0].first[0][1]); EXPECT_EQ(4, ds[0].first[1][0]); @@ -90,7 +90,7 @@ TEST(TestDataset_sequence_array, TestConstruction) EXPECT_EQ(128, ds[0].first[3][1]); EXPECT_EQ(256, ds[0].first[4][0]); EXPECT_EQ(512, ds[0].first[4][1]); - + EXPECT_EQ(-1, ds[1].first[0][0]); EXPECT_EQ(-2, ds[1].first[0][1]); EXPECT_EQ(-4, ds[1].first[1][0]); @@ -111,28 +111,28 @@ TEST(TestDataset_array_array, TestConstruction) data_p[0] = 0; data_p[1] = 0; data_p[2] = 0; - + data_p[3] = 0; data_p[4] = 1; data_p[5] = 1; - + data_p[6] = 1; data_p[7] = 0; data_p[8] = 1; - + data_p[9] = 1; data_p[10] = 1; data_p[11] = 0; - + SupervisedSimpleDataset ds(2, 1); ds.append(data_p, data_p + 2); ds.append(data_p + 3, data_p + 5); ds.append(data_p + 6, data_p + 8); ds.append(data_p + 9, data_p + 11); - + EXPECT_EQ(4, ds.size()) << "Wrong size of dataset."; - + EXPECT_EQ(0, ds[0].first[0]) << "Wrong size of dataset."; EXPECT_EQ(0, ds[0].first[1]) @@ -165,10 +165,10 @@ TEST(TestDataset_array_array, TestConstruction) TEST(TestDataSet_sequential_sequential, TestConstruction) { - - + + } - + } // namespace \ No newline at end of file diff --git a/src/cpp/tests/test_optimzation.cpp b/src/cpp/tests/test_optimzation.cpp index 965c95e..84c79fd 100644 --- a/src/cpp/tests/test_optimzation.cpp +++ b/src/cpp/tests/test_optimzation.cpp @@ -18,23 +18,23 @@ TEST(TestBackprop, TestStochasticStepDoubleDouble) { LinearLayer* inlayer_p = new LinearLayer(1); LinearLayer* outlayer_p = new LinearLayer(2); - + FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - con_p->get_parameters()[0] = 1; - con_p->get_parameters()[1] = 2.5; - + con_p->get_parameters()[0] = 1; + con_p->get_parameters()[1] = 2.5; + Network* net_p= new Network(); net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); - + SupervisedDataset ds(1, 2); double* row_p = new double[3]; row_p[0] = 1; row_p[1] = 2; row_p[2] = 3; ds.append(row_p, row_p + 1); - + SimpleBackprop trainer(*net_p, ds); trainer.set_learningrate(1.); trainer.train_stochastic(); @@ -44,7 +44,7 @@ TEST(TestBackprop, TestStochasticStepDoubleDouble) EXPECT_DOUBLE_EQ(0.5, con_p->get_derivatives()[1]) << "Derivatives not correct."; - + EXPECT_DOUBLE_EQ(2, con_p->get_parameters()[0]) << "Parameters not learned correctly."; @@ -59,28 +59,28 @@ TEST(TestBackprop, TestStochasticStepSequenceDouble) LinearLayer* outlayer_p = new LinearLayer(1); inlayer_p->set_mode(Component::Sequential); outlayer_p->set_mode(Component::Sequential); - + FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - con_p->get_parameters()[0] = 2.0; + con_p->get_parameters()[0] = 2.0; con_p->set_mode(Component::Sequential); - + Network* net_p= new Network(); net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); net_p->set_mode(Component::Sequential); - + double* seq_p = new double[2]; seq_p[0] = 1; seq_p[1] = 2; Sequence seq(2, 1, seq_p); - + double* target_p = new double[1]; target_p[0] = 3.0; - + SupervisedDataset ds(1, 1); ds.append(seq, target_p); - + SemiSequentialBackprop trainer(*net_p, ds); trainer.set_learningrate(1.); trainer.train_stochastic(); @@ -101,28 +101,28 @@ TEST(TestBackprop, TestStochasticStepSequenceSequence) outlayer_p->set_mode(Component::Sequential); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - con_p->get_parameters()[0] = 1.5; + con_p->get_parameters()[0] = 1.5; con_p->set_mode(Component::Sequential); - + Network* net_p= new Network(); net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); net_p->set_mode(Component::Sequential); - + double* inseq_p = new double[2]; inseq_p[0] = 1; inseq_p[1] = 2; Sequence inseq(2, 1, inseq_p); - + double* outseq_p = new double[2]; outseq_p[0] = 2; outseq_p[1] = 4; Sequence outseq(2, 1, outseq_p); - + SupervisedDataset ds(1, 1); ds.append(inseq, outseq); - + SequentialBackprop trainer(*net_p, ds); trainer.set_learningrate(1.); trainer.train_stochastic(); @@ -140,11 +140,11 @@ TEST(TestDescent, TestStepDescent) double params_p[5] = {1, 2, 3, 4, 5}; double derivs_p[5] = {-1, -2, -3, -4, -5}; Parametrized p(5, params_p, derivs_p); - + StepDescender d(p, 0.5); - + d.notify(); - + double solution_p[5] = {0.5, 1, 1.5, 2, 2.5}; for (int i = 0; i < 5; i++) { @@ -153,7 +153,7 @@ TEST(TestDescent, TestStepDescent) } d.notify(); - + double solution2_p[5] = {0, 0, 0, 0, 0}; for (int i = 0; i < 5; i++) { @@ -168,20 +168,20 @@ TEST(TestDescent, TestStepDescentMomentum) double params_p[1] = {0}; double derivs_p[1] = {1}; Parametrized p(1, params_p, derivs_p); - + StepDescender d(p, 0.5, 0.5); - + d.notify(); - + EXPECT_EQ(0.5, params_p[0]) << "Wrong update at first step."; derivs_p[0] = 2; d.notify(); - + EXPECT_EQ(1.75, params_p[0]) << "Wrong update at second step."; } - + // TODO: write a test for contained networks. - + } // namespace diff --git a/src/cpp/tests/test_structure.cpp b/src/cpp/tests/test_structure.cpp index 51db320..cbca5e1 100644 --- a/src/cpp/tests/test_structure.cpp +++ b/src/cpp/tests/test_structure.cpp @@ -18,45 +18,45 @@ TEST(TestCommon, TestBuffer) { double* addend_p = new double[2]; addend_p[0] = 1.2; addend_p[1] = 2.4; - + EXPECT_DOUBLE_EQ(0, buffer[0][0]) << "Buffer not correctly initialized"; EXPECT_DOUBLE_EQ(0, buffer[0][1]) << "Buffer not correctly initialized"; - + buffer.add(addend_p); - + EXPECT_DOUBLE_EQ(1.2, buffer[0][0]) << "Adding to buffer incorrect."; EXPECT_DOUBLE_EQ(2.4, buffer[0][1]) << "Adding to buffer incorrect."; - + buffer.add(addend_p); - + EXPECT_DOUBLE_EQ(2.4, buffer[0][0]) << "Adding to buffer incorrect."; EXPECT_DOUBLE_EQ(4.8, buffer[0][1]) << "Adding to buffer incorrect."; - + buffer.expand(); - + EXPECT_DOUBLE_EQ(0, buffer[1][0]) << "Buffer not correctly initialized"; EXPECT_DOUBLE_EQ(0, buffer[1][1]) << "Buffer not correctly initialized"; - + EXPECT_EQ(2, buffer.size()) << "Buffersize incorrect."; - + buffer.add(addend_p); - + EXPECT_DOUBLE_EQ(1.2, buffer[1][0]) << "Adding to buffer incorrect."; EXPECT_DOUBLE_EQ(2.4, buffer[1][1]) << "Adding to buffer incorrect."; buffer.clear(); - + EXPECT_DOUBLE_EQ(0, buffer[0][0]) << "Setting buffer to zero incorrect."; EXPECT_DOUBLE_EQ(0, buffer[0][1]) @@ -113,15 +113,15 @@ TEST(TestModules, TestModuleClear) { double* content_p = new double[2]; content_p[0] = 1; content_p[1] = 1; - + layer.add_to_input(content_p); EXPECT_DOUBLE_EQ(1, buffer[0][0]) << "Adding values did not work."; EXPECT_DOUBLE_EQ(1, buffer[0][1]) << "Adding values did not work."; - + layer.clear(); - + EXPECT_DOUBLE_EQ(0, buffer[0][0]) << "Clearing Module incorrect."; EXPECT_DOUBLE_EQ(0, buffer[0][1]) @@ -157,17 +157,17 @@ TEST(TestModules, LinearLayer) { << "LinearLayer::add_to_input not working."; layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(2, layer_p->input()[0][0]) << "LinearLayer::add_to_input not working."; ASSERT_DOUBLE_EQ(3, layer_p->input()[0][1]) << "LinearLayer::add_to_input not working."; - + layer_p->forward(); - + ASSERT_DOUBLE_EQ(2, layer_p->output()[0][0]) << "Forward pass incorrect."; - + ASSERT_DOUBLE_EQ(3, layer_p->output()[0][1]) << "Forward pass incorrect."; @@ -176,10 +176,10 @@ TEST(TestModules, LinearLayer) { outerror_p[1] = -.3; layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(1, layer_p->inerror()[0][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(-0.3, layer_p->inerror()[0][1]) << "Backward pass incorrect."; } @@ -194,12 +194,12 @@ TEST(TestModules, CosineLayer) { input_p[2] = 0.; layer_p->add_to_input(input_p); - + layer_p->forward(); - + ASSERT_DOUBLE_EQ(0.6, layer_p->output()[0][0]) << "Forward pass incorrect."; - + ASSERT_DOUBLE_EQ(0.8, layer_p->output()[0][1]) << "Forward pass incorrect."; @@ -208,10 +208,10 @@ TEST(TestModules, CosineLayer) { outerror_p[1] = 3; layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(0.128, layer_p->inerror()[0][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(0.216, layer_p->inerror()[0][1]) << "Backward pass incorrect."; @@ -229,33 +229,33 @@ TEST(TestModules, LinearLayerSequential) { input_p[1] = 3.; layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(2, layer_p->input()[0][0]) << "LinearLayer::add_to_input not working."; ASSERT_DOUBLE_EQ(3, layer_p->input()[0][1]) << "LinearLayer::add_to_input not working."; - + layer_p->forward(); ASSERT_DOUBLE_EQ(2, layer_p->output()[0][0]) << "Forward pass incorrect."; - + ASSERT_DOUBLE_EQ(3, layer_p->output()[0][1]) << "Forward pass incorrect."; - + layer_p->add_to_input(input_p); layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(4, layer_p->input()[1][0]) << "LinearLayer::add_to_input not working."; ASSERT_DOUBLE_EQ(6, layer_p->input()[1][1]) << "LinearLayer::add_to_input not working."; - + layer_p->forward(); - + ASSERT_DOUBLE_EQ(4, layer_p->output()[1][0]) << "Forward pass incorrect."; - + ASSERT_DOUBLE_EQ(6, layer_p->output()[1][1]) << "Forward pass incorrect."; @@ -264,35 +264,35 @@ TEST(TestModules, LinearLayerSequential) { outerror_p[1] = -.3; layer_p->add_to_outerror(outerror_p); - + EXPECT_DOUBLE_EQ(1, layer_p->outerror()[1][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(-0.3, layer_p->outerror()[1][1]) << "Backward pass incorrect."; - + layer_p->backward(); - + EXPECT_DOUBLE_EQ(1, layer_p->inerror()[1][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(-0.3, layer_p->inerror()[1][1]) << "Backward pass incorrect."; - + layer_p->add_to_outerror(outerror_p); layer_p->add_to_outerror(outerror_p); EXPECT_DOUBLE_EQ(1, layer_p->outerror()[1][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(-0.3, layer_p->outerror()[1][1]) << "Backward pass incorrect."; - + layer_p->backward(); - + EXPECT_DOUBLE_EQ(2, layer_p->inerror()[0][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(-0.6, layer_p->inerror()[0][1]) << "Backward pass incorrect."; } @@ -300,16 +300,16 @@ TEST(TestModules, LinearLayerSequential) { TEST(TestModules, SigmoidLayer) { SigmoidLayer* layer_p = new SigmoidLayer(5); - + double* input_p = new double[5]; input_p[0] = -1; input_p[1] = -0.5; input_p[2] = 0; input_p[3] = 0.5; input_p[4] = 1; - + layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(-1, layer_p->input()[0][0]) << "add_to_input not working."; ASSERT_DOUBLE_EQ(-0.5, layer_p->input()[0][1]) @@ -320,9 +320,9 @@ TEST(TestModules, SigmoidLayer) { << "add_to_input not working."; ASSERT_DOUBLE_EQ(1, layer_p->input()[0][4]) << "add_to_input not working."; - + layer_p->forward(); - + EXPECT_DOUBLE_EQ(0.2689414213699951, layer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0.37754066879814541, layer_p->output()[0][1]) @@ -333,17 +333,17 @@ TEST(TestModules, SigmoidLayer) { << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0.7310585786300049, layer_p->output()[0][4]) << "Forward pass incorrect."; - + double* outerror_p = new double[5]; outerror_p[0] = 2; outerror_p[1] = 4; outerror_p[2] = 6; outerror_p[3] = 8; outerror_p[4] = 10; - + layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(0.3932238664829637, layer_p->inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0.94001484880637798, layer_p->inerror()[0][1]) @@ -359,16 +359,16 @@ TEST(TestModules, SigmoidLayer) { TEST(TestModules, TanhLayer) { TanhLayer* layer_p = new TanhLayer(5); - + double* input_p = new double[5]; input_p[0] = -1; input_p[1] = -0.5; input_p[2] = 0; input_p[3] = 0.5; input_p[4] = 1; - + layer_p->add_to_input(input_p); - + EXPECT_DOUBLE_EQ(-1, layer_p->input()[0][0]) << "add_to_input not working."; EXPECT_DOUBLE_EQ(-0.5, layer_p->input()[0][1]) @@ -379,9 +379,9 @@ TEST(TestModules, TanhLayer) { << "add_to_input not working."; EXPECT_DOUBLE_EQ(1, layer_p->input()[0][4]) << "add_to_input not working."; - + layer_p->forward(); - + EXPECT_DOUBLE_EQ(-0.76159415595576485, layer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(-0.46211715726000974, layer_p->output()[0][1]) @@ -392,17 +392,17 @@ TEST(TestModules, TanhLayer) { << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0.76159415595576485, layer_p->output()[0][4]) << "Forward pass incorrect."; - + double* outerror_p = new double[5]; outerror_p[0] = 2; outerror_p[1] = 4; outerror_p[2] = 6; outerror_p[3] = 8; outerror_p[4] = 10; - + layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(0.83994868322805227, layer_p->inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(3.1457909318637096, layer_p->inerror()[0][1]) @@ -425,22 +425,22 @@ TEST(TestModules, SoftmaxLayer) { input_p[2] = 15.440919648395607; layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(input_p[0], layer_p->input()[0][0]) << "add_to_input not working."; ASSERT_DOUBLE_EQ(input_p[1], layer_p->input()[0][1]) << "add_to_input not working."; ASSERT_DOUBLE_EQ(input_p[2], layer_p->input()[0][2]) << "add_to_input not working."; - + layer_p->forward(); - + ASSERT_DOUBLE_EQ(2.0171481969464377e-05, layer_p->output()[0][0]) << "Forward pass incorrect."; - + ASSERT_DOUBLE_EQ(1.3694739368803625e-07, layer_p->output()[0][1]) << "Forward pass incorrect."; - + ASSERT_DOUBLE_EQ(0.99997969157063693, layer_p->output()[0][2]) << "Forward pass incorrect."; @@ -449,10 +449,10 @@ TEST(TestModules, SoftmaxLayer) { outerror_p[1] = 4; layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(2, layer_p->inerror()[0][0]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(4, layer_p->inerror()[0][1]) << "Backward pass incorrect."; } @@ -460,15 +460,15 @@ TEST(TestModules, SoftmaxLayer) { TEST(TestModules, GateLayer) { GateLayer* layer_p = new GateLayer(2); - + double* input_p = new double[4]; input_p[0] = 1; input_p[1] = 2; input_p[2] = 3; input_p[3] = 4; - + layer_p->add_to_input(input_p); - + EXPECT_DOUBLE_EQ(1, layer_p->input()[0][0]) << "add_to_input not working."; EXPECT_DOUBLE_EQ(2, layer_p->input()[0][1]) @@ -477,21 +477,21 @@ TEST(TestModules, GateLayer) { << "add_to_input not working."; EXPECT_DOUBLE_EQ(4, layer_p->input()[0][3]) << "add_to_input not working."; - + layer_p->forward(); - + EXPECT_DOUBLE_EQ(2.1931757358900148, layer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(3.5231883119115293, layer_p->output()[0][1]) << "Forward pass incorrect."; - + double* outerror_p = new double[2]; outerror_p[0] = -1; outerror_p[1] = 1; - + layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(-0.58983579972444555, layer_p->inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0.41997434161402647, layer_p->inerror()[0][1]) @@ -509,10 +509,10 @@ TEST(TestModules, DoubleGateLayer) DoubleGateLayer layer(2); layer.add_to_input(inpt); layer.forward(); - - double solution_p[4] = {0.35760876606635261, - -0.88079707797788231, - 2.6423912339336475, + + double solution_p[4] = {0.35760876606635261, + -0.88079707797788231, + 2.6423912339336475, -0.119202922022117690}; for (int i = 0; i < 4; i++) { @@ -527,10 +527,10 @@ TEST(TestModules, SwitchLayer) SwitchLayer layer(2); layer.add_to_input(inpt); layer.forward(); - - double solution_p[4] = {0.11920292202211755, - 0.92414181997875655, - 0.88079707797788243, + + double solution_p[4] = {0.11920292202211755, + 0.92414181997875655, + 0.88079707797788243, 0.075858180021243449}; for (int i = 0; i < 4; i++) { @@ -545,7 +545,7 @@ TEST(TestModules, MultiplicationLayer) MultiplicationLayer layer(2); layer.add_to_input(inpt); layer.forward(); - + double solution_p[2] = {-6.0, -2.5}; for (int i = 0; i < 2; i++) { @@ -556,15 +556,15 @@ TEST(TestModules, MultiplicationLayer) TEST(TestModules, PartialSoftmaxLayer) { PartialSoftmaxLayer* layer_p = new PartialSoftmaxLayer(4, 2); - + double* input_p = new double[5]; input_p[0] = 2; input_p[1] = 4; input_p[2] = 4; input_p[3] = 8; - + layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(2, layer_p->input()[0][0]) << "add_to_input not working."; ASSERT_DOUBLE_EQ(4, layer_p->input()[0][1]) @@ -573,9 +573,9 @@ TEST(TestModules, PartialSoftmaxLayer) { << "add_to_input not working."; ASSERT_DOUBLE_EQ(8, layer_p->input()[0][3]) << "add_to_input not working."; - + layer_p->forward(); - + EXPECT_DOUBLE_EQ(0.11920292202211756, layer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0.88079707797788243, layer_p->output()[0][1]) @@ -584,16 +584,16 @@ TEST(TestModules, PartialSoftmaxLayer) { << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0.90155367443998624, layer_p->output()[0][3]) << "Forward pass incorrect."; - + double* outerror_p = new double[5]; outerror_p[0] = 2; outerror_p[1] = 4; outerror_p[2] = 1; outerror_p[3] = 3; - + layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(2, layer_p->inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(4, layer_p->inerror()[0][1]) @@ -607,15 +607,15 @@ TEST(TestModules, PartialSoftmaxLayer) { TEST(TestModules, LstmLayer) { LstmLayer* layer_p = new LstmLayer(1); - + double* input_p = new double[4]; input_p[0] = 1; input_p[1] = 2; input_p[2] = 3; input_p[3] = 4; - + layer_p->add_to_input(input_p); - + ASSERT_DOUBLE_EQ(1, layer_p->input()[0][0]) << "add_to_input not working."; ASSERT_DOUBLE_EQ(2, layer_p->input()[0][1]) @@ -624,42 +624,42 @@ TEST(TestModules, LstmLayer) { << "add_to_input not working."; ASSERT_DOUBLE_EQ(4, layer_p->input()[0][3]) << "add_to_input not working."; - + layer_p->forward(); - + EXPECT_DOUBLE_EQ(0.61032029727785686, layer_p->output()[0][0]) << "Forward pass incorrect."; - + EXPECT_DOUBLE_EQ(0.72744331388925076, layer_p->state()[0][0]) << "State incorrect."; - + input_p[0] = 1; input_p[1] = -2; input_p[2] = 3; input_p[3] = 4; - + layer_p->add_to_input(input_p); - + layer_p->forward(); - + EXPECT_DOUBLE_EQ(0.65979239214347674, layer_p->output()[1][0]) << "Forward pass incorrect."; - + EXPECT_DOUBLE_EQ(0.81415668251030193, layer_p->state()[1][0]) << "State incorrect."; - + double* outerror_p = new double[1]; outerror_p[0] = -1; - + layer_p->add_to_outerror(outerror_p); - + ASSERT_DOUBLE_EQ(0, layer_p->outerror()[0][0]) << "add_to_error does not work."; ASSERT_DOUBLE_EQ(-1, layer_p->outerror()[1][0]) << "add_to_error does not work."; - + layer_p->backward(); - + EXPECT_DOUBLE_EQ(-0.10539391322654772, layer_p->inerror()[1][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(-0.041145334820469018, layer_p->inerror()[1][1]) @@ -668,16 +668,16 @@ TEST(TestModules, LstmLayer) { << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(-0.011867164496483215, layer_p->inerror()[1][3]) << "Backward pass incorrect."; - + outerror_p[0] = 2; - + layer_p->add_to_outerror(outerror_p); - + ASSERT_DOUBLE_EQ(2, layer_p->outerror()[0][0]) << "add_to_error does not work."; - + layer_p->backward(); - + EXPECT_DOUBLE_EQ(0.22326096032509266, layer_p->inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, layer_p->inerror()[0][1]) @@ -691,7 +691,7 @@ TEST(TestModules, LstmLayer) { TEST(TestModules, MdlstmLayer) { MdlstmLayer* layer_p = new MdlstmLayer(1, 2); - + double* input_p = new double[10]; input_p[0] = -2; input_p[1] = 1; @@ -703,10 +703,10 @@ TEST(TestModules, MdlstmLayer) { input_p[7] = 7; input_p[8] = 8; input_p[9] = 9; - + layer_p->add_to_input(input_p); layer_p->forward(); - + EXPECT_DOUBLE_EQ(0.99752618538000837, layer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0.99908893224240791, layer_p->output()[0][1]) @@ -715,16 +715,16 @@ TEST(TestModules, MdlstmLayer) { << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(9.3041593430291716, layer_p->output()[0][3]) << "Forward pass incorrect."; - + double* outerror_p = new double[5]; outerror_p[0] = -1; outerror_p[1] = 3; outerror_p[2] = 1; outerror_p[3] = 2; - + layer_p->add_to_outerror(outerror_p); layer_p->backward(); - + EXPECT_DOUBLE_EQ(0.10492291615431382, layer_p->inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0.39318818296939362, layer_p->inerror()[0][1]) @@ -775,28 +775,28 @@ TEST(TestModules, ErrorScalingLayer) TEST(TestConnections, IdentityConnection) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + IdentityConnection* con_p = new IdentityConnection(inlayer_p, outlayer_p); - + inlayer_p->forward(); con_p->forward(); outlayer_p->forward(); - + EXPECT_DOUBLE_EQ(2., outlayer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(3., outlayer_p->output()[0][1]) << "Forward pass incorrect."; - + outlayer_p->outerror()[0][0] = 0.5; outlayer_p->outerror()[0][1] = 1.2; outlayer_p->backward(); - + con_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(0.5, inlayer_p->outerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(1.2, inlayer_p->outerror()[0][1]) @@ -808,61 +808,61 @@ TEST(TestConnections, RecurrentIdentityConnection) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); IdentityConnection* con_p = new IdentityConnection(inlayer_p, outlayer_p); - + inlayer_p->set_mode(Component::Sequential); outlayer_p->set_mode(Component::Sequential); con_p->set_mode(Component::Sequential); con_p->set_recurrent(1); - + // First some data that should not have any effect immediately. - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); - + EXPECT_DOUBLE_EQ(0, outlayer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(0, outlayer_p->output()[0][1]) << "Forward pass incorrect."; - + // Now the previous information should pass through. - + inlayer_p->input()[0][0] = 0.5; inlayer_p->input()[0][1] = 3.2; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); - + EXPECT_DOUBLE_EQ(2, outlayer_p->output()[1][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(3, outlayer_p->output()[1][1]) << "Forward pass incorrect."; - - // Let's do a backward pass. - + + // Let's do a backward pass. + outlayer_p->outerror()[1][0] = 0.5; outlayer_p->outerror()[1][1] = 1.2; con_p->backward(); outlayer_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][1]) << "Backward pass incorrect."; - + outlayer_p->outerror()[0][0] = 2.3; outlayer_p->outerror()[0][1] = 1.8; con_p->backward(); outlayer_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(0.5, inlayer_p->outerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(1.2, inlayer_p->outerror()[0][1]) @@ -873,13 +873,13 @@ TEST(TestConnections, RecurrentIdentityConnection) { TEST(TestConnections, IdentityConnectionSliced) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + IdentityConnection* con_p = \ new IdentityConnection(inlayer_p, outlayer_p, 0, 1, 1, 2); - + ASSERT_EQ(0, con_p->get_incomingstart()) << "_incomingstart not initialized properly."; ASSERT_EQ(1, con_p->get_incomingstop()) @@ -888,23 +888,23 @@ TEST(TestConnections, IdentityConnectionSliced) { << "_outgoingstart not initialized properly."; ASSERT_EQ(2, con_p->get_outgoingstop()) << "_ougoingstop not initialized properly."; - + inlayer_p->forward(); con_p->forward(); outlayer_p->forward(); - + ASSERT_DOUBLE_EQ(0., outlayer_p->output()[0][0]) << "Forward pass incorrect."; ASSERT_DOUBLE_EQ(2., outlayer_p->output()[0][1]) << "Forward pass incorrect."; - + outlayer_p->outerror()[0][0] = 0.5; outlayer_p->outerror()[0][1] = 1.2; outlayer_p->backward(); - + con_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(1.2, inlayer_p->outerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[0][1]) @@ -915,35 +915,35 @@ TEST(TestConnections, IdentityConnectionSliced) { TEST(TestConnections, FullConnection) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(3); - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - con_p->get_parameters()[0] = 0; - con_p->get_parameters()[1] = 1; - con_p->get_parameters()[2] = 2; - con_p->get_parameters()[3] = 3; - con_p->get_parameters()[4] = 4; + con_p->get_parameters()[0] = 0; + con_p->get_parameters()[1] = 1; + con_p->get_parameters()[2] = 2; + con_p->get_parameters()[3] = 3; + con_p->get_parameters()[4] = 4; con_p->get_parameters()[5] = 5; - + inlayer_p->forward(); con_p->forward(); - + EXPECT_DOUBLE_EQ(3, outlayer_p->input()[0][0]) << "Forward pass not working."; EXPECT_DOUBLE_EQ(13, outlayer_p->input()[0][1]) << "Forward pass not working."; EXPECT_DOUBLE_EQ(23, outlayer_p->input()[0][2]) << "Forward pass not working."; - + outlayer_p->forward(); outlayer_p->outerror()[0][0] = 0.5; outlayer_p->outerror()[0][1] = 1.2; outlayer_p->outerror()[0][2] = 3.4; outlayer_p->backward(); con_p->backward(); - + EXPECT_DOUBLE_EQ(16, inlayer_p->outerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(21.1, inlayer_p->outerror()[0][1]) @@ -967,28 +967,28 @@ TEST(TestConnections, FullConnection) { TEST(TestConnections, LinearConnection) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + LinearConnection* con_p = new LinearConnection(inlayer_p, outlayer_p); - con_p->get_parameters()[0] = 1.5; - con_p->get_parameters()[1] = 2; - + con_p->get_parameters()[0] = 1.5; + con_p->get_parameters()[1] = 2; + inlayer_p->forward(); con_p->forward(); - + EXPECT_DOUBLE_EQ(3, outlayer_p->input()[0][0]) << "Forward pass not working."; EXPECT_DOUBLE_EQ(6, outlayer_p->input()[0][1]) << "Forward pass not working."; - + outlayer_p->forward(); outlayer_p->outerror()[0][0] = 0.5; outlayer_p->outerror()[0][1] = 1.2; outlayer_p->backward(); con_p->backward(); - + EXPECT_DOUBLE_EQ(0.75, inlayer_p->outerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(2.4, inlayer_p->outerror()[0][1]) @@ -1004,13 +1004,13 @@ TEST(TestConnections, LinearConnection) { TEST(TestConnections, FullConnectionSliced) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(3); - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - - FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p, + + FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p, 0, 1, 0, 3); - + ASSERT_EQ(0, con_p->get_incomingstart()) << "_incomingstart not initialized properly."; ASSERT_EQ(1, con_p->get_incomingstop()) @@ -1019,28 +1019,28 @@ TEST(TestConnections, FullConnectionSliced) { << "_outgoingstart not initialized properly."; ASSERT_EQ(3, con_p->get_outgoingstop()) << "_ougoingstop not initialized properly."; - + con_p->get_parameters()[0] = -1; - con_p->get_parameters()[1] = 1; - con_p->get_parameters()[2] = 2; - + con_p->get_parameters()[1] = 1; + con_p->get_parameters()[2] = 2; + inlayer_p->forward(); con_p->forward(); - + ASSERT_DOUBLE_EQ(-2, outlayer_p->input()[0][0]) << "Forward pass not working."; ASSERT_DOUBLE_EQ(2, outlayer_p->input()[0][1]) << "Forward pass not working."; ASSERT_DOUBLE_EQ(4, outlayer_p->input()[0][2]) << "Forward pass not working."; - + outlayer_p->forward(); outlayer_p->outerror()[0][0] = 0.5; outlayer_p->outerror()[0][1] = 1.2; outlayer_p->outerror()[0][2] = 3.4; outlayer_p->backward(); con_p->backward(); - + EXPECT_DOUBLE_EQ(1, con_p->get_derivatives()[0]) << "Backward pass not working."; EXPECT_DOUBLE_EQ(2.4, con_p->get_derivatives()[1]) @@ -1054,17 +1054,17 @@ TEST(TestConnections, RecurrentFullConnection) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(3); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + inlayer_p->set_mode(Component::Sequential); outlayer_p->set_mode(Component::Sequential); con_p->set_mode(Component::Sequential); con_p->set_recurrent(1); - - con_p->get_parameters()[0] = 0; - con_p->get_parameters()[1] = 1; - con_p->get_parameters()[2] = 2; - con_p->get_parameters()[3] = 3; - con_p->get_parameters()[4] = 4; + + con_p->get_parameters()[0] = 0; + con_p->get_parameters()[1] = 1; + con_p->get_parameters()[2] = 2; + con_p->get_parameters()[3] = 3; + con_p->get_parameters()[4] = 4; con_p->get_parameters()[5] = 5; EXPECT_DOUBLE_EQ(0, outlayer_p->input()[0][0]) @@ -1075,38 +1075,38 @@ TEST(TestConnections, RecurrentFullConnection) { << "Buffer not properly initialized."; // First some data that should not have any effect immediately. - + inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); - + EXPECT_DOUBLE_EQ(0, outlayer_p->input()[0][0]) << "Forward pass not working."; EXPECT_DOUBLE_EQ(0, outlayer_p->input()[0][1]) << "Forward pass not working."; EXPECT_DOUBLE_EQ(0, outlayer_p->input()[0][2]) << "Forward pass not working."; - + // Now the previous information should pass through. inlayer_p->input()[1][0] = 0.5; inlayer_p->input()[1][1] = 3.2; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); - + EXPECT_DOUBLE_EQ(3, outlayer_p->output()[1][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(13, outlayer_p->output()[1][1]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(23, outlayer_p->output()[1][2]) << "Forward pass incorrect."; - - // Let's do a backward pass. - + + // Let's do a backward pass. + outlayer_p->outerror()[1][0] = 0.5; outlayer_p->outerror()[1][1] = 1.2; outlayer_p->outerror()[1][2] = 3.4; @@ -1114,12 +1114,12 @@ TEST(TestConnections, RecurrentFullConnection) { con_p->backward(); outlayer_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][1]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[0]) << "Backward pass not working."; EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[1]) @@ -1140,7 +1140,7 @@ TEST(TestConnections, RecurrentFullConnection) { con_p->backward(); outlayer_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(1, con_p->get_derivatives()[0]) << "Backward pass not working."; EXPECT_DOUBLE_EQ(1.5, con_p->get_derivatives()[1]) @@ -1160,17 +1160,17 @@ TEST(TestConnections, DeepRecurrentFullConnection) { LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(3); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + inlayer_p->set_mode(Component::Sequential); outlayer_p->set_mode(Component::Sequential); con_p->set_mode(Component::Sequential); con_p->set_recurrent(2); - - con_p->get_parameters()[0] = 0; - con_p->get_parameters()[1] = 1; - con_p->get_parameters()[2] = 2; - con_p->get_parameters()[3] = 3; - con_p->get_parameters()[4] = 4; + + con_p->get_parameters()[0] = 0; + con_p->get_parameters()[1] = 1; + con_p->get_parameters()[2] = 2; + con_p->get_parameters()[3] = 3; + con_p->get_parameters()[4] = 4; con_p->get_parameters()[5] = 5; EXPECT_DOUBLE_EQ(0, outlayer_p->input()[0][0]) @@ -1183,7 +1183,7 @@ TEST(TestConnections, DeepRecurrentFullConnection) { // FIRST STEP FORWARD inlayer_p->input()[0][0] = 2.; inlayer_p->input()[0][1] = 3.; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); @@ -1200,7 +1200,7 @@ TEST(TestConnections, DeepRecurrentFullConnection) { inlayer_p->input()[1][0] = 0.; inlayer_p->input()[1][1] = 0.; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); @@ -1213,24 +1213,24 @@ TEST(TestConnections, DeepRecurrentFullConnection) { << "Forward pass not working."; // THIRD STEP FORWARD - + inlayer_p->input()[2][0] = 0; inlayer_p->input()[2][1] = 0; - + con_p->forward(); inlayer_p->forward(); outlayer_p->forward(); - + EXPECT_DOUBLE_EQ(3, outlayer_p->output()[2][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(13, outlayer_p->output()[2][1]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(23, outlayer_p->output()[2][2]) << "Forward pass incorrect."; - - + + // FIRST STEP BACKWARD - + outlayer_p->outerror()[2][0] = 0.5; outlayer_p->outerror()[2][1] = 1.2; outlayer_p->outerror()[2][2] = 3.4; @@ -1245,12 +1245,12 @@ TEST(TestConnections, DeepRecurrentFullConnection) { << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(3.4, outlayer_p->inerror()[2][2]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[2][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[2][1]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[0]) << "Backward pass not working."; EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[1]) @@ -1263,10 +1263,10 @@ TEST(TestConnections, DeepRecurrentFullConnection) { << "Backward pass not working."; EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[5]) << "Backward pass not working."; - + // SECOND STEP BACKWARDS - + outlayer_p->outerror()[1][0] = -1; outlayer_p->outerror()[1][1] = -1; outlayer_p->outerror()[1][2] = -1; @@ -1274,12 +1274,12 @@ TEST(TestConnections, DeepRecurrentFullConnection) { con_p->backward(); outlayer_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][1]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[0]) << "Backward pass not working."; EXPECT_DOUBLE_EQ(0, con_p->get_derivatives()[1]) @@ -1303,7 +1303,7 @@ TEST(TestConnections, DeepRecurrentFullConnection) { con_p->backward(); outlayer_p->backward(); inlayer_p->backward(); - + EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[2][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[2][1]) @@ -1313,12 +1313,12 @@ TEST(TestConnections, DeepRecurrentFullConnection) { << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(0, inlayer_p->outerror()[1][1]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(16, inlayer_p->outerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(21.1, inlayer_p->outerror()[0][1]) << "Backward pass incorrect."; - + EXPECT_DOUBLE_EQ(1, con_p->get_derivatives()[0]) << "Backward pass not working."; EXPECT_DOUBLE_EQ(1.5, con_p->get_derivatives()[1]) @@ -1336,7 +1336,7 @@ TEST(TestConnections, DeepRecurrentFullConnection) { TEST(TestNetwork, TestCopyResult) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); IdentityConnection* con_p = new IdentityConnection(inlayer_p, outlayer_p); @@ -1344,7 +1344,7 @@ TEST(TestNetwork, TestCopyResult) { net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); - + double* input_p = new double[2]; input_p[0] = 2; input_p[1] = 4; @@ -1352,9 +1352,9 @@ TEST(TestNetwork, TestCopyResult) { double* output_p = new double[2]; output_p[0] = 0; output_p[1] = 0; - + net_p->activate(input_p, output_p); - + ASSERT_DOUBLE_EQ(2, output_p[0]) << "Data not copied correctly into inmodule."; ASSERT_DOUBLE_EQ(4, output_p[1]) @@ -1364,7 +1364,7 @@ TEST(TestNetwork, TestCopyResult) { TEST(TestNetwork, TestAddParametrized) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); @@ -1379,24 +1379,24 @@ TEST(TestNetwork, TestAddParametrized) { TEST(TestNetwork, TestTwoLayerNetwork) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->get_parameters()[0] = 0.5; con_p->get_parameters()[1] = -2; con_p->get_parameters()[2] = 1.2; con_p->get_parameters()[3] = 4; - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); - + double* input_p = new double[2]; input_p[0] = 2; input_p[1] = 4; - + const double* output_p = net_p->activate(input_p); ASSERT_DOUBLE_EQ(2, net_p->input()[0][0]) @@ -1408,23 +1408,23 @@ TEST(TestNetwork, TestTwoLayerNetwork) { << "Data not copied correctly into inmodule."; ASSERT_DOUBLE_EQ(4, inlayer_p->input()[0][1]) << "Data not copied correctly into inmodule."; - + EXPECT_DOUBLE_EQ(-7, outlayer_p->output()[0][0]) << "Forward pass incorrect."; EXPECT_DOUBLE_EQ(18.4, outlayer_p->output()[0][1]) << "Forward pass incorrect."; - + EXPECT_DOUBLE_EQ(-7, output_p[0]) << "activate() Result not correct."; EXPECT_DOUBLE_EQ(18.4, output_p[1]) << "activate() Result not correct."; - + double* outerror_p = new double[2]; outerror_p[0] = 3; outerror_p[1] = -2; const double* inerror_p = net_p->back_activate(outerror_p); - + ASSERT_DOUBLE_EQ(3, net_p->outerror()[0][0]) << "Error not copied correctly into network outerror buffer."; ASSERT_DOUBLE_EQ(-2, net_p->outerror()[0][1]) @@ -1460,14 +1460,14 @@ TEST(TestNetwork, TestTwoLayerNetwork) { << "Derivatives incorrect."; net_p->clear(); - + for (int i = 0; i < net_p->input().size(); i++) { for (int j = 0; j < net_p->input().rowsize(); j++) { ASSERT_DOUBLE_EQ(0, net_p->input()[i][j]) << "Buffer has not been set to zero at " << i << " " << j; - + } } } @@ -1476,7 +1476,7 @@ TEST(TestNetwork, TestTwoLayerNetwork) { TEST(TestNetwork, TestRecurrentLayerNetwork) { Network* net_p = new Network(); net_p->set_mode(Component::Sequential); - + LinearLayer* inlayer_p = new LinearLayer(2); inlayer_p->set_mode(Component::Sequential); @@ -1489,16 +1489,16 @@ TEST(TestNetwork, TestRecurrentLayerNetwork) { IdentityConnection* rcon_p = new IdentityConnection(inlayer_p, outlayer_p); rcon_p->set_mode(Component::Sequential); rcon_p->set_recurrent(1); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); net_p->add_connection(rcon_p); - + double* input_p = new double[2]; input_p[0] = 2; input_p[1] = 4; - + net_p->activate(input_p); EXPECT_DOUBLE_EQ(2, outlayer_p->output()[0][0]) @@ -1540,20 +1540,20 @@ TEST(TestNetwork, TestRecurrentLayerNetwork) { TEST(TestNetwork, TestRecurrentNetworkTimesteps) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); - + net_p->set_mode(Component::Sequential); inlayer_p->set_mode(Component::Sequential); outlayer_p->set_mode(Component::Sequential); con_p->set_mode(Component::Sequential); - + double* input_p = new double[3]; input_p[0] = 2; input_p[1] = 4; @@ -1689,7 +1689,7 @@ TEST(TestNetwork, TestLinearMdrnn) const double* inerror_p = net.back_activate(outerror_p); - ASSERT_DOUBLE_EQ(2, net.outerror()[0][0]) + ASSERT_DOUBLE_EQ(2, net.outerror()[0][0]) << "Networks' outerror not filled correctly."; ASSERT_DOUBLE_EQ(4, net.outerror()[0][1]) << "Networks' outerror not filled correctly."; @@ -1698,7 +1698,7 @@ TEST(TestNetwork, TestLinearMdrnn) ASSERT_DOUBLE_EQ(10, net.outerror()[0][3]) << "Networks' outerror not filled correctly."; - EXPECT_DOUBLE_EQ(40, net.inerror()[0][0]) + EXPECT_DOUBLE_EQ(40, net.inerror()[0][0]) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(24, net.inerror()[0][1]) << "Backward pass incorrect."; @@ -1706,8 +1706,8 @@ TEST(TestNetwork, TestLinearMdrnn) << "Backward pass incorrect."; EXPECT_DOUBLE_EQ(10, net.inerror()[0][3]) << "Backward pass incorrect."; - - EXPECT_DOUBLE_EQ(net.inerror()[0][0], inerror_p[0]) + + EXPECT_DOUBLE_EQ(net.inerror()[0][0], inerror_p[0]) << "back_activate copy not correct."; EXPECT_DOUBLE_EQ(net.inerror()[0][1], inerror_p[1]) << "back_activate copy not correct."; @@ -1756,9 +1756,9 @@ TEST(TestNetwork, NetworkClearConnection) LinearLayer* output = new LinearLayer(1); FullConnection* con = \ new FullConnection(input, output); - + double* input_p = new double[1]; - + net_p->add_module(input, Network::InputModule); net_p->add_module(output, Network::OutputModule); net_p->add_connection(con); @@ -1783,21 +1783,21 @@ TEST(TestConnections, TestPermutationConnection) perm.push_back(0); perm.push_back(4); perm.push_back(3); - + LinearLayer* inlayer_p = new LinearLayer(5); LinearLayer* outlayer_p = new LinearLayer(5); PermutationConnection* con_p = \ new PermutationConnection(inlayer_p, outlayer_p, perm); - + inlayer_p->input()[0][0] = 0; inlayer_p->input()[0][1] = 1; inlayer_p->input()[0][2] = 2; inlayer_p->input()[0][3] = 3; inlayer_p->input()[0][4] = 4; inlayer_p->forward(); - + con_p->forward(); - + EXPECT_EQ(outlayer_p->input()[0][0], 2); EXPECT_EQ(outlayer_p->input()[0][1], 1); EXPECT_EQ(outlayer_p->input()[0][2], 0); @@ -1815,7 +1815,7 @@ TEST(TestConnections, TestPermutationConnection) outlayer_p->backward(); con_p->backward(); - + inlayer_p->outerror()[0][0] = -2; inlayer_p->outerror()[0][1] = -1; inlayer_p->outerror()[0][2] = 0; @@ -1831,13 +1831,13 @@ TEST(TestConnections, TestPermutationConnectionInvert) perm.push_back(0); perm.push_back(1); perm.push_back(3); - + LinearLayer* layer_p = new LinearLayer(4); PermutationConnection* con_p = \ new PermutationConnection(layer_p, layer_p, perm); - + con_p->invert(); - + std::vector& invperm = con_p->permutation(); EXPECT_EQ(1, invperm[0]); EXPECT_EQ(2, invperm[1]); @@ -1851,7 +1851,7 @@ TEST(TestConnections, TestBlockPermutationConnection) std::vector sequence_shape; sequence_shape.push_back(4); sequence_shape.push_back(4); - + std::vector block_shape; block_shape.push_back(2); block_shape.push_back(2); @@ -1860,17 +1860,17 @@ TEST(TestConnections, TestBlockPermutationConnection) LinearLayer* outlayer_p = new LinearLayer(16); BlockPermutationConnection* con_p = new BlockPermutationConnection( inlayer_p, outlayer_p, sequence_shape, block_shape); - + Network net; net.add_module(inlayer_p, Network::InputModule); net.add_module(outlayer_p, Network::OutputModule); net.add_connection(con_p); - + double* input_p = new double[16]; - - for (int i = 0; i < 16; i++) + + for (int i = 0; i < 16; i++) { - input_p[i] = i; + input_p[i] = i; } net.activate(input_p); @@ -1878,7 +1878,7 @@ TEST(TestConnections, TestBlockPermutationConnection) double solution_p[16] = { 0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15 }; - + for (int i = 0; i < 16; i++) { EXPECT_DOUBLE_EQ(solution_p[i], net.output()[0][i]); @@ -1891,7 +1891,7 @@ TEST(TestConnections, TestBlockPermutationConnectionInversion) std::vector sequence_shape; sequence_shape.push_back(16); sequence_shape.push_back(16); - + std::vector block_shape; block_shape.push_back(4); block_shape.push_back(2); @@ -1911,17 +1911,17 @@ TEST(TestConnections, TestBlockPermutationConnectionInversion) net.add_module(outlayer_p, Network::OutputModule); net.add_connection(con1_p); net.add_connection(con2_p); - + double* input_p = new double[256]; - - for (int i = 0; i < 256; i++) + + for (int i = 0; i < 256; i++) { - input_p[i] = i; + input_p[i] = i; } net.activate(input_p); - + for (int i = 0; i < 16; i++) { EXPECT_DOUBLE_EQ(net.input()[0][i], net.output()[0][i]); @@ -1935,16 +1935,16 @@ TEST(TestConnections, TestConvolveConnection) LinearLayer* outlayer_p = new LinearLayer(15); ConvolveConnection* con_p = new \ ConvolveConnection(inlayer_p, outlayer_p, 1, 5); - + double* params_p = new double[5]; params_p[0] = 1; params_p[1] = 2; params_p[2] = 3; params_p[3] = 4; params_p[4] = 5; - + con_p->set_parameters(params_p); - + inlayer_p->input()[0][0] = 2; inlayer_p->input()[0][1] = 3; inlayer_p->input()[0][2] = 6; @@ -1952,17 +1952,17 @@ TEST(TestConnections, TestConvolveConnection) inlayer_p->forward(); con_p->forward(); outlayer_p->forward(); - - double solution_p[15] = {2., 4., 6., 8., 10., + + double solution_p[15] = {2., 4., 6., 8., 10., 3., 6., 9., 12., 15., 6., 12., 18., 24., 30.}; - + for (int i = 0; i < 15; i++) { EXPECT_EQ(solution_p[i], outlayer_p->input()[0][i]) << "Wrong input for outlayer at " << i; } - + outlayer_p->outerror()[0][0] = -1; outlayer_p->outerror()[0][1] = -2; outlayer_p->outerror()[0][2] = -3; @@ -1982,14 +1982,14 @@ TEST(TestConnections, TestConvolveConnection) outlayer_p->backward(); con_p->backward(); inlayer_p->backward(); - + double backsolution_p[3] = {-55, -130, -205}; for (int i = 0; i < 3; i++) { ASSERT_EQ(backsolution_p[i], inlayer_p->outerror()[0][i]) << "Wrong error for inlayer at " << i; } - + double derivsolution_p[5] = {-86., -97., -108., -119., -130.}; for (int i = 0; i < 5; i++) { @@ -2005,7 +2005,7 @@ TEST(TestConnections, TestInConvolveConnection) LinearLayer* outlayer_p = new LinearLayer(3); InConvolveConnection* con_p = new \ InConvolveConnection(inlayer_p, outlayer_p, 2); - + double* params_p = new double[6]; params_p[0] = 1; params_p[1] = 2; @@ -2013,9 +2013,9 @@ TEST(TestConnections, TestInConvolveConnection) params_p[3] = 4; params_p[4] = 5; params_p[5] = 6; - + con_p->set_parameters(params_p); - + inlayer_p->input()[0][0] = 0; inlayer_p->input()[0][1] = 1; inlayer_p->input()[0][2] = 2; @@ -2026,9 +2026,9 @@ TEST(TestConnections, TestInConvolveConnection) inlayer_p->forward(); con_p->forward(); outlayer_p->forward(); - + double solution_p[3] = {24., 54., 84.}; - + for (int i = 0; i < 3; i++) { EXPECT_EQ(solution_p[i], outlayer_p->input()[0][i]) @@ -2043,19 +2043,19 @@ TEST(TestConnections, TestOutConvolveConnection) LinearLayer* outlayer_p = new LinearLayer(4); OutConvolveConnection* con_p = new \ OutConvolveConnection(inlayer_p, outlayer_p, 2); - + double* params_p = new double[6]; params_p[0] = 1; params_p[1] = 2; - + con_p->set_parameters(params_p); - + inlayer_p->forward(); con_p->forward(); outlayer_p->forward(); - + double solution_p[4] = {1., 2., 1., 2.}; - + for (int i = 0; i < 3; i++) { EXPECT_EQ(solution_p[i], outlayer_p->input()[0][i]) @@ -2129,7 +2129,7 @@ TEST(TestGradient, LstmLayer) net_p->randomize(); // ASSERT_GT(0.001, gradient_check(*net_p)) - ASSERT_GT(-1, 0) + ASSERT_GT(-1, 0) << "Gradient check not yet implemented for sequential modules."; } @@ -2139,7 +2139,7 @@ TEST(TestGradient, Sliced) Network* net_p = new Network(); LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(4); - FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p, + FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p, 0, 1, 0, 2); net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); @@ -2154,16 +2154,16 @@ TEST(TestGradient, Sliced) TEST(TestGradient, TwoLayerNetwork) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); LinearLayer* outlayer_p = new LinearLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->get_parameters()[0] = 0.5; con_p->get_parameters()[1] = -2; con_p->get_parameters()[2] = 1.2; con_p->get_parameters()[3] = 4; - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); @@ -2175,13 +2175,13 @@ TEST(TestGradient, TwoLayerNetwork) TEST(TestGradient, SigmoidLayer) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); SigmoidLayer* outlayer_p = new SigmoidLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->randomize(); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); @@ -2193,13 +2193,13 @@ TEST(TestGradient, SigmoidLayer) TEST(TestGradient, CosineLayer) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); CosineLayer* outlayer_p = new CosineLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->randomize(); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); @@ -2211,13 +2211,13 @@ TEST(TestGradient, CosineLayer) TEST(TestGradient, TanhLayer) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); TanhLayer* outlayer_p = new TanhLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->randomize(); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); @@ -2229,13 +2229,13 @@ TEST(TestGradient, TanhLayer) TEST(TestGradient, DoubleGateLayer) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); DoubleGateLayer* outlayer_p = new DoubleGateLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->randomize(); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); @@ -2247,13 +2247,13 @@ TEST(TestGradient, DoubleGateLayer) TEST(TestGradient, SwitchLayer) { Network* net_p = new Network(); - + LinearLayer* inlayer_p = new LinearLayer(2); SwitchLayer* outlayer_p = new SwitchLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->randomize(); - + net_p->add_module(inlayer_p, Network::InputModule); net_p->add_module(outlayer_p, Network::OutputModule); net_p->add_connection(con_p); @@ -2266,13 +2266,13 @@ TEST(TestGradient, SwitchLayer) TEST(TestGradient, MultiplicationLayer) { Network net; - + LinearLayer* inlayer_p = new LinearLayer(2); MultiplicationLayer* outlayer_p = new MultiplicationLayer(2); FullConnection* con_p = new FullConnection(inlayer_p, outlayer_p); - + con_p->randomize(); - + net.add_module(inlayer_p, Network::InputModule); net.add_module(outlayer_p, Network::OutputModule); net.add_connection(con_p); @@ -2291,7 +2291,7 @@ TEST(TestGradient, TanhMdrnn) net.set_block_shape(1, 2); net.sort(); net.randomize(); - + EXPECT_GT(0.001, gradient_check(net)); } @@ -2310,7 +2310,7 @@ TEST(TestGradient, MdMdrnn) hiddenlayer1.set_block_shape(1, 2); hiddenlayer1.sort(); hiddenlayer1.randomize(); - + TanhMdrnn hiddenlayer2 = TanhMdrnn(2, hidden); hiddenlayer2.set_sequence_shape(0, 4); hiddenlayer2.set_sequence_shape(1, 4); @@ -2334,9 +2334,9 @@ TEST(TestGradient, MdMdrnn) outperm.push_back(i); } - IdentityConnection incon = + IdentityConnection incon = IdentityConnection(&inlayer, &hiddenlayer1); - IdentityConnection outcon = + IdentityConnection outcon = IdentityConnection(&hiddenlayer1, &intermediate1); PermutationConnection blockvamp = \ @@ -2344,9 +2344,9 @@ TEST(TestGradient, MdMdrnn) PermutationConnection blockrevamp = \ PermutationConnection(&hiddenlayer2, &intermediate2, outperm); - ConvolveConnection outcon1 = + ConvolveConnection outcon1 = ConvolveConnection(&intermediate1, &outlayer, hidden, 1); - ConvolveConnection outcon2 = + ConvolveConnection outcon2 = ConvolveConnection(&intermediate2, &outlayer, hidden, 1); Network net; @@ -2386,14 +2386,14 @@ TEST(TestGradient, MdlstmMdrnn) TEST(TestGradient, InConvolveConnection) { Network net; - + LinearLayer* inlayer_p = new LinearLayer(6); LinearLayer* outlayer_p = new LinearLayer(3); InConvolveConnection* con_p = new \ InConvolveConnection(inlayer_p, outlayer_p, 2); con_p->randomize(); - + net.add_module(inlayer_p, Network::InputModule); net.add_module(outlayer_p, Network::OutputModule); net.add_connection(con_p); @@ -2406,14 +2406,14 @@ TEST(TestGradient, InConvolveConnection) TEST(TestGradient, OutConvolveConnection) { Network net; - + LinearLayer* inlayer_p = new LinearLayer(3); LinearLayer* outlayer_p = new LinearLayer(6); OutConvolveConnection* con_p = new \ OutConvolveConnection(inlayer_p, outlayer_p, 2); con_p->randomize(); - + net.add_module(inlayer_p, Network::InputModule); net.add_module(outlayer_p, Network::OutputModule); net.add_connection(con_p); diff --git a/src/cpp/tests/test_utilities.cpp b/src/cpp/tests/test_utilities.cpp index 2609366..3bfecc9 100644 --- a/src/cpp/tests/test_utilities.cpp +++ b/src/cpp/tests/test_utilities.cpp @@ -10,7 +10,7 @@ using namespace arac::utilities; TEST(TestBlockPermutation, Test44_22) { std::vector perm, shape, blockshape; - + shape.push_back(4); shape.push_back(4); blockshape.push_back(2); @@ -19,9 +19,9 @@ TEST(TestBlockPermutation, Test44_22) { block_permutation(perm, shape, blockshape); ASSERT_EQ(16, perm.size()); - + int solution_p[16] = {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15}; - + for (int i = 0; i < 16; i++) { EXPECT_EQ(solution_p[i], perm[i]) @@ -32,7 +32,7 @@ TEST(TestBlockPermutation, Test44_22) { TEST(TestBlockPermutation, Test34_12) { std::vector perm, shape, blockshape; - + shape.push_back(3); shape.push_back(4); blockshape.push_back(1); @@ -42,7 +42,7 @@ TEST(TestBlockPermutation, Test34_12) { ASSERT_EQ(12, perm.size()); int solution_p[12] = {0, 3, 1, 4, 2, 5, 6, 9, 7, 10, 8, 11}; - + for (int i = 0; i < 12; i++) { EXPECT_EQ(solution_p[i], perm[i]) @@ -51,10 +51,10 @@ TEST(TestBlockPermutation, Test34_12) { } -TEST(TestBlockPermutation, Test442_221) +TEST(TestBlockPermutation, Test442_221) { std::vector perm, shape, blockshape; - + shape.push_back(4); shape.push_back(4); shape.push_back(2); @@ -66,7 +66,7 @@ TEST(TestBlockPermutation, Test442_221) ASSERT_EQ(32, perm.size()); int solution_p[32] = {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15, 16, 17, 20, 21, 18, 19, 22, 23, 24, 25, 28, 29, 26, 27, 30, 31}; - + for (int i = 0; i < 32; i++) { EXPECT_EQ(solution_p[i], perm[i]) @@ -77,7 +77,7 @@ TEST(TestBlockPermutation, Test442_221) TEST(TestBlockPermutation, Test442_222) { std::vector perm, shape, blockshape; - + shape.push_back(4); shape.push_back(4); shape.push_back(2); @@ -89,7 +89,7 @@ TEST(TestBlockPermutation, Test442_222) { ASSERT_EQ(32, perm.size()); int solution_p[32] = {0, 1, 4, 5, 16, 17, 20, 21, 2, 3, 6, 7, 18, 19, 22, 23, 8, 9, 12, 13, 24, 25, 28, 29, 10, 11, 14, 15, 26, 27, 30, 31}; - + for (int i = 0; i < 32; i++) { EXPECT_EQ(solution_p[i], perm[i]) @@ -99,5 +99,5 @@ TEST(TestBlockPermutation, Test442_222) { - + } // namespace \ No newline at end of file diff --git a/src/cpp/utilities/utilities.cpp b/src/cpp/utilities/utilities.cpp index 8496e36..a4563b8 100644 --- a/src/cpp/utilities/utilities.cpp +++ b/src/cpp/utilities/utilities.cpp @@ -14,10 +14,10 @@ using namespace arac::datasets; namespace arac { - + namespace utilities { - - + + void print_array(const double* array, int length) { @@ -26,8 +26,8 @@ print_array(const double* array, int length) std::cout << array[i] << " "; } } - - + + void print_parameters(arac::structure::networks::BaseNetwork& net) { @@ -49,7 +49,7 @@ print_derivatives(arac::structure::networks::BaseNetwork& net) param_p_iter != net.parametrizeds().end(); param_p_iter++) { - print_array((*param_p_iter)->get_derivatives(), + print_array((*param_p_iter)->get_derivatives(), (*param_p_iter)->size()); } } @@ -70,25 +70,25 @@ print_activations(BaseNetwork& net, SupervisedDataset& ds) { error_p[j] = target_p[j] - prediction_p[j]; } - + std::cout << "Input: "; print_array(input_p, ds.samplesize()); std::cout << std::endl << "Target: "; print_array(target_p, ds.targetsize()); - + std::cout << std::endl << "Prediction: "; print_array(prediction_p, net.outsize()); - + std::cout << std::endl << "Error: "; print_array(error_p, net.outsize()); - + std::cout << std::endl << std::endl; } } -void block_permutation(std::vector& perm, +void block_permutation(std::vector& perm, std::vector& sequence_shape, std::vector& block_shape) { @@ -99,7 +99,7 @@ void block_permutation(std::vector& perm, } int dim = sequence_shape.size(); - + // Make a vector that contains the multiplied sizes of previous dimensions. std::vector shape_dims; shape_dims.push_back(1); @@ -107,9 +107,9 @@ void block_permutation(std::vector& perm, { shape_dims.push_back(shape_dims[i] * sequence_shape[i]); } - + int& length = shape_dims.back(); - + std::vector< std::vector > coords; for(int i = dim - 1; i >= 0; i--) { @@ -127,16 +127,16 @@ void block_permutation(std::vector& perm, } coords.push_back(this_dims); } - + int n_blocks = 1; std::vector::iterator intiter, intiter_; - for (intiter = sequence_shape.begin(), intiter_ = block_shape.begin(); + for (intiter = sequence_shape.begin(), intiter_ = block_shape.begin(); intiter != sequence_shape.end(); intiter++, intiter_++) { n_blocks *= *intiter / *intiter_; } - + std::vector< std::vector > blocks; blocks.reserve(n_blocks); for (int i = 0; i < n_blocks; i++) @@ -144,14 +144,14 @@ void block_permutation(std::vector& perm, std::vector empty; blocks.push_back(empty); } - + std::vector block_dims; block_dims.push_back(1); for (int i = 0; i < dim; i++) { block_dims.push_back(block_dims[i] * block_shape[i]); } - + for(int i = 0; i < length; i++) { int block_index = 0; @@ -162,7 +162,7 @@ void block_permutation(std::vector& perm, } blocks[block_index].push_back(i); } - + std::vector< std::vector >::iterator intveciter; for (intveciter = blocks.begin(); intveciter != blocks.end(); @@ -175,7 +175,7 @@ void block_permutation(std::vector& perm, perm.push_back(*intiter); } } -} +} // TODO: use better rng, like mt from tr1 or sth. static int count = 0; @@ -194,7 +194,7 @@ void fill_random(double* sink_p, int length, double interval) void -addscale(const double* first_p, const double* second_p, double* sink_p, +addscale(const double* first_p, const double* second_p, double* sink_p, size_t length, double scale) { for (int i = 0; i < length; i++) @@ -204,7 +204,7 @@ addscale(const double* first_p, const double* second_p, double* sink_p, } -void +void square(double* target_p, size_t length) { for (int i = 0; i < length; i++) @@ -230,7 +230,7 @@ void parametrized_by_network(std::vector& params, BaseNetwork& net) { std::vector::iterator net_iter; - + for (net_iter = net.networks().begin(); net_iter != net.networks().end(); net_iter++) @@ -253,7 +253,7 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) { int insize = network.insize(); int outsize = network.outsize(); - + // Build up an appropriate input. double* input_p = new double[insize]; double* target_p = new double[outsize]; @@ -261,7 +261,7 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) double* error_p = new double[outsize]; fill_random(input_p, insize, 2.5); fill_random(target_p, outsize, 2.5); - + double epsilon = 1e-5; double biggest = 0.0; @@ -269,14 +269,14 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) double param_deriv; // The derivative as computed numerically. double numeric_deriv; - - // Hold pointers to all Parametrized objects here to check them + + // Hold pointers to all Parametrized objects here to check them // sequentially. std::vector params; parametrized_by_network(params, network); std::vector::iterator param_iter; - // Now iterate over all parametrized objects in order to play with every + // Now iterate over all parametrized objects in order to play with every // parameter to check derivative correctness. for (param_iter = params.begin(); param_iter != params.end(); @@ -295,17 +295,17 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) network.clear(); network.clear_derivatives(); result_p = network.activate(input_p); - + addscale(target_p, result_p, error_p, outsize, -1); - + network.back_activate(error_p); param_deriv = parametrized.get_derivatives()[i]; - + network.clear(); // Calculate point to the right of the target. param = old_param + epsilon; - + result_p = network.activate(input_p); addscale(target_p, result_p, error_p, outsize, -1); square(error_p, outsize); @@ -313,7 +313,7 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) double righterror = 0.5 * sum(error_p, outsize); network.clear(); - + // Calculate point to the left of the target. param = old_param - epsilon; @@ -326,8 +326,8 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) numeric_deriv = (righterror - lefterror) / (epsilon * -2); if (verbose) { - std::cout << "Numeric/Analytical:" << numeric_deriv - << " <-> " + std::cout << "Numeric/Analytical:" << numeric_deriv + << " <-> " << param_deriv << std::endl; } @@ -340,7 +340,7 @@ gradient_check_nonsequential(BaseNetwork& network, bool verbose) param = old_param; } } - + return biggest; } diff --git a/src/cpp/utilities/utilities.h b/src/cpp/utilities/utilities.h index 5dcab5d..282899b 100644 --- a/src/cpp/utilities/utilities.h +++ b/src/cpp/utilities/utilities.h @@ -32,7 +32,7 @@ void block_permutation(std::vector& perm, /// -/// Fill the sink with random values from the interval [-interval, interval]. +/// Fill the sink with random values from the interval [-interval, interval]. /// interval defaults to 0.01. /// void fill_random(double* sink_p, int length, double interval = 0.01); @@ -52,7 +52,7 @@ gradient_check(arac::structure::networks::BaseNetwork& network, /// Parametrized objects to the end of a vector. /// void -parametrized_by_network(std::vector& params, +parametrized_by_network(std::vector& params, arac::structure::networks::BaseNetwork& net); diff --git a/src/swig/cppbridge.i b/src/swig/cppbridge.i index 2e7a569..4cfe37a 100644 --- a/src/swig/cppbridge.i +++ b/src/swig/cppbridge.i @@ -1,7 +1,7 @@ %module cppbridge %{ #define SWIG_FILE_WITH_INIT - + #include #include #include @@ -39,7 +39,7 @@ PyObject* PyArray_1DFromDoublePointer(int dim, double* data_p) int* dims = new int[1]; dims[0] = dim; // TODO: use python function that does not trigger a warning here. - PyObject* res_p = PyArray_FromDimsAndData(1, dims, PyArray_DOUBLE, + PyObject* res_p = PyArray_FromDimsAndData(1, dims, PyArray_DOUBLE, (char*) data_p); delete[] dims; return res_p; @@ -52,10 +52,10 @@ PyObject* PyArray_2DFromDoublePointer(int dim1, int dim2, double* data_p) dims[0] = dim1; dims[1] = dim2; // TODO: use python function that does not trigger a warning here. - PyObject* res_p = PyArray_FromDimsAndData(2, dims, PyArray_DOUBLE, + PyObject* res_p = PyArray_FromDimsAndData(2, dims, PyArray_DOUBLE, (char*) data_p); delete[] dims; - return res_p; + return res_p; } @@ -78,13 +78,13 @@ namespace std %} -%apply (double* INPLACE_ARRAY1, int DIM1) {(double* input_p, int inlength), +%apply (double* INPLACE_ARRAY1, int DIM1) {(double* input_p, int inlength), (double* output_p, int outlength)}; -%apply (double* INPLACE_ARRAY1, int DIM1) {(double* outerror_p, int outlength), +%apply (double* INPLACE_ARRAY1, int DIM1) {(double* outerror_p, int outlength), (double* inerror_p, int inlength)}; -%apply (double* INPLACE_ARRAY1, int DIM1) {(double* parameters_p, int parameter_size), +%apply (double* INPLACE_ARRAY1, int DIM1) {(double* parameters_p, int parameter_size), (double* derivatives_p, int derivative_size)}; -%apply (double* INPLACE_ARRAY1, int DIM1) {(double* outerror_p, int outlength), +%apply (double* INPLACE_ARRAY1, int DIM1) {(double* outerror_p, int outlength), (double* inerror_p, int inlength)}; %apply (double* INPLACE_ARRAY2, int DIM1, int DIM2) { (double* content_p, int length, int rowsize)}; @@ -98,7 +98,7 @@ class Buffer }; -%extend Buffer +%extend Buffer { void append(double* row_p, int this_size) { @@ -112,15 +112,15 @@ class Buffer }; -class Component +class Component { - public: - enum Mode + public: + enum Mode { Simple = 0, ErrorAgnostic = 1, Sequential = 2, - + SequentialErrorAgnostic = 3, }; virtual Component(); @@ -163,7 +163,7 @@ class Module : public Component }; -%extend Module +%extend Module { void init_input(double* content_p, int length, int rowsize) { @@ -174,7 +174,7 @@ class Module : public Component { init_buffer($self->output(), content_p, length, rowsize); } - + void init_inerror(double* content_p, int length, int rowsize) { init_buffer($self->inerror(), content_p, length, rowsize); @@ -190,9 +190,9 @@ class Module : public Component %apply (double* INPLACE_ARRAY1, int DIM1) {(double* parameters_p, int n_parameters)}; %apply (double* INPLACE_ARRAY1, int DIM1) {(double* derivatives_p, int n_derivatives)}; -class Parametrized +class Parametrized { - public: + public: Parametrized(); Parametrized(int size); int size(); @@ -207,7 +207,7 @@ class Parametrized { return PyArray_1DFromDoublePointer($self->size(), $self->get_parameters()); } - + void set_parameters(double* parameters_p, int n_parameters) { if (n_parameters != $self->size()) @@ -218,12 +218,12 @@ class Parametrized } $self->set_parameters(parameters_p); } - + PyObject* get_derivatives() { return PyArray_1DFromDoublePointer($self->size(), $self->get_derivatives()); } - + void set_derivatives(double* derivatives_p, int n_derivatives) { if (n_derivatives != $self->size()) @@ -239,38 +239,38 @@ class Parametrized class Connection : public Component { - public: + public: Connection(Module* incoming, Module* outgoing, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); Connection(Module* incoming, Module* outgoing); virtual ~Connection(); - + void set_incomingstart(int n); void set_incomingstop(int n); void set_outgoingstart(int n); void set_outgoingstop(int n); - + int get_incomingstart(); int get_incomingstop(); int get_outgoingstart(); int get_outgoingstop(); - + void set_recurrent(int recurrent); int get_recurrent(); - + Module* incoming(); Module* outgoing(); }; %feature("notabstract") IdentityConnection; -class IdentityConnection : public Connection +class IdentityConnection : public Connection { public: IdentityConnection(Module* incoming_p, Module* outgoing_p); IdentityConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); virtual ~IdentityConnection(); }; @@ -377,32 +377,32 @@ class MdlstmLayer : public Module { init_buffer($self->input_squashed(), content_p, length, rowsize); } - + void init_input_gate_squashed(double* content_p, int length, int rowsize) { init_buffer($self->input_gate_squashed(), content_p, length, rowsize); } - + void init_input_gate_unsquashed(double* content_p, int length, int rowsize) { init_buffer($self->input_gate_unsquashed(), content_p, length, rowsize); } - + void init_output_gate_squashed(double* content_p, int length, int rowsize) { init_buffer($self->output_gate_squashed(), content_p, length, rowsize); } - + void init_output_gate_unsquashed(double* content_p, int length, int rowsize) { init_buffer($self->output_gate_unsquashed(), content_p, length, rowsize); } - + void init_forget_gate_unsquashed(double* content_p, int length, int rowsize) { init_buffer($self->forget_gate_unsquashed(), content_p, length, rowsize); } - + void init_forget_gate_squashed(double* content_p, int length, int rowsize) { init_buffer($self->forget_gate_squashed(), content_p, length, rowsize); @@ -455,19 +455,19 @@ class TanhLayer : public Module class BaseNetwork : public Module { - + public: BaseNetwork(); virtual ~BaseNetwork(); - + virtual void activate(double* input_p, double* output_p); virtual void back_activate(double* outerror_p, double* inerror_p); virtual void forward(); - + std::vector& parametrizeds(); - + std::vector& networks(); - + virtual void sort() = 0; virtual void randomize(); }; @@ -477,19 +477,19 @@ class BaseNetwork : public Module { // TODO: do not make the API request a output array, but return a PyObject* // instead. - - virtual void activate(double* input_p, int inlength, + + virtual void activate(double* input_p, int inlength, double* output_p, int outlength) { // TODO: check bounds of in and output // if (inlength != $self->insize()) { - // PyErr_Format(PyExc_ValueError, + // PyErr_Format(PyExc_ValueError, // "Input has wrong size: %d instead of %d", // inlength, $self->insize()); // return; // } // if (outlength != $self->outsize()) { - // PyErr_Format(PyExc_ValueError, + // PyErr_Format(PyExc_ValueError, // "Output has wrong size: %d instead of %d", // outlength, $self->outsize()); // return; @@ -498,7 +498,7 @@ class BaseNetwork : public Module $self->activate(input_p, output_p); } - virtual void back_activate(double* outerror_p, int outlength, + virtual void back_activate(double* outerror_p, int outlength, double* inerror_p, int inlength) { if (inlength != $self->insize() or outlength != $self->outsize()) { @@ -514,120 +514,120 @@ class BaseNetwork : public Module %feature("notabstract") FullConnection; class FullConnection : public Connection, public Parametrized { - public: - + public: + FullConnection(Module* incoming_p, Module* outgoing_p); FullConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); FullConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); virtual ~FullConnection(); - - %extend + + %extend { FullConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, int parameter_size, double* derivatives_p, int derivative_size, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) - + { int required_size = \ (incomingstop - incomingstart) * (outgoingstop - outgoingstart); if (parameter_size != required_size) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Parameters have wrong size: should be %d instead of %d.", required_size, parameter_size); return 0; } if (derivative_size != required_size) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Derivatives have wrong size: should be %d instead of %d.", required_size, parameter_size); return 0; } - - FullConnection* con = new FullConnection(incoming_p, outgoing_p, + + FullConnection* con = new FullConnection(incoming_p, outgoing_p, parameters_p, derivatives_p, incomingstart, incomingstop, outgoingstart, outgoingstop); return con; } } -}; +}; %feature("notabstract") LinearConnection; class LinearConnection : public Connection, public Parametrized { - public: - + public: + LinearConnection(Module* incoming_p, Module* outgoing_p); LinearConnection(Module* incoming_p, Module* outgoing_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); LinearConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, double* derivatives_p, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop); virtual ~LinearConnection(); - + %extend { LinearConnection(Module* incoming_p, Module* outgoing_p, double* parameters_p, int parameter_size, double* derivatives_p, int derivative_size, - int incomingstart, int incomingstop, + int incomingstart, int incomingstop, int outgoingstart, int outgoingstop) { int required_size = incomingstop - incomingstart; if (outgoingstop - outgoingstart != required_size) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Slice sizes are not equal. (%d, %d).", required_size, outgoingstop - outgoingstart); return 0; } if (parameter_size != required_size) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Parameters have wrong size: should be %d instead of %d.", required_size, parameter_size); return 0; } if (derivative_size != incomingstop - incomingstart) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Derivatives have wrong size: should be %d instead of %d.", required_size, parameter_size); return 0; } - + LinearConnection* con = new LinearConnection( - incoming_p, outgoing_p, + incoming_p, outgoing_p, parameters_p, derivatives_p, incomingstart, incomingstop, outgoingstart, outgoingstop); return con; } } -}; +}; %feature("notabstract") BlockPermutationConnection; class BlockPermutationConnection : public Connection { public: - BlockPermutationConnection(Module* incoming_p, Module* outgoing_p, + BlockPermutationConnection(Module* incoming_p, Module* outgoing_p, std::vector sequence_shape, std::vector block_shape); virtual ~BlockPermutationConnection(); - + std::vector& permutation(); void invert(); }; @@ -637,10 +637,10 @@ class BlockPermutationConnection : public Connection class PermutationConnection : public Connection { public: - PermutationConnection(Module* incoming_p, Module* outgoing_p, + PermutationConnection(Module* incoming_p, Module* outgoing_p, std::vector permutation); virtual ~PermutationConnection(); - + std::vector& permutation(); void invert(); }; @@ -650,7 +650,7 @@ class PermutationConnection : public Connection class ConvolveConnection : public Connection, public Parametrized { public: - ConvolveConnection(Module* incoming_p, Module* outgoing_p, + ConvolveConnection(Module* incoming_p, Module* outgoing_p, int inchunk, int outchunk); ~ConvolveConnection(); }; @@ -676,8 +676,8 @@ class OutConvolveConnection : public Connection, public Parametrized %feature("notabstract") Network; class Network : public BaseNetwork { - public: - + public: + enum ModuleType { Simple = 0, InputModule = 1, @@ -692,9 +692,9 @@ class Network : public BaseNetwork void add_connection(Connection* con_p); virtual void sort(); -}; - - +}; + + class BaseMdrnn : public BaseNetwork {}; @@ -704,11 +704,11 @@ class SigmoidMdrnn : public BaseMdrnn public: SigmoidMdrnn(int timedim, int hiddensize); ~SigmoidMdrnn(); - + // TODO: remove this; sorting should be implicit, but does not work for // mdrnns somehow. virtual void sort(); - + void set_sequence_shape(int dim, int val); int get_sequence_shape(int dim); int sequencelength(); @@ -723,11 +723,11 @@ class TanhMdrnn : public BaseMdrnn public: TanhMdrnn(int timedim, int hiddensize); ~TanhMdrnn(); - + // TODO: remove this; sorting should be implicit, but does not work for // mdrnns somehow. virtual void sort(); - + void set_sequence_shape(int dim, int val); int get_sequence_shape(int dim); int sequencelength(); @@ -742,11 +742,11 @@ class LinearMdrnn : public BaseMdrnn public: LinearMdrnn(int timedim, int hiddensize); ~LinearMdrnn(); - + // TODO: remove this; sorting should be implicit, but does not work for // mdrnns somehow. virtual void sort(); - + void set_sequence_shape(int dim, int val); int get_sequence_shape(int dim); int sequencelength(); @@ -761,11 +761,11 @@ class MdlstmMdrnn : public BaseMdrnn public: MdlstmMdrnn(int timedim, int hiddensize); ~MdlstmMdrnn(); - + // TODO: remove this; sorting should be implicit, but does not work for // mdrnns somehow. virtual void sort(); - + void set_sequence_shape(int dim, int val); int get_sequence_shape(int dim); int sequencelength(); @@ -773,8 +773,8 @@ class MdlstmMdrnn : public BaseMdrnn int get_block_shape(int dim); }; - -%apply (double* INPLACE_ARRAY1, int DIM1) {(double* sample_p, int samplelength), + +%apply (double* INPLACE_ARRAY1, int DIM1) {(double* sample_p, int samplelength), (double* target_p, int targetlength)}; %apply (double* INPLACE_ARRAY1, int DIM1) {(double* importance_p, int importancelength)}; @@ -784,7 +784,7 @@ class SupervisedSimpleDataset public: SupervisedSimpleDataset(int samplesize, int targetsize); ~SupervisedSimpleDataset(); - + virtual int size(); int samplesize(); int targetsize(); @@ -796,7 +796,7 @@ class SupervisedSimpleDataset %extend SupervisedSimpleDataset { - void append(double* sample_p, int samplelength, + void append(double* sample_p, int samplelength, double* target_p, int targetlength) { if (samplelength != $self->samplesize() or \ @@ -810,7 +810,7 @@ class SupervisedSimpleDataset void set_importance(int index, double* importance_p, int importancelength) { - if (importancelength != $self->targetsize()) + if (importancelength != $self->targetsize()) { PyErr_Format(PyExc_ValueError, "Arrays of lengths %d given", importancelength); @@ -818,19 +818,19 @@ class SupervisedSimpleDataset } $self->set_importance(index, importance_p); } - + PyObject* sample(int index) { SupervisedSimpleDataset& ds = *($self); - return PyArray_1DFromDoublePointer($self->samplesize(), ds[index].first); + return PyArray_1DFromDoublePointer($self->samplesize(), ds[index].first); } - + PyObject* target(int index) { SupervisedSimpleDataset& ds = *($self); return PyArray_1DFromDoublePointer($self->targetsize(), ds[index].second); } - + PyObject* importance(int index) { SupervisedSimpleDataset& ds = *($self); @@ -850,7 +850,7 @@ class SupervisedSemiSequentialDataset public: SupervisedSemiSequentialDataset(int samplesize, int targetsize); ~SupervisedSemiSequentialDataset(); - + virtual int size(); int samplesize(); int targetsize(); @@ -859,7 +859,7 @@ class SupervisedSemiSequentialDataset %extend SupervisedSemiSequentialDataset { - void append(double* sequence_p, int samplelength, int sequencelength, + void append(double* sequence_p, int samplelength, int sequencelength, double* target_p, int targetlength) { if (samplelength != $self->samplesize() or \ @@ -871,14 +871,14 @@ class SupervisedSemiSequentialDataset Sequence seq(sequencelength, samplelength, sequence_p); $self->append(seq, target_p); } - + PyObject* sample(int index) { SupervisedSemiSequentialDataset& ds = *($self); Sequence& seq = ds[index].first; return PyArray_2DFromDoublePointer(seq.itemsize(), seq.length(), seq[0]); } - + PyObject* target(int index) { SupervisedSemiSequentialDataset& ds = *($self); @@ -888,7 +888,7 @@ class SupervisedSemiSequentialDataset %apply (double* INPLACE_ARRAY2, int DIM1, int DIM2) { - (double* samplesequence_p, int samplelength, int samplesequencelength), + (double* samplesequence_p, int samplelength, int samplesequencelength), (double* targetsequence_p, int targetlength, int targetsequencelength) }; @@ -898,7 +898,7 @@ class SupervisedSequentialDataset public: SupervisedSequentialDataset(int samplesize, int targetsize); ~SupervisedSequentialDataset(); - + virtual int size(); int samplesize(); int targetsize(); @@ -907,7 +907,7 @@ class SupervisedSequentialDataset %extend SupervisedSequentialDataset { - void append(double* samplesequence_p, int samplelength, int samplesequencelength, + void append(double* samplesequence_p, int samplelength, int samplesequencelength, double* targetsequence_p, int targetlength, int targetsequencelength) { if (samplelength != $self->samplesize() or targetlength != $self->targetsize()) { @@ -916,16 +916,16 @@ class SupervisedSequentialDataset return; } if (samplesequencelength != targetsequencelength) { - PyErr_Format(PyExc_ValueError, + PyErr_Format(PyExc_ValueError, "Sequences have to be of same length."); return; } - + Sequence sampleseq(samplesequencelength, samplelength, samplesequence_p); Sequence targetseq(targetsequencelength, targetlength, targetsequence_p); $self->append(sampleseq, targetseq); } - + PyObject* sample(int index) { SupervisedSequentialDataset& ds = *($self); @@ -948,18 +948,18 @@ class SimpleBackprop public: SimpleBackprop(BaseNetwork& network, SupervisedSimpleDataset& ds); virtual ~SimpleBackprop(); - - void train_stochastic(); - void train_stochastic_batch(); + + void train_stochastic(); + void train_stochastic_batch(); double loss(); - + double learningrate(); void set_learningrate(const double value); - + double momentum(); void set_momentum(const double value); - + BaseNetwork& network(); SupervisedSimpleDataset& dataset(); }; @@ -967,9 +967,9 @@ class SimpleBackprop %extend SimpleBackprop { - PyObject* error() + PyObject* error() { - return PyArray_1DFromDoublePointer($self->network().outsize(), + return PyArray_1DFromDoublePointer($self->network().outsize(), $self->error()); } } @@ -979,18 +979,18 @@ class SemiSequentialBackprop { public: - SemiSequentialBackprop(BaseNetwork& network, + SemiSequentialBackprop(BaseNetwork& network, SupervisedSemiSequentialDataset& ds); ~SemiSequentialBackprop(); - - void train_stochastic(); - + + void train_stochastic(); + double learningrate(); void set_learningrate(const double value); - + double momentum(); void set_momentum(const double value); - + BaseNetwork& network(); SupervisedSemiSequentialDataset& dataset(); }; @@ -998,9 +998,9 @@ class SemiSequentialBackprop %extend SemiSequentialBackprop { - PyObject* lasterror() + PyObject* lasterror() { - return PyArray_1DFromDoublePointer($self->dataset().targetsize(), + return PyArray_1DFromDoublePointer($self->dataset().targetsize(), $self->error()); } } @@ -1011,15 +1011,15 @@ class SequentialBackprop public: SequentialBackprop(BaseNetwork& network, SupervisedSequentialDataset& ds); ~SequentialBackprop(); - + void train_stochastic(); - + double learningrate(); void set_learningrate(const double value); - + double momentum(); void set_momentum(const double value); - + BaseNetwork& network(); SupervisedSequentialDataset& dataset(); };