Skip to content

Commit

Permalink
add two programs for SGD and GA neural networks
Browse files Browse the repository at this point in the history
fixes #1
  • Loading branch information
azimonti committed Sep 12, 2024
1 parent affa72c commit f12ee51
Show file tree
Hide file tree
Showing 14 changed files with 1,254 additions and 0 deletions.
196 changes: 196 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
---
Language: Cpp
# BasedOnStyle: LLVM
# Start Customization
#
AlignArrayOfStructures: Right
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignConsecutiveAssignments: AcrossEmptyLinesAndComments
AlignConsecutiveBitFields: Consecutive
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
BreakBeforeBraces: Custom
ColumnLimit: 120
IndentWidth: 4
NamespaceIndentation: All
PointerAlignment: Left
ReferenceAlignment: Pointer
QualifierAlignment: Left
SeparateDefinitionBlocks: Always
SortIncludes: CaseInsensitive
Standard: c++17
# End Customization
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortLambdasOnASingleLine: All
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: true
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: false
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Merge
IncludeCategories:
- Regex: '<[[:alnum:]_]+>'
Priority: -1
CaseSensitive: false
- Regex: '<[[:alnum:]._/]+>'
Priority: 1
CaseSensitive: false
- Regex: '<[[:alnum:]._]+>'
Priority: 2
CaseSensitive: false
- Regex: '\/'
Priority: 3
CaseSensitive: false
- Regex: '.*'
Priority: 4
CaseSensitive: false
IncludeIsMainRegex: '"$"'
IncludeIsMainSourceRegex: '"$"'
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: OuterScope
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PPIndentWidth: -1
ReflowComments: true
RemoveBracesLLVM: false
ShortNamespaceLines: 1
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build/
data/MNIST/
*.eps
*.hd5
*.obj
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "externals/ma_libs"]
path = externals/ma_libs
url = https://github.com/azimonti/ma_libs.git
106 changes: 106 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
cmake_minimum_required(VERSION 3.13.4)
project(nnetworks_example)
set (PROJECT_VERSION "1.0" )
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION})

# location of the ma_libs
set(MA_LIBS_ROOT "${CMAKE_SOURCE_DIR}/externals/ma_libs")
set(MA_LIBS_CPP_ROOT "${MA_LIBS_ROOT}/cpp")


list(APPEND CMAKE_MODULE_PATH "${MA_LIBS_ROOT}/cmake_modules")
include( COMPILERCOMMON )
include( COMPILERCPP )
include( FindLIBS )
set(CMAKE_CXX_STANDARD 17 )
add_definitions( -DLOGGING -DCOUTEXT )

if(MSVC)
generic_libs_find(hdf5 ON )
generic_libs_find(zlib ON )
include_directories( ${HDF5_INCLUDE_DIRS}/src )
include_directories( ${HDF5_INCLUDE_DIRS2} )
link_directories( ${ZLIB_LIBRARY_PATH} )
else()
generic_libs_find(hdf5 OFF )
add_compile_options(-Wall -Wextra -pedantic -Wconversion -Wno-float-conversion)
endif()

include_directories( ${MATPLOT_INCLUDE_DIRS} )
include_directories( ${HDF5_INCLUDE_DIRS} )
include_directories( ${MA_LIBS_CPP_ROOT} )
include_directories( ${MA_LIBS_CPP_ROOT}/math )
include_directories( ${MA_LIBS_CPP_ROOT}/libnn/src )
include_directories( ${MA_LIBS_CPP_ROOT}/utils )

add_definitions( -DLOGGING )

set ( SRCS
./src/mnist.cpp
${MA_LIBS_CPP_ROOT}/utils/log/log.cpp
)

add_library( objnnetworks OBJECT ${SRCS} )
set_property( TARGET objnnetworks PROPERTY POSITION_INDEPENDENT_CODE 1 )
if(UNITYBUILD)
set_property( TARGET objnnetworks PROPERTY UNITY_BUILD ON )
endif()

project(network1_bin)
set ( SRCS ./src/main1.cpp )

link_directories( ${LIBS_DIR} )
link_directories( ${HDF5_LIBRARY_PATH} )
add_executable( ${PROJECT_NAME} ${SRCS} $<TARGET_OBJECTS:objnnetworks> )
if(UNITYBUILD)
set_property( TARGET ${PROJECT_NAME} PROPERTY UNITY_BUILD ON )
endif()
if(MSVC)
target_link_libraries( ${PROJECT_NAME}
debug libhdf5_D zlibstaticd
optimized libhdf5 zlibstatic )
else()
target_link_libraries( ${PROJECT_NAME}
debug hdf5
optimized hdf5 )
endif()

link_directories( ${MA_LIBS_ROOT}/build/${CMAKE_BUILD_TYPE} )

project(network2_bin)
set ( SRCS ./src/main2.cpp )

link_directories( ${LIBS_DIR} )
link_directories( ${HDF5_LIBRARY_PATH} )
add_executable( ${PROJECT_NAME} ${SRCS} $<TARGET_OBJECTS:objnnetworks> )
if(UNITYBUILD)
set_property( TARGET ${PROJECT_NAME} PROPERTY UNITY_BUILD ON )
endif()
if(MSVC)
target_link_libraries( ${PROJECT_NAME}
debug libhdf5_D debug zlibstaticd debug nnd
optimized libhdf5 optimized zlibstatic nn )
else()
target_link_libraries( ${PROJECT_NAME}
debug hdf5 debug nnd
optimized hdf5 optimized nn)
endif()

project(network3_bin)
set ( SRCS ./src/main3.cpp )

link_directories( ${LIBS_DIR} )
link_directories( ${HDF5_LIBRARY_PATH} )
add_executable( ${PROJECT_NAME} ${SRCS} $<TARGET_OBJECTS:objnnetworks> )
if(UNITYBUILD)
set_property( TARGET ${PROJECT_NAME} PROPERTY UNITY_BUILD ON )
endif()
if(MSVC)
target_link_libraries( ${PROJECT_NAME}
debug libhdf5_D debug zlibstaticd debug nnd
optimized libhdf5 optimized zlibstatic optimized nn)
else()
target_link_libraries( ${PROJECT_NAME}
debug hdf5 debug nnd
optimized hdf5 optimized nn)
endif()
Loading

0 comments on commit f12ee51

Please sign in to comment.