From df120eef00644c8e33a35bec0785418bd190b6d4 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 9 Jul 2019 09:28:23 +0200 Subject: [PATCH 01/38] Add 2Dos in Readme and comments in peaks/peaks.cfg --- Readme.md | 21 + examples/peaks/peaks.cfg | 8 +- tags | 1168 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1196 insertions(+), 1 deletion(-) create mode 100644 tags diff --git a/Readme.md b/Readme.md index 58c4b2b..47f5a2e 100644 --- a/Readme.md +++ b/Readme.md @@ -17,3 +17,24 @@ Run the test cases by callying './main' with the corresponding configuration fil ## Output An optimization history file 'optim.dat' will be flushed to the examples subfolder. +## Roland / Stef combo - LEARNING/TODO: + +### Overview: + +* Xbraid => 3 braid apps know one net +* One NN +* Braid has to be initialized first -> Decides about layers per core +* Tangling with NN is given due to reason above + - create nn + - give nn to braid + - init nn + +## 2Dos 😊 + +* Clean up syntax (google std) +* Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles +* Extract methods and clean up objects +* Comment everything + + + diff --git a/examples/peaks/peaks.cfg b/examples/peaks/peaks.cfg index fb0af31..3599df6 100644 --- a/examples/peaks/peaks.cfg +++ b/examples/peaks/peaks.cfg @@ -35,7 +35,7 @@ nchannels = 8 # number of layers (including opening layer and classification layer) (nlayer >= 3 !) nlayers = 32 # final time -T = 5.0 +T = 1.0 # Activation function ("tanh" or "ReLu" or "SmoothReLu") activation = SmoothReLu # Type of network ("dense" the default, or "convolutional") @@ -88,6 +88,12 @@ braid_nrelax0 = 0 # Optimization #################################### # Type of batch selection ("deterministic" or "stochastic") +# deterministic: +# fixes batch size => trains on this one +# +# stochastic: uses some (dead) pool +# batch elements are randomly chosen in each iteration during training +# smaller batch size makes sense batch_type = deterministic # Batch size nbatch = 5000 diff --git a/tags b/tags new file mode 100644 index 0000000..1dc9776 --- /dev/null +++ b/tags @@ -0,0 +1,1168 @@ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ +!_TAG_PROGRAM_NAME Exuberant Ctags // +!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ +!_TAG_PROGRAM_VERSION 5.9~svn20110310 // +-interaction xbraid/docs/Makefile /^ if test -d developer_manual; then cd developer_manual; sed 's\/pdflatex\/pdflatex --interaction=nonstopmode\/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi$/;" m +-interaction xbraid/docs/Makefile /^ if test -d user_manual; then cd user_manual; sed 's\/pdflatex\/pdflatex --interaction=nonstopmode\/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi$/;" m +.*|^ xbraid/test/adjoint.sh /^lines_to_check="^ time steps.*|^ number of levels.*|^ iterations.*|^ residual norm.*|^ state residual.*|^ adjoint residual.*|^ Objective function.*|^ Gradient norm.*|^ optimization iterations.*|^Finished braid_TestAll: no fails detected, however some results must be|.*Braid: Temporal refinement occurred.*|^255.*|^ 3 .*"$/;" f +../img/logo_with_subtext.pdf xbraid/docs/developer_manual_header.tex /^ \\includegraphics[width=0.7\\textwidth]{..\/img\/logo_with_subtext.pdf}$/;" g +../img/logo_with_subtext.pdf xbraid/docs/user_manual_header.tex /^ \\includegraphics[width=0.7\\textwidth]{..\/img\/logo_with_subtext.pdf}$/;" g +A include/hessianApprox.hpp /^ MyReal* A;$/;" m class:BFGS +A xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrix & A;$/;" m class:DenseMatrixTimeDependentOperator +A xbraid/drivers/mfem_arnoldi.hpp /^ Operator *A;$/;" m class:Arnoldi +ACCESS xbraid/braid/_braid_tape.h /^ ACCESS = 8,$/;" e enum:_braid_Call_enum +ACCESSOR_HEADER_GET1 xbraid/braid/braid_status.h 45;" d +ACCESSOR_HEADER_GET2 xbraid/braid/braid_status.h 47;" d +ACCESSOR_HEADER_GET4 xbraid/braid/braid_status.h 49;" d +ACCESSOR_HEADER_GET5 xbraid/braid/braid_status.h 51;" d +ACCESSOR_HEADER_SET1 xbraid/braid/braid_status.h 53;" d +ALL_EXAMPLES xbraid/drivers/Makefile /^ALL_EXAMPLES := $(patsubst %.c,%,$(ALL_EXAMPLES))$/;" m +ALL_EXAMPLES xbraid/drivers/Makefile /^ALL_EXAMPLES := $(patsubst %.cpp,%,$(wildcard *.c *.cpp))$/;" m +Access xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Access(braid_Vector u_,$/;" f class:MFEMBraidApp +Access xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Access(braid_Vector u_, BraidAccessStatus &astatus)$/;" f class:MFEMBraidApp +AddMeshOptions xbraid/drivers/braid_mfem.hpp /^void BraidOptions::AddMeshOptions()$/;" f class:BraidOptions +AddMeshOptions xbraid/drivers/braid_mfem_block.hpp /^void BraidOptions::AddMeshOptions()$/;" f class:BraidOptions +AllocLevels xbraid/drivers/braid_mfem.hpp /^ virtual void AllocLevels(int num_levels) { }$/;" f class:MFEMBraidApp +AllocLevels xbraid/drivers/braid_mfem_block.hpp /^ virtual void AllocLevels(int num_space_levels) { }$/;" f class:MFEMBraidApp +ApplyV xbraid/drivers/mfem_arnoldi.hpp /^ void ApplyV(const Vector & ubar, Vector & u)$/;" f class:Arnoldi +ApplyVT xbraid/drivers/mfem_arnoldi.hpp /^ void ApplyVT(const Vector & u, Vector & ubar)$/;" f class:Arnoldi +Arnoldi xbraid/drivers/mfem_arnoldi.hpp /^ Arnoldi(int k_max_, MPI_Comm comm_)$/;" f class:Arnoldi +Arnoldi xbraid/drivers/mfem_arnoldi.hpp /^class Arnoldi$/;" c +B include/hessianApprox.hpp /^ MyReal* B;$/;" m class:BFGS +BACKTRACKINGLS include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" e enum:stepsizetype +BFGS include/hessianApprox.hpp /^class BFGS : public HessianApprox {$/;" c +BFGS_SERIAL include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" e enum:hessiantype +BRAID_DIR xbraid/drivers/Makefile /^BRAID_DIR=..\/braid$/;" m +BRAID_DIR xbraid/examples/Makefile /^BRAID_DIR=..\/braid$/;" m +BRAID_FILES xbraid/braid/Makefile /^BRAID_FILES = _util.c braid.c _braid.c braid_test.c _braid_status.c braid_F90_iface.c _braid_base.c _braid_tape.c$/;" m +BRAID_FLAGS xbraid/drivers/Makefile /^BRAID_FLAGS = -I$(BRAID_DIR)$/;" m +BRAID_FLAGS xbraid/examples/Makefile /^BRAID_FLAGS = -I$(BRAID_DIR)$/;" m +BRAID_HEADERS xbraid/braid/Makefile /^BRAID_HEADERS = _braid.h braid.h _util.h braid_test.h braid_status.h braid_defs.h _braid_base.h _braid_tape.h$/;" m +BRAID_INC_DIR Makefile /^BRAID_INC_DIR = xbraid\/braid$/;" m +BRAID_LIB_FILE Makefile /^BRAID_LIB_FILE = xbraid\/braid\/libbraid.a$/;" m +BRAID_LIB_FILE xbraid/drivers/Makefile /^BRAID_LIB_FILE = $(BRAID_DIR)\/libbraid.a$/;" m +BRAID_LIB_FILE xbraid/examples/Makefile /^BRAID_LIB_FILE = $(BRAID_DIR)\/libbraid.a$/;" m +BRAID_OBJ xbraid/braid/Makefile /^BRAID_OBJ = $(BRAID_FILES:.c=.o)$/;" m +BUFPACK xbraid/braid/_braid_tape.h /^ BUFPACK = 6,$/;" e enum:_braid_Call_enum +BUFUNPACK xbraid/braid/_braid_tape.h /^ BUFUNPACK = 7,$/;" e enum:_braid_Call_enum +BUILD_DIR Makefile /^BUILD_DIR = build$/;" m +BraidAccessStatus xbraid/braid/braid.hpp /^ BraidAccessStatus(braid_AccessStatus _astatus)$/;" f class:BraidAccessStatus +BraidAccessStatus xbraid/braid/braid.hpp /^class BraidAccessStatus$/;" c +BraidApp xbraid/braid/braid.hpp /^ BraidApp(MPI_Comm _comm_t,$/;" f class:BraidApp +BraidApp xbraid/braid/braid.hpp /^class BraidApp$/;" c +BraidBufferStatus xbraid/braid/braid.hpp /^ BraidBufferStatus( braid_BufferStatus _bstatus )$/;" f class:BraidBufferStatus +BraidBufferStatus xbraid/braid/braid.hpp /^class BraidBufferStatus$/;" c +BraidCoarsenRefStatus xbraid/braid/braid.hpp /^ BraidCoarsenRefStatus(braid_CoarsenRefStatus _cstatus)$/;" f class:BraidCoarsenRefStatus +BraidCoarsenRefStatus xbraid/braid/braid.hpp /^class BraidCoarsenRefStatus$/;" c +BraidCore xbraid/braid/braid.hpp /^ BraidCore(MPI_Comm comm_world, BraidApp *app)$/;" f class:BraidCore +BraidCore xbraid/braid/braid.hpp /^class BraidCore$/;" c +BraidOptions xbraid/drivers/braid_mfem.hpp /^BraidOptions::BraidOptions(int argc, char *argv[])$/;" f class:BraidOptions +BraidOptions xbraid/drivers/braid_mfem.hpp /^struct BraidOptions : public OptionsParser$/;" s +BraidOptions xbraid/drivers/braid_mfem_block.hpp /^BraidOptions::BraidOptions(int argc, char *argv[])$/;" f class:BraidOptions +BraidOptions xbraid/drivers/braid_mfem_block.hpp /^struct BraidOptions : public OptionsParser$/;" s +BraidStepStatus xbraid/braid/braid.hpp /^ BraidStepStatus(braid_StepStatus _pstatus)$/;" f class:BraidStepStatus +BraidStepStatus xbraid/braid/braid.hpp /^class BraidStepStatus$/;" c +BraidUtil xbraid/braid/braid.hpp /^ BraidUtil() { }$/;" f class:BraidUtil +BraidUtil xbraid/braid/braid.hpp /^class BraidUtil$/;" c +BraidVector xbraid/drivers/braid_mfem.hpp /^ BraidVector(const BraidVector &source_vector)$/;" f class:BraidVector +BraidVector xbraid/drivers/braid_mfem.hpp /^ BraidVector(int source_level, ParFiniteElementSpace *pfes)$/;" f class:BraidVector +BraidVector xbraid/drivers/braid_mfem.hpp /^ BraidVector(int source_level, const HypreParVector &source_vector)$/;" f class:BraidVector +BraidVector xbraid/drivers/braid_mfem.hpp /^class BraidVector : public HypreParVector$/;" c +BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::BraidVector(const BraidVector &source_vector)$/;" f class:BraidVector +BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::BraidVector(int source_level, const Array &bOffsets)$/;" f class:BraidVector +BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::BraidVector(int source_level, const BlockVector &source_vector)$/;" f class:BraidVector +BraidVector xbraid/drivers/braid_mfem_block.hpp /^class BraidVector : public BlockVector$/;" c +BufPack xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::BufPack(braid_Vector u_,$/;" f class:MFEMBraidApp +BufPack xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::BufPack(braid_Vector u_, $/;" f class:MFEMBraidApp +BufSize xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::BufSize(int *size_ptr,$/;" f class:MFEMBraidApp +BufSize xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::BufSize(int *size_ptr,$/;" f class:MFEMBraidApp +BufUnpack xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::BufUnpack(void *buffer,$/;" f class:MFEMBraidApp +BufUnpack xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::BufUnpack(void *buffer,$/;" f class:MFEMBraidApp +CC Makefile /^CC = mpicc$/;" m +CLASSIFICATION include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +CLONE xbraid/braid/_braid_tape.h /^ CLONE = 3,$/;" e enum:_braid_Call_enum +CONFIG_ARG_MAX_BYTES include/config.hpp 7;" d +CONVOLUTION include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +CONVOLUTIONAL include/config.hpp /^enum networkType{DENSE, CONVOLUTIONAL}; $/;" e enum:networkType +CXX Makefile /^CXX = mpicxx$/;" m +CXX_EXAMPLES xbraid/drivers/Makefile /^CXX_EXAMPLES = drive-diffusion-1D-moving-mesh drive-diffusion-1D-moving-mesh-serial \\$/;" m +CXX_FLAGS Makefile /^CXX_FLAGS = -g -Wall -pedantic -lm -Wno-write-strings -Wno-delete-non-virtual-dtor -std=c++11$/;" m +C_EXAMPLES xbraid/drivers/Makefile /^C_EXAMPLES = drive-burgers-1D drive-diffusion-2D drive-lorenz$/;" m +C_EXAMPLES xbraid/examples/Makefile /^C_EXAMPLES = ex-03 ex-03-serial$/;" m +C_NOHYPRE xbraid/examples/Makefile /^C_NOHYPRE = ex-01 ex-01-adjoint ex-01-optimization ex-01-refinement ex-01-expanded ex-01-expanded-bdf2 ex-02 ex-04 ex-04-serial$/;" m +ClassificationLayer include/layer.hpp /^class ClassificationLayer : public Layer$/;" c +Clone xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Clone(braid_Vector u_,$/;" f class:MFEMBraidApp +Clone xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Clone(braid_Vector u_,$/;" f class:MFEMBraidApp +Coarsen xbraid/braid/braid.hpp /^ virtual braid_Int Coarsen(braid_Vector fu_,$/;" f class:BraidApp +Coarsen xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Coarsen(braid_Vector fu_,$/;" f class:MFEMBraidApp +Coarsen xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Coarsen(braid_Vector fu_, braid_Vector *cu_ptr, BraidCoarsenRefStatus &status)$/;" f class:MFEMBraidApp +ComputeMeshSize xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::ComputeMeshSize( ParMesh *pmesh, double * h_min_ptr, double * h_max_ptr)$/;" f class:SpaceTimeMeshInfo +ComputeMeshSize xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::ComputeMeshSize( ParMesh *pmesh, double * h_min_ptr, double * h_max_ptr)$/;" f class:SpaceTimeMeshInfo +ComputeSpaceLevel xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::ComputeSpaceLevel(double tstart, double tprior, double tstop)$/;" f class:MFEMBraidApp +ComputeSpaceLevel xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::ComputeSpaceLevel(double tstart, double tprior, double tstop)$/;" f class:MFEMBraidApp +Config include/config.hpp /^class Config {$/;" c +Config pythonutil/config.py /^class Config(OrderedBunch):$/;" c +ConstructFESpace xbraid/drivers/braid_mfem.hpp /^ParFiniteElementSpace *MFEMBraidApp::ConstructFESpace(ParMesh *pmesh)$/;" f class:MFEMBraidApp +ConstructFESpace xbraid/drivers/braid_mfem_block.hpp /^ParFiniteElementSpace *MFEMBraidApp::ConstructFESpace(ParMesh *pmesh)$/;" f class:MFEMBraidApp +ConvLayer include/layer.hpp /^class ConvLayer : public Layer {$/;" c +DENSE include/config.hpp /^enum networkType{DENSE, CONVOLUTIONAL}; $/;" e enum:networkType +DENSE include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +DETERMINISTIC include/config.hpp /^enum batchtype{DETERMINISTIC, STOCHASTIC};$/;" e enum:batchtype +DOX xbraid/docs/Makefile /^DOX=doxygen$/;" m +DOXVERSION xbraid/docs/Makefile /^DOXVERSION := $(shell expr `doxygen --version | sed -e 's\/\\.\\([0-9][0-9]\\)\/\\1\/g' -e 's\/\\.\\([0-9]\\)\/0\\1\/g' -e 's\/^[0-9]\\{3,4\\}$$\/&00\/'` \\>= 10800)$/;" m +DataSet include/dataset.hpp /^class DataSet {$/;" c +DenseLayer include/layer.hpp /^class DenseLayer : public Layer {$/;" c +DenseMatrixTimeDependentOperator xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrixTimeDependentOperator(DenseMatrix & A_) : TimeDependentOperator(A_.Width()), A(A_) {}$/;" f class:DenseMatrixTimeDependentOperator +DenseMatrixTimeDependentOperator xbraid/drivers/mfem_arnoldi.hpp /^class DenseMatrixTimeDependentOperator : public TimeDependentOperator$/;" c +Dot xbraid/drivers/mfem_arnoldi.hpp /^ double Dot(const Vector &x, const Vector &y) const$/;" f class:Arnoldi +Drive xbraid/braid/braid.hpp /^ void Drive() { braid_Drive(core); }$/;" f class:BraidCore +EvalBufSize xbraid/drivers/braid_mfem.hpp /^ static int EvalBufSize(int vector_size)$/;" f class:MFEMBraidApp +EvalBufSize xbraid/drivers/braid_mfem_block.hpp /^ static int EvalBufSize(int vector_size)$/;" f class:MFEMBraidApp +FIXED include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" e enum:stepsizetype +FREE xbraid/braid/_braid_tape.h /^ FREE = 4,$/;" e enum:_braid_Call_enum +F_NOHYPRE xbraid/examples/Makefile /^F_NOHYPRE = ex-01-expanded-f$/;" m +Free xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Free(braid_Vector u_)$/;" f class:MFEMBraidApp +Free xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Free(braid_Vector u_)$/;" f class:MFEMBraidApp +GenKrylovSpace xbraid/drivers/mfem_arnoldi.hpp /^ void GenKrylovSpace(const Vector & u)$/;" f class:Arnoldi +GetCTprior xbraid/braid/braid.hpp /^ void GetCTprior(braid_Real *c_tprior_ptr) { braid_CoarsenRefStatusGetCTprior(cstatus, c_tprior_ptr); }$/;" f class:BraidCoarsenRefStatus +GetCTstop xbraid/braid/braid.hpp /^ void GetCTstop(braid_Real *c_tstop_ptr) { braid_CoarsenRefStatusGetCTstop(cstatus, c_tstop_ptr); }$/;" f class:BraidCoarsenRefStatus +GetCore xbraid/braid/braid.hpp /^ braid_Core GetCore() { return core; };$/;" f class:BraidCore +GetDistribution xbraid/braid/braid.hpp /^ void GetDistribution(braid_Int *ilower_ptr, braid_Int *iupper_ptr) { _braid_GetDistribution(core, ilower_ptr, iupper_ptr); };$/;" f class:BraidCore +GetDone xbraid/braid/braid.hpp /^ void GetDone(braid_Int *done_ptr) { braid_AccessStatusGetDone(astatus, done_ptr); }$/;" f class:BraidAccessStatus +GetFTprior xbraid/braid/braid.hpp /^ void GetFTprior(braid_Real *f_tprior_ptr) { braid_CoarsenRefStatusGetFTprior(cstatus, f_tprior_ptr); }$/;" f class:BraidCoarsenRefStatus +GetFTstop xbraid/braid/braid.hpp /^ void GetFTstop(braid_Real *f_tstop_ptr) { braid_CoarsenRefStatusGetFTstop(cstatus, f_tstop_ptr); }$/;" f class:BraidCoarsenRefStatus +GetH xbraid/drivers/mfem_arnoldi.hpp /^ TimeDependentOperator & GetH( )$/;" f class:Arnoldi +GetIter xbraid/braid/braid.hpp /^ void GetIter(braid_Int *iter_ptr) { braid_StepStatusGetIter(pstatus, iter_ptr); }$/;" f class:BraidStepStatus +GetIter xbraid/braid/braid.hpp /^ void GetIter(braid_Int *iter_ptr) { braid_AccessStatusGetIter(astatus, iter_ptr); }$/;" f class:BraidAccessStatus +GetLevel xbraid/braid/braid.hpp /^ void GetLevel(braid_Int *level_ptr) { braid_StepStatusGetLevel(pstatus, level_ptr); }$/;" f class:BraidStepStatus +GetLevel xbraid/braid/braid.hpp /^ void GetLevel(braid_Int *level_ptr) { braid_AccessStatusGetLevel(astatus, level_ptr); }$/;" f class:BraidAccessStatus +GetLevel xbraid/braid/braid.hpp /^ void GetLevel(braid_Int *level_ptr) { braid_CoarsenRefStatusGetLevel(cstatus, level_ptr); }$/;" f class:BraidCoarsenRefStatus +GetMessageType xbraid/braid/braid.hpp /^ void GetMessageType( braid_Int *messagetype_ptr ) { braid_BufferStatusGetMessageType( bstatus, messagetype_ptr); }$/;" f class:BraidBufferStatus +GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_StepStatusGetNLevels(pstatus, nlevels_ptr); }$/;" f class:BraidStepStatus +GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_AccessStatusGetNLevels(astatus, nlevels_ptr);}$/;" f class:BraidAccessStatus +GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_CoarsenRefStatusGetNLevels(cstatus, nlevels_ptr); }$/;" f class:BraidCoarsenRefStatus +GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_GetNLevels(core, nlevels_ptr); }$/;" f class:BraidCore +GetNRefine xbraid/braid/braid.hpp /^ void GetNRefine(braid_Int *nrefine_ptr) { braid_StepStatusGetNRefine(pstatus, nrefine_ptr); }$/;" f class:BraidStepStatus +GetNRefine xbraid/braid/braid.hpp /^ void GetNRefine(braid_Int *nrefine_ptr) { braid_AccessStatusGetNRefine(astatus, nrefine_ptr); }$/;" f class:BraidAccessStatus +GetNRefine xbraid/braid/braid.hpp /^ void GetNRefine(braid_Int *nrefine_ptr) { braid_CoarsenRefStatusGetNRefine(cstatus, nrefine_ptr); }$/;" f class:BraidCoarsenRefStatus +GetNumBlocks xbraid/drivers/braid_mfem_block.hpp /^void BraidVector::GetNumBlocks(int &blocks)$/;" f class:BraidVector +GetNumIter xbraid/braid/braid.hpp /^ void GetNumIter(braid_Int *niter_ptr) { braid_GetNumIter(core, niter_ptr); }$/;" f class:BraidCore +GetNumSpaceLevels xbraid/drivers/braid_mfem.hpp /^ int GetNumSpaceLevels() const { return ode.Size(); }$/;" f class:MFEMBraidApp +GetNumSpaceLevels xbraid/drivers/braid_mfem_block.hpp /^ int GetNumSpaceLevels() const { return ode.Size(); }$/;" f class:MFEMBraidApp +GetOffsetsPtr xbraid/drivers/braid_mfem_block.hpp /^void BraidVector::GetOffsetsPtr(const int *&address)$/;" f class:BraidVector +GetOldFineTolx xbraid/braid/braid.hpp /^ void GetOldFineTolx(braid_Real *old_fine_tolx_ptr) { braid_StepStatusGetOldFineTolx(pstatus, old_fine_tolx_ptr); }$/;" f class:BraidStepStatus +GetRNorms xbraid/braid/braid.hpp /^ void GetRNorms(braid_Int *nrequest_ptr, braid_Real *rnorms)$/;" f class:BraidStepStatus +GetRNorms xbraid/braid/braid.hpp /^ void GetRNorms(braid_Int *nrequest_ptr, braid_Real *rnorms) { braid_GetRNorms(core, nrequest_ptr, rnorms); }$/;" f class:BraidCore +GetResidual xbraid/braid/braid.hpp /^ void GetResidual(braid_Real *rnorm_ptr) { braid_AccessStatusGetResidual(astatus, rnorm_ptr); }$/;" f class:BraidAccessStatus +GetSpatialAccuracy xbraid/braid/braid.hpp /^ void GetSpatialAccuracy(braid_StepStatus sstatus,$/;" f class:BraidUtil +GetT xbraid/braid/braid.hpp /^ void GetT(braid_Real *t_ptr) { braid_AccessStatusGetT(astatus, t_ptr); }$/;" f class:BraidAccessStatus +GetT xbraid/braid/braid.hpp /^ void GetT(braid_Real *tstart_ptr) { braid_StepStatusGetT(pstatus, tstart_ptr); }$/;" f class:BraidStepStatus +GetT xbraid/braid/braid.hpp /^ void GetT(braid_Real *tstart_ptr) { braid_CoarsenRefStatusGetT(cstatus, tstart_ptr); }$/;" f class:BraidCoarsenRefStatus +GetTILD xbraid/braid/braid.hpp /^ void GetTILD(braid_Real *t_ptr,$/;" f class:BraidAccessStatus +GetTIndex xbraid/braid/braid.hpp /^ void GetTIndex(braid_Int *tindex_ptr) { braid_StepStatusGetTIndex(pstatus, tindex_ptr); }$/;" f class:BraidStepStatus +GetTIndex xbraid/braid/braid.hpp /^ void GetTIndex(braid_Int *tindex_ptr) { braid_AccessStatusGetTIndex(astatus, tindex_ptr); }$/;" f class:BraidAccessStatus +GetTIndex xbraid/braid/braid.hpp /^ void GetTIndex(braid_Int *tindex_ptr) { braid_CoarsenRefStatusGetTIndex(cstatus, tindex_ptr); }$/;" f class:BraidCoarsenRefStatus +GetTpriorTstop xbraid/braid/braid.hpp /^ void GetTpriorTstop(braid_Real *tstart_ptr,$/;" f class:BraidCoarsenRefStatus +GetTstartTstop xbraid/braid/braid.hpp /^ void GetTstartTstop(braid_Real *tstart_ptr, braid_Real *tstop_ptr)$/;" f class:BraidStepStatus +GetTstop xbraid/braid/braid.hpp /^ void GetTstop(braid_Real *tstop_ptr) { braid_StepStatusGetTstop(pstatus, tstop_ptr); }$/;" f class:BraidStepStatus +GetWarmRestart xbraid/braid/braid.hpp /^ braid_Int GetWarmRestart() { return _braid_CoreElt(core, warm_restart); };$/;" f class:BraidCore +GetWrapperTest xbraid/braid/braid.hpp /^ void GetWrapperTest(braid_Int *wtest_ptr) { braid_AccessStatusGetWrapperTest(astatus, wtest_ptr); }$/;" f class:BraidAccessStatus +H xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrix H;$/;" m class:Arnoldi +H0 include/hessianApprox.hpp /^ MyReal H0; \/* Initial Hessian scaling factor *\/$/;" m class:L_BFGS +HYPRE_DIR xbraid/drivers/Makefile /^HYPRE_DIR = ..\/..\/hypre\/src\/hypre$/;" m +HYPRE_DIR xbraid/examples/Makefile /^HYPRE_DIR = ..\/..\/hypre\/src\/hypre$/;" m +HYPRE_FLAGS xbraid/drivers/Makefile /^HYPRE_FLAGS = -I$(HYPRE_DIR)\/include$/;" m +HYPRE_FLAGS xbraid/examples/Makefile /^HYPRE_FLAGS = -I$(HYPRE_DIR)\/include$/;" m +HYPRE_LIB xbraid/drivers/Makefile /^HYPRE_LIB = -L$(HYPRE_DIR)\/lib -lHYPRE$/;" m +HYPRE_LIB xbraid/examples/Makefile /^HYPRE_LIB = -L$(HYPRE_DIR)\/lib -lHYPRE$/;" m +HYPRE_LIB_FILE xbraid/examples/Makefile /^HYPRE_LIB_FILE = $(HYPRE_DIR)\/lib\/libHYPRE.a$/;" m +Hessian include/hessianApprox.hpp /^ MyReal* Hessian; \/* Storing the Hessian approximation (flattened: dimN*dimN) *\/$/;" m class:BFGS +HessianApprox include/hessianApprox.hpp /^class HessianApprox {$/;" c +Hop xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrixTimeDependentOperator Hop;$/;" m class:Arnoldi +Hy include/hessianApprox.hpp /^ MyReal* Hy;$/;" m class:BFGS +IDENTITY include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" e enum:hessiantype +INC Makefile /^INC = -I$(INC_DIR) -I$(BRAID_INC_DIR)$/;" m +INC_DIR Makefile /^INC_DIR = include$/;" m +INIT xbraid/braid/_braid_tape.h /^ INIT = 2,$/;" e enum:_braid_Call_enum +Identity include/hessianApprox.hpp /^class Identity : public HessianApprox{$/;" c +Init xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Init(double t,$/;" f class:MFEMBraidApp +Init xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Init(double t, braid_Vector *u_ptr)$/;" f class:MFEMBraidApp +InitLevel xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::InitLevel(int l)$/;" f class:MFEMBraidApp +InitLevel xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::InitLevel(int l)$/;" f class:MFEMBraidApp +InitMultilevelApp xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::InitMultilevelApp(ParMesh *pmesh, int pref, bool scoarsen)$/;" f class:MFEMBraidApp +InitMultilevelApp xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::InitMultilevelApp(ParMesh *pmesh, int pref, bool scoarsen)$/;" f class:MFEMBraidApp +LBFGS include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" e enum:hessiantype +L_BFGS include/hessianApprox.hpp /^class L_BFGS : public HessianApprox {$/;" c +Layer include/layer.hpp /^class Layer $/;" c +LoadMeshAndRefine xbraid/drivers/braid_mfem.hpp /^ParMesh *BraidOptions::LoadMeshAndRefine(MPI_Comm comm_x)$/;" f class:BraidOptions +LoadMeshAndSerialRefine xbraid/drivers/braid_mfem.hpp /^Mesh *BraidOptions::LoadMeshAndSerialRefine()$/;" f class:BraidOptions +LoadMeshAndSerialRefine xbraid/drivers/braid_mfem_block.hpp /^Mesh *BraidOptions::LoadMeshAndSerialRefine()$/;" f class:BraidOptions +M include/hessianApprox.hpp /^ int M; \/* Length of the l-bfgs memory (stages) *\/$/;" m class:L_BFGS +MFEMBraidApp xbraid/drivers/braid_mfem.hpp /^MFEMBraidApp::MFEMBraidApp($/;" f class:MFEMBraidApp +MFEMBraidApp xbraid/drivers/braid_mfem.hpp /^class MFEMBraidApp : public BraidApp$/;" c +MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::MFEMBraidApp( MPI_Comm comm_t_, TimeDependentOperator *ode_, BlockVector *X0_,$/;" f class:MFEMBraidApp +MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::MFEMBraidApp( MPI_Comm comm_t_, const int num_space_levels, double tstart_,$/;" f class:MFEMBraidApp +MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::MFEMBraidApp(MPI_Comm comm_t_, double tstart_, double tstop_, int ntime_)$/;" f class:MFEMBraidApp +MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^class MFEMBraidApp : public BraidApp$/;" c +MFEM_CONFIG_MK xbraid/drivers/Makefile /^MFEM_CONFIG_MK = $(MFEM_DIR)\/config\/config.mk$/;" m +MFEM_CONFIG_MK xbraid/examples/Makefile /^MFEM_CONFIG_MK = $(MFEM_DIR)\/config\/config.mk$/;" m +MFEM_DIR xbraid/drivers/Makefile /^MFEM_DIR = ..\/..\/mfem$/;" m +MFEM_DIR xbraid/examples/Makefile /^MFEM_DIR = ..\/..\/mfem$/;" m +MFEM_INTERFACE xbraid/drivers/Makefile /^MFEM_INTERFACE = .\/braid_mfem.hpp .\/braid_mfem_block.hpp ..\/braid\/braid.hpp$/;" m +MFEM_LIB_FILE xbraid/drivers/Makefile /^MFEM_LIB_FILE = mfem_is_not_built$/;" m +MFEM_LIB_FILE xbraid/examples/Makefile /^MFEM_LIB_FILE = mfem_is_not_built$/;" m +MPI_ANY_SOURCE xbraid/braid/mpistubs.h 65;" d +MPI_ANY_TAG xbraid/braid/mpistubs.h 66;" d +MPI_Aint xbraid/braid/mpistubs.h /^typedef int MPI_Aint;$/;" t +MPI_BOTTOM xbraid/braid/mpistubs.h 46;" d +MPI_BYTE xbraid/braid/mpistubs.h 52;" d +MPI_CHAR xbraid/braid/mpistubs.h 50;" d +MPI_COMM_NULL xbraid/braid/mpistubs.h 44;" d +MPI_COMM_WORLD xbraid/braid/mpistubs.h 43;" d +MPI_COMPLEX xbraid/braid/mpistubs.h 54;" d +MPI_Comm xbraid/braid/braid.h /^typedef int MPI_Comm;$/;" t +MPI_DOUBLE xbraid/braid/mpistubs.h 48;" d +MPI_Datatype xbraid/braid/mpistubs.h /^typedef int MPI_Datatype;$/;" t +MPI_Group xbraid/braid/mpistubs.h /^typedef int MPI_Group;$/;" t +MPI_INT xbraid/braid/mpistubs.h 49;" d +MPI_LONG xbraid/braid/mpistubs.h 51;" d +MPI_LOR xbraid/braid/mpistubs.h 59;" d +MPI_MAX xbraid/braid/mpistubs.h 58;" d +MPI_MIN xbraid/braid/mpistubs.h 57;" d +MPI_MyReal include/defs.hpp 11;" d +MPI_Op xbraid/braid/mpistubs.h /^typedef int MPI_Op;$/;" t +MPI_REAL xbraid/braid/mpistubs.h 53;" d +MPI_REQUEST_NULL xbraid/braid/mpistubs.h 64;" d +MPI_Request xbraid/braid/mpistubs.h /^typedef int MPI_Request;$/;" t +MPI_SOURCE xbraid/braid/mpistubs.h /^ int MPI_SOURCE;$/;" m struct:__anon1 +MPI_STATUSES_IGNORE xbraid/braid/mpistubs.h 61;" d +MPI_SUCCESS xbraid/braid/mpistubs.h 60;" d +MPI_SUM xbraid/braid/mpistubs.h 56;" d +MPI_Status xbraid/braid/mpistubs.h /^} MPI_Status;$/;" t typeref:struct:__anon1 +MPI_TAG xbraid/braid/mpistubs.h /^ int MPI_TAG;$/;" m struct:__anon1 +MPI_UNDEFINED xbraid/braid/mpistubs.h 63;" d +MPIcomm include/hessianApprox.hpp /^ MPI_Comm MPIcomm; \/* MPI communicator for parallel L-BFGS updates *\/$/;" m class:HessianApprox +MPIrank include/dataset.hpp /^ int MPIrank; \/* Processors rank *\/$/;" m class:DataSet +MPIsize include/dataset.hpp /^ int MPIsize; \/* Size of the global communicator *\/$/;" m class:DataSet +Mult xbraid/drivers/mfem_arnoldi.hpp /^ virtual void Mult(const Vector &x, Vector &y) const$/;" f class:DenseMatrixTimeDependentOperator +MyReal include/defs.hpp /^typedef double MyReal;$/;" t +Network include/network.hpp /^class Network$/;" c +OBJECTIVET xbraid/braid/_braid_tape.h /^ OBJECTIVET = 9$/;" e enum:_braid_Call_enum +OBJ_FILES Makefile /^OBJ_FILES = $(patsubst $(SRC_DIR)\/%.cpp,$(BUILD_DIR)\/%.o,$(SRC_FILES))$/;" m +ONEOVERK include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" e enum:stepsizetype +OPENCONV include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +OPENCONVMNIST include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +OPENDENSE include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +OPENZERO include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype +OpenConvLayer include/layer.hpp /^class OpenConvLayer : public Layer {$/;" c +OpenConvLayerMNIST include/layer.hpp /^class OpenConvLayerMNIST : public OpenConvLayer {$/;" c +OpenDenseLayer include/layer.hpp /^class OpenDenseLayer : public DenseLayer {$/;" c +OpenExpandZero include/layer.hpp /^class OpenExpandZero : public Layer $/;" c +OrderedBunch pythonutil/ordered_bunch.py /^class OrderedBunch(OrderedDict):$/;" c +OrderedDict pythonutil/ordered_dict.py /^class OrderedDict(dict):$/;" c +P xbraid/drivers/braid_mfem.hpp /^ Array P; \/\/ local prolongation matrices, l+1 --> l$/;" m class:MFEMBraidApp +P xbraid/drivers/braid_mfem_block.hpp /^ Array P; \/\/ local interpolation matrices, l --> l+1$/;" m class:MFEMBraidApp +Print xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::Print(MPI_Comm comm)$/;" f class:SpaceTimeMeshInfo +Print xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::Print(MPI_Comm comm)$/;" f class:SpaceTimeMeshInfo +RELU include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" e enum:activation +Refine xbraid/braid/braid.hpp /^ virtual braid_Int Refine(braid_Vector cu_,$/;" f class:BraidApp +Refine xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Refine(braid_Vector cu_,$/;" f class:MFEMBraidApp +Refine xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Refine(braid_Vector cu_, braid_Vector *fu_ptr, BraidCoarsenRefStatus &status)$/;" f class:MFEMBraidApp +Reinitialize xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::Reinitialize(int _max_levels)$/;" f class:SpaceTimeMeshInfo +Reinitialize xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::Reinitialize(int _max_levels)$/;" f class:SpaceTimeMeshInfo +Residual xbraid/drivers/braid_mfem.hpp /^ virtual int Residual(braid_Vector u_,$/;" f class:MFEMBraidApp +Residual xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Residual(braid_Vector u_, braid_Vector r_, BraidStepStatus &pstatus)$/;" f class:MFEMBraidApp +SEQFLAGS xbraid/braid/Makefile /^ SEQFLAGS = $/;" m +SEQFLAGS xbraid/braid/Makefile /^ SEQFLAGS = -Dbraid_SEQUENTIAL$/;" m +SMRELU include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" e enum:activation +SRC_DIR Makefile /^SRC_DIR = src$/;" m +SRC_FILES Makefile /^SRC_FILES = $(wildcard $(SRC_DIR)\/*.cpp)$/;" m +STEP xbraid/braid/_braid_tape.h /^ STEP = 1,$/;" e enum:_braid_Call_enum +STOCHASTIC include/config.hpp /^enum batchtype{DETERMINISTIC, STOCHASTIC};$/;" e enum:batchtype +SUM xbraid/braid/_braid_tape.h /^ SUM = 5,$/;" e enum:_braid_Call_enum +SetAbsTol xbraid/braid/braid.hpp /^ void SetAbsTol(braid_Real tol) { braid_SetAbsTol(core, tol); }$/;" f class:BraidCore +SetAccessLevel xbraid/braid/braid.hpp /^ void SetAccessLevel(braid_Int access_level) { braid_SetAccessLevel(core, access_level); }$/;" f class:BraidCore +SetAggCFactor xbraid/braid/braid.hpp /^ void SetAggCFactor(braid_Int cfactor0)$/;" f class:BraidCore +SetBraidCoreOptions xbraid/drivers/braid_mfem.hpp /^void BraidOptions::SetBraidCoreOptions(BraidCore &core)$/;" f class:BraidOptions +SetBraidCoreOptions xbraid/drivers/braid_mfem_block.hpp /^void BraidOptions::SetBraidCoreOptions(BraidCore &core)$/;" f class:BraidOptions +SetCFactor xbraid/braid/braid.hpp /^ void SetCFactor(braid_Int level, braid_Int cfactor)$/;" f class:BraidCore +SetExactSolution xbraid/drivers/braid_mfem.hpp /^ void SetExactSolution(Coefficient *exsol) { exact_sol = exsol; }$/;" f class:MFEMBraidApp +SetExactSolution xbraid/drivers/braid_mfem_block.hpp /^ void SetExactSolution(Coefficient *exsol) { exact_sol = exsol; }$/;" f class:MFEMBraidApp +SetFMG xbraid/braid/braid.hpp /^ void SetFMG() { braid_SetFMG(core); }$/;" f class:BraidCore +SetInitialCondition xbraid/drivers/braid_mfem.hpp /^ void SetInitialCondition(HypreParVector *_X0) { X0 = _X0; }$/;" f class:MFEMBraidApp +SetInitialCondition xbraid/drivers/braid_mfem_block.hpp /^ void SetInitialCondition(BlockVector *_X0) { X0 = _X0; }$/;" f class:MFEMBraidApp +SetMaxIter xbraid/braid/braid.hpp /^ void SetMaxIter(braid_Int max_iter) { braid_SetMaxIter(core, max_iter); }$/;" f class:BraidCore +SetMaxLevels xbraid/braid/braid.hpp /^ void SetMaxLevels(braid_Int max_levels) { braid_SetMaxLevels(core, max_levels); }$/;" f class:BraidCore +SetMaxRefinements xbraid/braid/braid.hpp /^ void SetMaxRefinements(braid_Int max_refinements) {braid_SetMaxRefinements(core, max_refinements);}$/;" f class:BraidCore +SetMinCoarse xbraid/braid/braid.hpp /^ void SetMinCoarse(braid_Int min_coarse) { braid_SetMinCoarse(core, min_coarse); }$/;" f class:BraidCore +SetNFMG xbraid/braid/braid.hpp /^ void SetNFMG(braid_Int k) { braid_SetNFMG(core, k); }$/;" f class:BraidCore +SetNFMGVcyc xbraid/braid/braid.hpp /^ void SetNFMGVcyc(braid_Int nfmg_Vcyc) { braid_SetNFMGVcyc(core, nfmg_Vcyc); }$/;" f class:BraidCore +SetNRelax xbraid/braid/braid.hpp /^ void SetNRelax(braid_Int level, braid_Int nrelax)$/;" f class:BraidCore +SetOldFineTolx xbraid/braid/braid.hpp /^ void SetOldFineTolx(braid_Real old_fine_tolx) { braid_StepStatusSetOldFineTolx(pstatus, old_fine_tolx); }$/;" f class:BraidStepStatus +SetOperator xbraid/drivers/mfem_arnoldi.hpp /^ void SetOperator(Operator &A_)$/;" f class:Arnoldi +SetPrintFile xbraid/braid/braid.hpp /^ void SetPrintFile(const char *printfile_name) { braid_SetPrintFile(core, printfile_name); }$/;" f class:BraidCore +SetPrintLevel xbraid/braid/braid.hpp /^ void SetPrintLevel(braid_Int print_level) { braid_SetPrintLevel(core, print_level); }$/;" f class:BraidCore +SetRFactor xbraid/braid/braid.hpp /^ void SetRFactor(braid_Int rfactor) { braid_StepStatusSetRFactor(pstatus, rfactor); }$/;" f class:BraidStepStatus +SetRSpace xbraid/braid/braid.hpp /^ void SetRSpace(braid_Int rspace) { braid_StepStatusSetRSpace(pstatus, rspace); }$/;" f class:BraidStepStatus +SetRandomInitVectors xbraid/drivers/braid_mfem.hpp /^ void SetRandomInitVectors(unsigned seed)$/;" f class:MFEMBraidApp +SetRefine xbraid/braid/braid.hpp /^ void SetRefine(braid_Int refine) {braid_SetRefine(core, refine);}$/;" f class:BraidCore +SetRelTol xbraid/braid/braid.hpp /^ void SetRelTol(braid_Real tol) { braid_SetRelTol(core, tol); }$/;" f class:BraidCore +SetResidual xbraid/braid/braid.hpp /^ void SetResidual() { braid_SetResidual(core, _BraidAppResidual); }$/;" f class:BraidCore +SetRevertedRanks xbraid/braid/braid.hpp /^ void SetRevertedRanks(braid_Int reverted_ranks) { braid_SetRevertedRanks(core, reverted_ranks); }$/;" f class:BraidCore +SetRow xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::SetRow(int braid_level, int vec_level, ParMesh * pmesh, double dt)$/;" f class:SpaceTimeMeshInfo +SetRow xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::SetRow(int braid_level, int vec_level, ParMesh * pmesh, double dt)$/;" f class:SpaceTimeMeshInfo +SetSeqSoln xbraid/braid/braid.hpp /^ void SetSeqSoln(braid_Int use_seq_soln) { braid_SetSeqSoln(core, use_seq_soln); }$/;" f class:BraidCore +SetSize xbraid/braid/braid.hpp /^ void SetSize( braid_Int size ) { braid_BufferStatusSetSize( bstatus, size ); }$/;" f class:BraidBufferStatus +SetSkip xbraid/braid/braid.hpp /^ void SetSkip(braid_Int skip) { braid_SetSkip(core, skip); }$/;" f class:BraidCore +SetSpaceLevel xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::SetSpaceLevel(int l, TimeDependentOperator *ode_l,$/;" f class:MFEMBraidApp +SetSpaceLevel xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::SetSpaceLevel(int l, TimeDependentOperator *ode_l, ODESolver *solver_l, $/;" f class:MFEMBraidApp +SetSpatialCoarsenAndRefine xbraid/braid/braid.hpp /^ void SetSpatialCoarsenAndRefine()$/;" f class:BraidCore +SetStorage xbraid/braid/braid.hpp /^ void SetStorage(braid_Int storage) { braid_SetStorage(core, storage); }$/;" f class:BraidCore +SetTemporalNorm xbraid/braid/braid.hpp /^ void SetTemporalNorm(braid_Int tnorm) { braid_SetTemporalNorm(core, tnorm); }$/;" f class:BraidCore +SetTightFineTolx xbraid/braid/braid.hpp /^ void SetTightFineTolx(braid_Int tight_fine_tolx) { braid_StepStatusSetTightFineTolx(pstatus, tight_fine_tolx); }$/;" f class:BraidStepStatus +SetVisHostAndPort xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::SetVisHostAndPort(const char *vh, int vp)$/;" f class:MFEMBraidApp +SetVisHostAndPort xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::SetVisHostAndPort(const char *vh, int vp)$/;" f class:MFEMBraidApp +SetVisSampling xbraid/drivers/braid_mfem.hpp /^ void SetVisSampling(int time_steps, int braid_steps)$/;" f class:MFEMBraidApp +SetVisSampling xbraid/drivers/braid_mfem_block.hpp /^ void SetVisSampling(int time_steps, int braid_steps)$/;" f class:MFEMBraidApp +SetVisScreenshots xbraid/drivers/braid_mfem.hpp /^ void SetVisScreenshots(bool ss) { vis_screenshots = ss; }$/;" f class:MFEMBraidApp +SetVisScreenshots xbraid/drivers/braid_mfem_block.hpp /^ void SetVisScreenshots(bool ss) { vis_screenshots = ss; }$/;" f class:MFEMBraidApp +SpaceTimeMeshInfo xbraid/drivers/braid_mfem.hpp /^ SpaceTimeMeshInfo(int _max_levels) :$/;" f class:SpaceTimeMeshInfo +SpaceTimeMeshInfo xbraid/drivers/braid_mfem.hpp /^class SpaceTimeMeshInfo$/;" c +SpaceTimeMeshInfo xbraid/drivers/braid_mfem_block.hpp /^ SpaceTimeMeshInfo(int _max_levels) : $/;" f class:SpaceTimeMeshInfo +SpaceTimeMeshInfo xbraid/drivers/braid_mfem_block.hpp /^class SpaceTimeMeshInfo$/;" c +SpatialNorm xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::SpatialNorm(braid_Vector u_,$/;" f class:MFEMBraidApp +SpatialNorm xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::SpatialNorm(braid_Vector u_, double *norm_ptr)$/;" f class:MFEMBraidApp +SplitCommworld xbraid/braid/braid.hpp /^ void SplitCommworld(const MPI_Comm *comm_world,$/;" f class:BraidUtil +Step xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Step(braid_Vector u_,$/;" f class:MFEMBraidApp +Step xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Step(braid_Vector u_, braid_Vector ustop_, braid_Vector fstop_, BraidStepStatus &pstatus)$/;" f class:MFEMBraidApp +StepStatusGetTol xbraid/braid/braid.hpp /^ void StepStatusGetTol(braid_Real *tol_ptr) { braid_StepStatusGetTol(pstatus, tol_ptr); }$/;" f class:BraidStepStatus +Sum xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Sum(double alpha,$/;" f class:MFEMBraidApp +Sum xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Sum(double alpha, braid_Vector a_, double beta, braid_Vector b_)$/;" f class:MFEMBraidApp +T include/config.hpp /^ MyReal T;$/;" m class:Config +TABLE OF CONTENTS xbraid/docs/developer_manual_header.tex /^\\tableofcontents$/;" s +TABLE OF CONTENTS xbraid/docs/user_manual_header.tex /^\\tableofcontents$/;" s +TANH include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" e enum:activation +TestAll xbraid/braid/braid.hpp /^ braid_Int TestAll(BraidApp *app,$/;" f class:BraidUtil +TestBuf xbraid/braid/braid.hpp /^ braid_Int TestBuf(BraidApp *app,$/;" f class:BraidUtil +TestClone xbraid/braid/braid.hpp /^ void TestClone(BraidApp *app,$/;" f class:BraidUtil +TestCoarsenRefine xbraid/braid/braid.hpp /^ braid_Int TestCoarsenRefine(BraidApp *app,$/;" f class:BraidUtil +TestInitAccess xbraid/braid/braid.hpp /^ void TestInitAccess(BraidApp *app,$/;" f class:BraidUtil +TestResidual xbraid/braid/braid.hpp /^ braid_Int TestResidual(BraidApp *app,$/;" f class:BraidUtil +TestSpatialNorm xbraid/braid/braid.hpp /^ braid_Int TestSpatialNorm(BraidApp *app,$/;" f class:BraidUtil +TestSum xbraid/braid/braid.hpp /^ void TestSum(BraidApp *app,$/;" f class:BraidUtil +TrueDofsToLDofs xbraid/drivers/braid_mfem_block.hpp /^void TrueDofsToLDofs(const Vector &u, ParGridFunction &v)$/;" f namespace:mfem +V xbraid/drivers/mfem_arnoldi.hpp /^ Vector *V;$/;" m class:Arnoldi +X0 xbraid/drivers/braid_mfem.hpp /^ HypreParVector *X0; \/\/ Initial condition (at the finest level 0)$/;" m class:MFEMBraidApp +X0 xbraid/drivers/braid_mfem_block.hpp /^ BlockVector *X0; \/\/ Initial condition (at the finest level 0)$/;" m class:MFEMBraidApp +_BraidAppAccess xbraid/braid/braid.hpp /^static braid_Int _BraidAppAccess(braid_App _app,$/;" f +_BraidAppBufPack xbraid/braid/braid.hpp /^static braid_Int _BraidAppBufPack(braid_App _app,$/;" f +_BraidAppBufSize xbraid/braid/braid.hpp /^static braid_Int _BraidAppBufSize(braid_App _app,$/;" f +_BraidAppBufUnpack xbraid/braid/braid.hpp /^static braid_Int _BraidAppBufUnpack(braid_App _app,$/;" f +_BraidAppClone xbraid/braid/braid.hpp /^static braid_Int _BraidAppClone(braid_App _app,$/;" f +_BraidAppCoarsen xbraid/braid/braid.hpp /^static braid_Int _BraidAppCoarsen(braid_App _app,$/;" f +_BraidAppFree xbraid/braid/braid.hpp /^static braid_Int _BraidAppFree(braid_App _app,$/;" f +_BraidAppInit xbraid/braid/braid.hpp /^static braid_Int _BraidAppInit(braid_App _app,$/;" f +_BraidAppRefine xbraid/braid/braid.hpp /^static braid_Int _BraidAppRefine(braid_App _app,$/;" f +_BraidAppResidual xbraid/braid/braid.hpp /^static braid_Int _BraidAppResidual(braid_App _app,$/;" f +_BraidAppSpatialNorm xbraid/braid/braid.hpp /^static braid_Int _BraidAppSpatialNorm(braid_App _app,$/;" f +_BraidAppStep xbraid/braid/braid.hpp /^static braid_Int _BraidAppStep(braid_App _app,$/;" f +_BraidAppSum xbraid/braid/braid.hpp /^static braid_Int _BraidAppSum(braid_App _app,$/;" f +__contains__ pythonutil/ordered_bunch.py /^ def __contains__(self, k):$/;" m class:OrderedBunch file: +__delattr__ pythonutil/ordered_bunch.py /^ def __delattr__(self, k):$/;" m class:OrderedBunch file: +__delitem__ pythonutil/ordered_dict.py /^ def __delitem__(self, key, dict_delitem=dict.__delitem__):$/;" m class:OrderedDict file: +__eq__ pythonutil/config.py /^ def __eq__(self,konfig):$/;" m class:Config file: +__eq__ pythonutil/ordered_dict.py /^ def __eq__(self, other):$/;" m class:OrderedDict file: +__getattr__ pythonutil/config.py /^ def __getattr__(self,k):$/;" m class:Config file: +__getattr__ pythonutil/ordered_bunch.py /^ def __getattr__(self, k):$/;" m class:OrderedBunch file: +__getitem__ pythonutil/config.py /^ def __getitem__(self,k):$/;" m class:Config file: +__init__ pythonutil/config.py /^ def __init__(self,*args,**kwarg):$/;" m class:Config +__init__ pythonutil/ordered_bunch.py /^ def __init__(self,*args,**kwarg):$/;" m class:OrderedBunch +__init__ pythonutil/ordered_dict.py /^ def __init__(self, *args, **kwds):$/;" m class:OrderedDict +__init__ pythonutil/switch.py /^ def __init__(self, value):$/;" m class:switch +__iter__ pythonutil/ordered_dict.py /^ def __iter__(self):$/;" m class:OrderedDict file: +__iter__ pythonutil/switch.py /^ def __iter__(self):$/;" m class:switch file: +__marker pythonutil/ordered_dict.py /^ __marker = object()$/;" v class:OrderedDict +__ne__ pythonutil/config.py /^ def __ne__(self,konfig):$/;" m class:Config file: +__ne__ pythonutil/ordered_dict.py /^ def __ne__(self, other):$/;" m class:OrderedDict file: +__reduce__ pythonutil/ordered_dict.py /^ def __reduce__(self):$/;" m class:OrderedDict file: +__repr__ pythonutil/config.py /^ def __repr__(self):$/;" m class:Config file: +__repr__ pythonutil/ordered_bunch.py /^ def __repr__(self):$/;" m class:OrderedBunch file: +__repr__ pythonutil/ordered_dict.py /^ def __repr__(self, _repr_running={}):$/;" m class:OrderedDict file: +__reversed__ pythonutil/ordered_dict.py /^ def __reversed__(self):$/;" m class:OrderedDict file: +__setattr__ pythonutil/ordered_bunch.py /^ def __setattr__(self, k, v):$/;" m class:OrderedBunch file: +__setitem__ pythonutil/ordered_dict.py /^ def __setitem__(self, key, value, dict_setitem=dict.__setitem__):$/;" m class:OrderedDict file: +__str__ pythonutil/config.py /^ def __str__(self):$/;" m class:Config file: +__str__ pythonutil/ordered_bunch.py /^ def __str__(self):$/;" m class:OrderedBunch file: +__update pythonutil/ordered_dict.py /^ __update = update # let subclasses override update without breaking __init__$/;" v class:OrderedDict +_braid_AccessStatus_struct xbraid/braid/_braid_status.h /^struct _braid_AccessStatus_struct$/;" s +_braid_Action xbraid/braid/_braid_tape.h /^} _braid_Action;$/;" t typeref:struct:_braid_Action_struct +_braid_Action_struct xbraid/braid/_braid_tape.h /^typedef struct _braid_Action_struct$/;" s +_braid_BaseVector_struct xbraid/braid/_braid.h /^struct _braid_BaseVector_struct$/;" s +_braid_BufferStatus_struct xbraid/braid/_braid_status.h /^struct _braid_BufferStatus_struct$/;" s +_braid_CTAlloc xbraid/braid/braid_defs.h 96;" d +_braid_Call xbraid/braid/_braid_tape.h /^} _braid_Call;$/;" t typeref:enum:_braid_Call_enum +_braid_Call_enum xbraid/braid/_braid_tape.h /^typedef enum _braid_Call_enum$/;" g +_braid_CoarsenRefStatus_struct xbraid/braid/_braid_status.h /^struct _braid_CoarsenRefStatus_struct$/;" s +_braid_CommHandle xbraid/braid/_braid.h /^} _braid_CommHandle;$/;" t typeref:struct:__anon2 +_braid_CommHandleElt xbraid/braid/_braid.h 307;" d +_braid_Core xbraid/braid/_braid.h /^} _braid_Core;$/;" t typeref:struct:_braid_Core_struct +_braid_CoreElt xbraid/braid/_braid.h 317;" d +_braid_CoreFcn xbraid/braid/_braid.h 322;" d +_braid_Core_struct xbraid/braid/_braid.h /^typedef struct _braid_Core_struct$/;" s +_braid_Error xbraid/braid/braid_defs.h 80;" d +_braid_ErrorInArg xbraid/braid/braid_defs.h 81;" d +_braid_Grid xbraid/braid/_braid.h /^} _braid_Grid;$/;" t typeref:struct:__anon3 +_braid_GridElt xbraid/braid/_braid.h 312;" d +_braid_HEADER xbraid/braid/_braid.h 32;" d +_braid_IsCPoint xbraid/braid/_braid.h 360;" d +_braid_IsFPoint xbraid/braid/_braid.h 354;" d +_braid_MapCoarseToFine xbraid/braid/_braid.h 348;" d +_braid_MapFineToCoarse xbraid/braid/_braid.h 341;" d +_braid_NextCPoint xbraid/braid/_braid.h 366;" d +_braid_ObjectiveStatus_struct xbraid/braid/_braid_status.h /^struct _braid_ObjectiveStatus_struct$/;" s +_braid_Optimization_struct xbraid/braid/_braid.h /^struct _braid_Optimization_struct$/;" s +_braid_PriorCPoint xbraid/braid/_braid.h 372;" d +_braid_Status xbraid/braid/_braid_status.h /^typedef struct _braid_Status_struct _braid_Status;$/;" t typeref:struct:_braid_Status_struct +_braid_StatusElt xbraid/braid/_braid_status.h 84;" d +_braid_Status_struct xbraid/braid/_braid_status.h /^struct _braid_Status_struct$/;" s +_braid_StepStatus_struct xbraid/braid/_braid_status.h /^struct _braid_StepStatus_struct$/;" s +_braid_TAlloc xbraid/braid/braid_defs.h 90;" d +_braid_TFree xbraid/braid/braid_defs.h 108;" d +_braid_TReAlloc xbraid/braid/braid_defs.h 102;" d +_braid_Tape xbraid/braid/_braid_tape.h /^} _braid_Tape;$/;" t typeref:struct:_braid_tape_struct +_braid_VectorBar_struct xbraid/braid/_braid.h /^struct _braid_VectorBar_struct$/;" s +_braid_base_HEADER xbraid/braid/_braid_base.h 40;" d +_braid_max xbraid/braid/braid_defs.h 116;" d +_braid_min xbraid/braid/braid_defs.h 119;" d +_braid_status_HEADER xbraid/braid/_braid_status.h 31;" d +_braid_tape_struct xbraid/braid/_braid_tape.h /^typedef struct _braid_tape_struct$/;" s +_filename pythonutil/config.py /^ _filename = 'config.cfg'$/;" v class:Config +_initialized pythonutil/ordered_bunch.py /^ _initialized = False$/;" v class:OrderedBunch +a xbraid/misc/user_utils/cycleplot.py /^ a = data[:,4].min()$/;" v +access xbraid/braid/_braid.h /^ braid_PtFcnAccess access; \/**< user access function to XBraid and current vector *\/$/;" m struct:_braid_Core_struct +access_level xbraid/braid/_braid.h /^ braid_Int access_level; \/**< determines how often to call the user's access routine *\/ $/;" m struct:_braid_Core_struct +access_level xbraid/drivers/braid_mfem.hpp /^ int access_level;$/;" m struct:BraidOptions +access_level xbraid/drivers/braid_mfem_block.hpp /^ int access_level;$/;" m struct:BraidOptions +access_level xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level, access_level,/;" v program:ex01_f90 +accuracy include/network.hpp /^ MyReal accuracy; \/* Accuracy of the network prediction (percentage of successfully predicted classes) *\/$/;" m class:Network +actionTape xbraid/braid/_braid.h /^ _braid_Tape* actionTape; \/**< tape storing the actions while recording *\/$/;" m struct:_braid_Core_struct +activ include/layer.hpp /^ int activ; \/* Activaation function (enum element) *\/$/;" m class:Layer +activation include/config.hpp /^ int activation;$/;" m class:Config +activation include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" g +adjoint xbraid/braid/_braid.h /^ braid_Int adjoint; \/**< determines if adjoint run is performed (1) or not (0) *\/$/;" m struct:_braid_Core_struct +adjoints xbraid/braid/_braid.h /^ braid_Vector *adjoints; \/**< vector for the adjoint variables *\/$/;" m struct:_braid_Optimization_struct +app xbraid/braid/_braid.h /^ braid_App app; \/**< application data for the user *\/$/;" m struct:_braid_Core_struct +app xbraid/examples/ex-01-expanded-f.f90 /^ type(my_app)/;" v program:ex01_f90 +arg xbraid/examples/ex-01-expanded-f.f90 /^ character (len = 255) arg$/;" v program:ex01_f90 +args testing/testing.py /^args = parser.parse_args()$/;" v +assemble_batch_script pythonutil/batch_job.py /^def assemble_batch_script(name, run_command, args):$/;" f +astatus xbraid/braid/braid.hpp /^ braid_AccessStatus astatus;$/;" m class:BraidAccessStatus +availIDs include/dataset.hpp /^ int* availIDs; \/* Auxilliary: holding available batchIDs when generating a batch *\/$/;" m class:DataSet +ax2 xbraid/misc/user_utils/cycleplot.py /^ ax2 = ax.twinx()$/;" v +bar xbraid/braid/_braid.h /^ braid_VectorBar bar; \/**< holds the bar vector (shared pointer implementation) *\/$/;" m struct:_braid_BaseVector_struct +barTape xbraid/braid/_braid.h /^ _braid_Tape* barTape; \/**< tape storing intermediate AD-bar variables while recording *\/$/;" m struct:_braid_Core_struct +batchIDs include/dataset.hpp /^ int *batchIDs; \/* Array of batch indicees *\/$/;" m class:DataSet +batch_args_mapping pythonutil/batch_job.py /^batch_args_mapping = batch_args_mapping_slurm$/;" v +batch_args_mapping_slurm pythonutil/batch_job.py /^batch_args_mapping_slurm = {"NAME" : "--job-name",$/;" v +batch_type include/config.hpp /^ int batch_type;$/;" m class:Config +batchtype include/config.hpp /^enum batchtype{DETERMINISTIC, STOCHASTIC};$/;" g +bias include/layer.hpp /^ MyReal* bias; \/* Bias *\/$/;" m class:Layer +bias_bar include/layer.hpp /^ MyReal* bias_bar; \/* Derivative of bias *\/$/;" m class:Layer +braidCall xbraid/braid/_braid_tape.h /^ _braid_Call braidCall; \/**< type of the user routine *\/$/;" m struct:_braid_Action_struct +braid_ASCaller_FAccess xbraid/braid/braid_status.h 525;" d +braid_ASCaller_FInterp xbraid/braid/braid_status.h 519;" d +braid_ASCaller_FRefine xbraid/braid/braid_status.h 523;" d +braid_ASCaller_FRestrict xbraid/braid/braid_status.h 521;" d +braid_AccessStatus xbraid/braid/braid_status.h /^typedef struct _braid_AccessStatus_struct *braid_AccessStatus;$/;" t typeref:struct:_braid_AccessStatus_struct +braid_Access_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Access_F90(/;" s +braid_App xbraid/braid/braid.h /^typedef struct _braid_App_struct *braid_App;$/;" t typeref:struct:_braid_App_struct +braid_BaseVector xbraid/braid/_braid.h /^typedef struct _braid_BaseVector_struct *braid_BaseVector;$/;" t typeref:struct:_braid_BaseVector_struct +braid_BufPack_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_BufPack_F90(/;" s +braid_BufSize_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_BufSize_F90(/;" s +braid_BufUnPack_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_BufUnPack_F90(/;" s +braid_BufferStatus xbraid/braid/braid_status.h /^typedef struct _braid_BufferStatus_struct *braid_BufferStatus;$/;" t typeref:struct:_braid_BufferStatus_struct +braid_Clone_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Clone_F90(/;" s +braid_CoarsenRefStatus xbraid/braid/braid_status.h /^typedef struct _braid_CoarsenRefStatus_struct *braid_CoarsenRefStatus;$/;" t typeref:struct:_braid_CoarsenRefStatus_struct +braid_Core xbraid/braid/braid.h /^typedef struct _braid_Core_struct *braid_Core;$/;" t typeref:struct:_braid_Core_struct +braid_ERROR_ARG xbraid/braid/braid.h 86;" d +braid_ERROR_GENERIC xbraid/braid/braid.h 84;" d +braid_ERROR_MEMORY xbraid/braid/braid.h 85;" d +braid_FMANGLE xbraid/braid/braid.h 62;" d +braid_Fortran_Residual xbraid/braid/braid.h 66;" d +braid_Fortran_SpatialCoarsen xbraid/braid/braid.h 64;" d +braid_Fortran_TimeGrid xbraid/braid/braid.h 68;" d +braid_Free_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Free_F90(/;" s +braid_HEADER xbraid/braid/braid.h 32;" d +braid_INVALID_RNORM xbraid/braid/braid.h 82;" d +braid_Init_Vec_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Init_Vec_F90(/;" s +braid_Int xbraid/braid/braid_defs.h /^typedef int braid_Int;$/;" t +braid_Int_Max xbraid/braid/braid_defs.h 50;" d +braid_Int_Min xbraid/braid/braid_defs.h 51;" d +braid_MPI_INT xbraid/braid/braid_defs.h 67;" d +braid_MPI_REAL xbraid/braid/braid_defs.h 66;" d +braid_ObjectiveStatus xbraid/braid/braid_status.h /^typedef struct _braid_ObjectiveStatus_struct *braid_ObjectiveStatus;$/;" t typeref:struct:_braid_ObjectiveStatus_struct +braid_Optim xbraid/braid/_braid.h /^typedef struct _braid_Optimization_struct *braid_Optim;$/;" t typeref:struct:_braid_Optimization_struct +braid_PtFcnAccess xbraid/braid/braid.h /^(*braid_PtFcnAccess)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnBufPack xbraid/braid/braid.h /^(*braid_PtFcnBufPack)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnBufSize xbraid/braid/braid.h /^(*braid_PtFcnBufSize)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnBufUnpack xbraid/braid/braid.h /^(*braid_PtFcnBufUnpack)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnClone xbraid/braid/braid.h /^(*braid_PtFcnClone)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnFree xbraid/braid/braid.h /^(*braid_PtFcnFree)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnInit xbraid/braid/braid.h /^(*braid_PtFcnInit)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnObjectiveT xbraid/braid/braid.h /^(*braid_PtFcnObjectiveT)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnObjectiveTDiff xbraid/braid/braid.h /^(*braid_PtFcnObjectiveTDiff)(braid_App app, \/**< input \/ output: user-defined _braid_App structure, used to store gradient *\/$/;" t +braid_PtFcnPostprocessObjective xbraid/braid/braid.h /^(*braid_PtFcnPostprocessObjective)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnPostprocessObjective_diff xbraid/braid/braid.h /^(*braid_PtFcnPostprocessObjective_diff)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnResetGradient xbraid/braid/braid.h /^(*braid_PtFcnResetGradient)(braid_App app \/**< output: user-defined _braid_App structure, used to store gradient *\/$/;" t +braid_PtFcnResidual xbraid/braid/braid.h /^(*braid_PtFcnResidual)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnSClone xbraid/braid/braid.h /^(*braid_PtFcnSClone)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnSCoarsen xbraid/braid/braid.h /^(*braid_PtFcnSCoarsen)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnSFree xbraid/braid/braid.h /^(*braid_PtFcnSFree)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnSInit xbraid/braid/braid.h /^(*braid_PtFcnSInit)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnSRefine xbraid/braid/braid.h /^(*braid_PtFcnSRefine)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnSpatialNorm xbraid/braid/braid.h /^(*braid_PtFcnSpatialNorm)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnStep xbraid/braid/braid.h /^(*braid_PtFcnStep)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnStepDiff xbraid/braid/braid.h /^(*braid_PtFcnStepDiff)(braid_App app, \/**< input \/ output: user-defined _braid_App structure, used to store gradient *\/$/;" t +braid_PtFcnSum xbraid/braid/braid.h /^(*braid_PtFcnSum)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_PtFcnTimeGrid xbraid/braid/braid.h /^(*braid_PtFcnTimeGrid)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t +braid_RAND_MAX xbraid/braid/braid_defs.h 129;" d +braid_Real xbraid/braid/braid_defs.h /^typedef double braid_Real;$/;" t +braid_Residual_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Residual_F90(/;" s +braid_SpatialNorm_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_SpatialNorm_F90(/;" s +braid_Status xbraid/braid/braid_status.h /^typedef struct _braid_Status_struct *braid_Status;$/;" t typeref:struct:_braid_Status_struct +braid_StepStatus xbraid/braid/braid_status.h /^typedef struct _braid_StepStatus_struct *braid_StepStatus;$/;" t typeref:struct:_braid_StepStatus_struct +braid_Step_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Step_F90(/;" s +braid_Sum_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Sum_F90(/;" s +braid_Vector xbraid/braid/braid.h /^typedef struct _braid_Vector_struct *braid_Vector;$/;" t typeref:struct:_braid_Vector_struct +braid_VectorBar xbraid/braid/_braid.h /^typedef struct _braid_VectorBar_struct *braid_VectorBar;$/;" t typeref:struct:_braid_VectorBar_struct +braid_abstol include/config.hpp /^ MyReal braid_abstol;$/;" m class:Config +braid_abstoladj include/config.hpp /^ MyReal braid_abstoladj;$/;" m class:Config +braid_accesslevel include/config.hpp /^ int braid_accesslevel;$/;" m class:Config +braid_cfactor include/config.hpp /^ int braid_cfactor;$/;" m class:Config +braid_cfactor0 include/config.hpp /^ int braid_cfactor0; $/;" m class:Config +braid_core xbraid/examples/ex-01-expanded-f.f90 /^ integer (kind=8) :: braid_core$/;" v module:braid_types +braid_fmg include/config.hpp /^ int braid_fmg;$/;" m class:Config +braid_hpp_HEADER xbraid/braid/braid.hpp 23;" d +braid_hypre_extra_HEADER xbraid/drivers/hypre_extra.hpp 23;" d +braid_isnan xbraid/braid/braid_defs.h 122;" d +braid_iter xbraid/braid/_braid_tape.h /^ braid_Int braid_iter; \/**< iteration number of xBraid *\/$/;" m struct:_braid_Action_struct +braid_iter xbraid/drivers/braid_mfem_block.hpp /^ int braid_iter;$/;" m class:MFEMBraidApp +braid_maxiter include/config.hpp /^ int braid_maxiter;$/;" m class:Config +braid_maxlevels include/config.hpp /^ int braid_maxlevels;$/;" m class:Config +braid_maxlevelslist testing/testing.py /^braid_maxlevelslist = args.maxlevels$/;" v +braid_mfem_HEADER xbraid/drivers/braid_mfem.hpp 23;" d +braid_mfem_HEADER xbraid/drivers/braid_mfem_block.hpp 23;" d +braid_mincoarse include/config.hpp /^ int braid_mincoarse;$/;" m class:Config +braid_nrelax include/config.hpp /^ int braid_nrelax;$/;" m class:Config +braid_nrelax0 include/config.hpp /^ int braid_nrelax0;$/;" m class:Config +braid_printlevel include/config.hpp /^ int braid_printlevel;$/;" m class:Config +braid_setskip include/config.hpp /^ int braid_setskip;$/;" m class:Config +braid_status_HEADER xbraid/braid/braid_status.h 32;" d +braid_tape_HEADER xbraid/braid/_braid_tape.h 8;" d +braid_test_HEADER xbraid/braid/braid_test.h 33;" d +braid_timegrid_f90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_timegrid_f90(/;" s +braid_types xbraid/examples/ex-01-expanded-f.f90 /^module braid_types$/;" m +braid_util_HEADER xbraid/braid/_util.h 34;" d +braiddefs_HEADER xbraid/braid/braid_defs.h 31;" d +bstatus xbraid/braid/braid.hpp /^ braid_BufferStatus bstatus;$/;" m class:BraidBufferStatus +buff_size xbraid/drivers/braid_mfem.hpp /^ Array buff_size;$/;" m class:MFEMBraidApp +buff_size xbraid/drivers/braid_mfem_block.hpp /^ Array buff_size;$/;" m class:MFEMBraidApp +buffer xbraid/braid/_braid.h /^ void *buffer; \/**< Buffer for message *\/$/;" m struct:__anon2 +bufpack xbraid/braid/_braid.h /^ braid_PtFcnBufPack bufpack; \/**< pack a buffer *\/$/;" m struct:_braid_Core_struct +bufsize xbraid/braid/_braid.h /^ braid_PtFcnBufSize bufsize; \/**< return buffer size *\/$/;" m struct:_braid_Core_struct +bufunpack xbraid/braid/_braid.h /^ braid_PtFcnBufUnpack bufunpack; \/**< unpack a buffer *\/$/;" m struct:_braid_Core_struct +c_tprior xbraid/braid/_braid.h /^ braid_Real c_tprior; \/**< time value to the left of tstart on coarse grid *\/$/;" m struct:_braid_Core_struct +c_tstop xbraid/braid/_braid.h /^ braid_Real c_tstop; \/**< time value to the right of tstart on coarse grid *\/$/;" m struct:_braid_Core_struct +calling_function xbraid/braid/_braid.h /^ braid_Int calling_function; \/**< from which function are we accessing the vector *\/$/;" m struct:_braid_Core_struct +case testing/testing.py /^case = args.case$/;" v +cfactor xbraid/braid/_braid.h /^ braid_Int cfactor; \/**< coarsening factor *\/$/;" m struct:__anon3 +cfactor xbraid/drivers/braid_mfem.hpp /^ int cfactor;$/;" m struct:BraidOptions +cfactor xbraid/drivers/braid_mfem_block.hpp /^ int cfactor;$/;" m struct:BraidOptions +cfactor xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax, nrelax0, cfactor,/;" v program:ex01_f90 +cfactor0 xbraid/drivers/braid_mfem.hpp /^ int cfactor0;$/;" m struct:BraidOptions +cfactor0 xbraid/drivers/braid_mfem_block.hpp /^ int cfactor0;$/;" m struct:BraidOptions +cfactor0 xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax, nrelax0, cfactor, cfactor0$/;" v program:ex01_f90 +cfactors xbraid/braid/_braid.h /^ braid_Int *cfactors; \/**< coarsening factors *\/$/;" m struct:_braid_Core_struct +cfdefault xbraid/braid/_braid.h /^ braid_Int cfdefault; \/**< default coarsening factor *\/$/;" m struct:_braid_Core_struct +clear pythonutil/ordered_dict.py /^ def clear(self):$/;" m class:OrderedDict +clone xbraid/braid/_braid.h /^ braid_PtFcnClone clone; \/**< clone a vector *\/$/;" m struct:_braid_Core_struct +clone xbraid/drivers/braid_mfem.hpp /^ BraidVector *clone()$/;" f class:BraidVector +clone xbraid/drivers/braid_mfem_block.hpp /^ BraidVector *clone()$/;" f class:BraidVector +clower xbraid/braid/_braid.h /^ braid_Int clower; \/**< smallest C point index *\/$/;" m struct:__anon3 +comm include/network.hpp /^ MPI_Comm comm; \/* MPI communicator *\/$/;" m class:Network +comm xbraid/braid/_braid.h /^ MPI_Comm comm; \/**< communicator for the time dimension *\/$/;" m struct:_braid_Core_struct +comm xbraid/drivers/mfem_arnoldi.hpp /^ MPI_Comm comm;$/;" m class:Arnoldi +comm xbraid/examples/ex-01-expanded-f.f90 /^ integer :: comm$/;" k type:my_app +comm_t xbraid/braid/braid.hpp /^ MPI_Comm comm_t;$/;" m class:BraidApp +comm_world xbraid/braid/_braid.h /^ MPI_Comm comm_world;$/;" m struct:_braid_Core_struct +comparefiles pythonutil/util.py /^def comparefiles(refname, testname):$/;" f +config testing/testing.py /^config = Config(case + ".cfg")$/;" v +config_option include/config.hpp /^ struct config_option {$/;" s class:Config +configfile examples/mnist/mnist_runs/submit_paramstudy.py /^configfile = Config("config.cfg")$/;" v +configfile pythonutil/submit_paramstudy.py /^configfile = Config("config.cfg")$/;" v +copy pythonutil/ordered_dict.py /^ def copy(self):$/;" m class:OrderedDict +core include/braid_wrapper.hpp /^ BraidCore* core; \/* Braid core for running PinT simulation *\/$/;" m class:myBraidApp +core xbraid/braid/_braid_status.h /^ _braid_Core core;$/;" m struct:_braid_Status_struct +core xbraid/braid/_braid_tape.h /^ braid_Core core; \/**< pointer to braid's core structure *\/$/;" m struct:_braid_Action_struct +core xbraid/braid/braid.hpp /^ braid_Core core;$/;" m class:BraidCore +csize include/layer.hpp /^ int csize;$/;" m class:Layer +csize2 include/layer.hpp /^ int csize2;$/;" m class:ConvLayer +cstatus xbraid/braid/braid.hpp /^ braid_CoarsenRefStatus cstatus;$/;" m class:BraidCoarsenRefStatus +cupper xbraid/braid/_braid.h /^ braid_Int cupper; \/**< largest C point index *\/$/;" m struct:__anon3 +current_lvl xbraid/misc/user_utils/cycleplot.py /^ current_lvl = 0$/;" v +current_lvl xbraid/misc/user_utils/cycleplot.py /^ current_lvl = data[-1,0]$/;" v +current_rank xbraid/examples/viz-ex-02.py /^ current_rank = current_rank + 1$/;" v +current_rank xbraid/examples/viz-ex-02.py /^current_rank = 0$/;" v +current_rank xbraid/examples/viz-ex-04.py /^ current_rank = current_rank + 1$/;" v +current_rank xbraid/examples/viz-ex-04.py /^ current_rank = 0$/;" v +cycleplot xbraid/misc/user_utils/cycleplot.m /^function cycleplot(filename);$/;" f +data include/braid_wrapper.hpp /^ DataSet* data; \/* Pointer to the Data set *\/$/;" m class:myBraidApp +data xbraid/drivers/viz-burgers-1D.py /^data = loadtxt(fname)$/;" v +data xbraid/drivers/viz-burgers-1D.py /^data = zeros((nsteps,data.shape[0]-6))$/;" v +data xbraid/drivers/viz-lorenz.py /^data = numpy.loadtxt('drive-lorenz.out')$/;" v +data xbraid/examples/viz-ex-02.py /^data = loadtxt(fname)$/;" v +data xbraid/examples/viz-ex-02.py /^data = zeros((nsteps,data.shape[0]-6))$/;" v +data xbraid/misc/user_utils/cycleplot.py /^ data = loadtxt(fname)$/;" v +data_ptr xbraid/braid/_braid_tape.h /^ void *data_ptr;$/;" m struct:_braid_tape_struct +datafolder examples/mnist/mnist_runs/submit_paramstudy.py /^datafolder = "data"$/;" v +datafolder include/config.hpp /^ const char* datafolder; $/;" m class:Config +datafolder pythonutil/submit_paramstudy.py /^datafolder = "data"$/;" v +datafolder testing/testing.py /^ datafolder = "..\/" + config.datafolder$/;" v +default_batch_args pythonutil/batch_job.py /^default_batch_args = {batch_args_mapping["NAME"] : "default",$/;" v +design include/network.hpp /^ MyReal* design; \/* Local vector of design variables*\/$/;" m class:Network +design xbraid/examples/viz-ex-04.py /^design = loadtxt('ex-04.out.design')$/;" v +design_old include/hessianApprox.hpp /^ MyReal* design_old; \/* Design at previous iteration *\/$/;" m class:L_BFGS +design_old include/hessianApprox.hpp /^ MyReal* design_old; \/* Design at previous iteration *\/$/;" m class:BFGS +dimN include/hessianApprox.hpp /^ int dimN; \/* Dimension of the gradient vector *\/$/;" m class:HessianApprox +dim_Bias include/layer.hpp /^ int dim_Bias; \/* Dimension of the bias vector *\/$/;" m class:Layer +dim_In include/layer.hpp /^ int dim_In; \/* Dimension of incoming data *\/$/;" m class:Layer +dim_Out include/layer.hpp /^ int dim_Out; \/* Dimension of outgoing data *\/$/;" m class:Layer +done xbraid/braid/_braid.h /^ braid_Int done; \/**< boolean describing whether XBraid has finished *\/$/;" m struct:_braid_Core_struct +dr xbraid/misc/user_utils/cycleplot.py /^ dr = r[:-1] - r[1:]$/;" v +dt include/layer.hpp /^ MyReal dt; \/* Step size for Layer update *\/$/;" m class:Layer +dt include/network.hpp /^ MyReal dt; \/* Time step size *\/$/;" m class:Network +dt xbraid/examples/ex-01-expanded-f.f90 /^ double precision, allocatable :: dt(/;" k type:my_app +dump pythonutil/config.py /^ def dump(self,filename=''):$/;" m class:Config +dump_config pythonutil/config.py /^def dump_config(filename,config):$/;" f +endlayerID include/network.hpp /^ int endlayerID; \/* ID of the last layer on that processor *\/$/;" m class:Network +err testing/testing.py /^ err = comparefiles(refname, testfoldername + "\/" + outfile)$/;" v +ex01_f90 xbraid/examples/ex-01-expanded-f.f90 /^program ex01_f90$/;" p +exact_sol xbraid/drivers/braid_mfem.hpp /^ Coefficient *exact_sol;$/;" m class:MFEMBraidApp +exact_sol xbraid/drivers/braid_mfem_block.hpp /^ Coefficient *exact_sol;$/;" m class:MFEMBraidApp +example include/layer.hpp /^ MyReal* example; \/* Pointer to the current example data *\/$/;" m class:OpenExpandZero +example include/layer.hpp /^ MyReal* example; \/* Pointer to the current example data *\/$/;" m class:OpenConvLayer +example include/layer.hpp /^ MyReal* example; \/* Pointer to the current example data *\/$/;" m class:OpenDenseLayer +examples include/dataset.hpp /^ MyReal **examples; \/* Array of Feature vectors (dim: nelements x nfeatures) *\/$/;" m class:DataSet +f_bar xbraid/braid/_braid.h /^ braid_Real f_bar; \/**< contains the seed for tape evaluation *\/$/;" m struct:_braid_Optimization_struct +f_tprior xbraid/braid/_braid.h /^ braid_Real f_tprior; \/**< time value to the left of tstart on fine grid *\/$/;" m struct:_braid_Core_struct +f_tstop xbraid/braid/_braid.h /^ braid_Real f_tstop; \/**< time value to the right of tstart on fine grid *\/$/;" m struct:_braid_Core_struct +fa xbraid/braid/_braid.h /^ braid_BaseVector *fa; \/**< rhs vectors f (all points, NULL on level 0) *\/$/;" m struct:__anon3 +fa_alloc xbraid/braid/_braid.h /^ braid_BaseVector *fa_alloc; \/**< original memory allocation for fa *\/$/;" m struct:__anon3 +fcsize include/layer.hpp /^ int fcsize;$/;" m class:ConvLayer +fe_space xbraid/drivers/braid_mfem.hpp /^ Array fe_space;$/;" m class:MFEMBraidApp +fe_space xbraid/drivers/braid_mfem_block.hpp /^ Array fe_space;$/;" m class:MFEMBraidApp +fig_size xbraid/misc/user_utils/cycleplot.py /^ fig_size = [niter*1.7, nlevels*1.0]$/;" v +file_stem xbraid/drivers/viz-burgers-1D.py /^file_stem = 'drive-burgers-1D.out.'$/;" v +file_stem xbraid/examples/viz-ex-02.py /^file_stem = 'ex-02.out.'$/;" v +file_stem xbraid/examples/viz-ex-04.py /^ file_stem = "ex-04.out."$/;" v +fmg xbraid/braid/_braid.h /^ braid_Int fmg; \/**< use FMG cycle *\/$/;" m struct:_braid_Core_struct +fmg xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg,/;" v program:ex01_f90 +fname xbraid/drivers/viz-burgers-1D.py /^ fname = file_stem + "%07d"%step + '.' + "%05d"%rank$/;" v +fname xbraid/drivers/viz-burgers-1D.py /^fname = file_stem + "%07d"%step + '.' + "%05d"%rank$/;" v +fname xbraid/examples/viz-ex-02.py /^ fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank$/;" v +fname xbraid/examples/viz-ex-02.py /^fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank$/;" v +fname xbraid/examples/viz-ex-04.py /^ fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank$/;" v +fname xbraid/misc/user_utils/cycleplot.py /^ fname = "braid.out.cycle"$/;" v +fontsize xbraid/misc/user_utils/cycleplot.py /^ fontsize = 22$/;" v +free xbraid/braid/_braid.h /^ braid_PtFcnFree free; \/**< free up a vector *\/$/;" m struct:_braid_Core_struct +fromOrderedDict pythonutil/ordered_bunch.py /^ def fromOrderedDict(d):$/;" m class:OrderedBunch +fromYAML pythonutil/ordered_bunch.py /^ def fromYAML(*args, **kwargs):$/;" f +from_yaml pythonutil/ordered_bunch.py /^ def from_yaml(loader, node):$/;" f +fromkeys pythonutil/ordered_dict.py /^ def fromkeys(cls, iterable, value=None):$/;" m class:OrderedDict +ftrain_ex include/config.hpp /^ const char* ftrain_ex;$/;" m class:Config +ftrain_labels include/config.hpp /^ const char* ftrain_labels;$/;" m class:Config +full_rnorm0 xbraid/braid/_braid.h /^ braid_Real full_rnorm0; \/**< (optional) initial full residual norm *\/$/;" m struct:_braid_Core_struct +full_rnorm_res xbraid/braid/_braid.h /^ braid_PtFcnResidual full_rnorm_res; \/**< (optional) used to compute full residual norm *\/$/;" m struct:_braid_Core_struct +full_rnorms xbraid/braid/_braid.h /^ braid_Real *full_rnorms; \/**< (optional) full residual norm history *\/$/;" m struct:_braid_Core_struct +fval_ex include/config.hpp /^ const char* fval_ex;$/;" m class:Config +fval_labels include/config.hpp /^ const char* fval_labels;$/;" m class:Config +gamma_class include/config.hpp /^ MyReal gamma_class;$/;" m class:Config +gamma_ddt include/config.hpp /^ MyReal gamma_ddt;$/;" m class:Config +gamma_ddt include/layer.hpp /^ MyReal gamma_ddt; \/* Parameter for DDT regularization of weights and bias *\/$/;" m class:Layer +gamma_tik include/config.hpp /^ MyReal gamma_tik;$/;" m class:Config +gamma_tik include/layer.hpp /^ MyReal gamma_tik; \/* Parameter for Tikhonov regularization of weights and bias *\/$/;" m class:Layer +gammaclass examples/mnist/mnist_runs/submit_paramstudy.py /^gammaclass = [1e-1,1e-3,1e-5]$/;" v +gammaclass pythonutil/submit_paramstudy.py /^gammaclass = [1e-1, 1e-5]$/;" v +gammaddt examples/mnist/mnist_runs/submit_paramstudy.py /^gammaddt = [1e-1,1e-3,1e-5]$/;" v +gammaddt pythonutil/submit_paramstudy.py /^gammaddt = [1e-5]$/;" v +gammatik examples/mnist/mnist_runs/submit_paramstudy.py /^gammatik = [1e-1,1e-3,1e-5]$/;" v +gammatik pythonutil/submit_paramstudy.py /^gammatik = [1e-5]$/;" v +globaltime xbraid/braid/_braid.h /^ braid_Real globaltime; \/**< global wall time for braid_Drive() *\/$/;" m struct:_braid_Core_struct +gradient include/network.hpp /^ MyReal* gradient; \/* Local Gradient *\/$/;" m class:Network +gradient_old include/hessianApprox.hpp /^ MyReal* gradient_old; \/* Gradient at previous iteration *\/$/;" m class:L_BFGS +gradient_old include/hessianApprox.hpp /^ MyReal* gradient_old; \/* Gradient at previous iteration *\/$/;" m class:BFGS +grids xbraid/braid/_braid.h /^ _braid_Grid **grids; \/**< pointer to temporal grid structures for each level*\/$/;" m struct:_braid_Core_struct +gtol include/config.hpp /^ MyReal gtol;$/;" m class:Config +guess xbraid/drivers/braid_mfem_block.hpp /^ BlockVector *guess; $/;" m class:MFEMBraidApp +gupper xbraid/braid/_braid.h /^ braid_Int gupper; \/**< global size of the fine grid *\/$/;" m struct:_braid_Core_struct +gupper xbraid/braid/_braid.h /^ braid_Int gupper; \/**< global size of the grid *\/$/;" m struct:__anon3 +gupper xbraid/braid/_braid_tape.h /^ braid_Int gupper; \/**< global size of the fine grid *\/$/;" m struct:_braid_Action_struct +hessianapprox_type include/config.hpp /^ int hessianapprox_type;$/;" m class:Config +hessiantype include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" g +hypre xbraid/drivers/hypre_extra.hpp /^namespace hypre$/;" n +hypre_CSRMatrixSetConstantValues xbraid/drivers/hypre_extra.hpp /^ hypre_CSRMatrixSetConstantValues( hypre_CSRMatrix *A,$/;" f namespace:hypre +hypre_CSRMatrixSum xbraid/drivers/hypre_extra.hpp /^ hypre_CSRMatrixSum( hypre_CSRMatrix *A,$/;" f namespace:hypre +hypre_ParCSRMatrixAdd xbraid/drivers/hypre_extra.hpp /^ hypre_ParCSRMatrixAdd( hypre_ParCSRMatrix *A,$/;" f namespace:hypre +hypre_ParCSRMatrixSetConstantValues xbraid/drivers/hypre_extra.hpp /^ hypre_ParCSRMatrixSetConstantValues( hypre_ParCSRMatrix *A,$/;" f namespace:hypre +hypre_ParCSRMatrixSum xbraid/drivers/hypre_extra.hpp /^ hypre_ParCSRMatrixSum( hypre_ParCSRMatrix *A,$/;" f namespace:hypre +i xbraid/examples/ex-01-expanded-f.f90 /^ in/;" v program:ex01_f90 +idx xbraid/braid/_braid.h /^ braid_Int idx; \/**< time point index value corresponding to t on the global time grid *\/$/;" m struct:_braid_Core_struct +ierr xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr,/;" v program:ex01_f90 +ilower xbraid/braid/_braid.h /^ braid_Int ilower; \/**< smallest time index at this level*\/$/;" m struct:__anon3 +img_size include/layer.hpp /^ int img_size;$/;" m class:ConvLayer +img_size_sqrt include/layer.hpp /^ int img_size_sqrt;$/;" m class:ConvLayer +inTime xbraid/braid/_braid_tape.h /^ braid_Real inTime; \/**< time of the input vector *\/$/;" m struct:_braid_Action_struct +inTimeIdx xbraid/braid/_braid_tape.h /^ braid_Int inTimeIdx; \/**< index of time of input vector *\/$/;" m struct:_braid_Action_struct +index include/layer.hpp /^ int index; \/* Number of the layer *\/$/;" m class:Layer +inf pythonutil/config.py /^inf = 1.0e20$/;" v +init xbraid/braid/_braid.h /^ braid_PtFcnInit init; \/**< return an initialized braid_BaseVector *\/$/;" m struct:_braid_Core_struct +init_rand xbraid/drivers/braid_mfem.hpp /^ bool init_rand; \/* If true, use std::rand() to initialize BraidVectors in$/;" m class:MFEMBraidApp +init_timesteps xbraid/examples/ex-01-expanded-f.f90 /^subroutine init_timesteps(/;" s +interactive xbraid/misc/user_utils/cycleplot.py /^ interactive = 0$/;" v +interactive xbraid/misc/user_utils/cycleplot.py /^ interactive = float(argv[1])$/;" v +io_level xbraid/braid/_braid.h /^ braid_Int io_level; \/**< determines amount of output printed to files (0,1) *\/$/;" m struct:_braid_Core_struct +items pythonutil/ordered_dict.py /^ def items(self):$/;" m class:OrderedDict +iteritems pythonutil/ordered_dict.py /^ def iteritems(self):$/;" m class:OrderedDict +iterkeys pythonutil/ordered_dict.py /^ def iterkeys(self):$/;" m class:OrderedDict +itervalues pythonutil/ordered_dict.py /^ def itervalues(self):$/;" m class:OrderedDict +iupper xbraid/braid/_braid.h /^ braid_Int iupper; \/**< largest time index at this level*\/$/;" m struct:__anon3 +jobname examples/mnist/mnist_runs/submit_paramstudy.py /^ "-class" + str(konfig.gamma_class)$/;" v +jobname pythonutil/submit_paramstudy.py /^ "class" + str(konfig.gamma_class)$/;" v +k_max xbraid/drivers/mfem_arnoldi.hpp /^ int k_max;$/;" m class:Arnoldi +key include/config.hpp /^ char key[CONFIG_ARG_MAX_BYTES];$/;" m struct:Config::config_option +keys pythonutil/ordered_dict.py /^ def keys(self):$/;" m class:OrderedDict +konfig examples/mnist/mnist_runs/submit_paramstudy.py /^ konfig = copy.deepcopy(configfile)$/;" v +konfig pythonutil/submit_paramstudy.py /^ konfig = copy.deepcopy(configfile)$/;" v +konfig testing/testing.py /^ konfig = copy.deepcopy(config)$/;" v +label include/layer.hpp /^ MyReal* label; \/* Pointer to the current label vector *\/$/;" m class:ClassificationLayer +labels include/dataset.hpp /^ MyReal **labels; \/* Array of Label vectors (dim: nelements x nlabels) *\/$/;" m class:DataSet +layer include/braid_wrapper.hpp /^ Layer* layer; \/* Pointer to layer information *\/$/;" m class:myBraidVector +layer_left include/network.hpp /^ Layer* layer_left; \/* Copy of last layer of left-neighbouring processor *\/$/;" m class:Network +layer_right include/network.hpp /^ Layer* layer_right; \/* Copy of first layer of right-neighbouring processor *\/$/;" m class:Network +layers include/network.hpp /^ Layer** layers; \/* Array of hidden layers (includes classification layer at last processor *\/$/;" m class:Network +layertype include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" g class:Layer +lbfgs_stages include/config.hpp /^ int lbfgs_stages;$/;" m class:Config +level xbraid/braid/_braid.h /^ braid_Int level; \/**< Level that grid is on *\/$/;" m struct:__anon3 +level xbraid/braid/_braid.h /^ braid_Int level; \/**< current level in XBraid*\/$/;" m struct:_braid_Core_struct +level xbraid/braid/_braid_tape.h /^ braid_Int level; \/**< current level in Braid *\/$/;" m struct:_braid_Action_struct +level xbraid/drivers/braid_mfem.hpp /^ int level;$/;" m class:BraidVector +level xbraid/misc/user_utils/cycleplot.py /^ level = -level$/;" v +level xbraid/misc/user_utils/cycleplot.py /^ level = data[:,0] - data[:,1]$/;" v +localtime xbraid/braid/_braid.h /^ braid_Real localtime; \/**< local wall time for braid_Drive() *\/$/;" m struct:_braid_Core_struct +loss include/network.hpp /^ MyReal loss; \/* Value of the loss function *\/$/;" m class:Network +ls_factor include/config.hpp /^ MyReal ls_factor;$/;" m class:Config +ls_maxiter include/config.hpp /^ int ls_maxiter;$/;" m class:Config +ma xbraid/misc/user_utils/cycleplot.py /^ ma = r_to_print.max()$/;" v +make_link pythonutil/util.py /^def make_link(src,dst):$/;" f +match pythonutil/switch.py /^ def match(self, *args):$/;" m class:switch +maxBlocks xbraid/drivers/braid_mfem_block.hpp /^ static const int maxBlocks = 2;$/;" m class:MFEMBraidApp +max_dt xbraid/drivers/braid_mfem.hpp /^ Array max_dt; \/\/ maximal safe dt on each spatial mesh$/;" m class:MFEMBraidApp +max_dt xbraid/drivers/braid_mfem_block.hpp /^ Array max_dt; \/\/ maximal safe dt on each spatial mesh$/;" m class:MFEMBraidApp +max_iter xbraid/braid/_braid.h /^ braid_Int max_iter; \/**< maximum number of multigrid in time iterations *\/$/;" m struct:_braid_Core_struct +max_iter xbraid/drivers/braid_mfem.hpp /^ int max_iter;$/;" m struct:BraidOptions +max_iter xbraid/drivers/braid_mfem_block.hpp /^ int max_iter;$/;" m struct:BraidOptions +max_iter xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter,/;" v program:ex01_f90 +max_levels xbraid/braid/_braid.h /^ braid_Int max_levels; \/**< maximum number of temporal grid levels *\/$/;" m struct:_braid_Core_struct +max_levels xbraid/drivers/braid_mfem.hpp /^ int max_levels;$/;" m class:SpaceTimeMeshInfo +max_levels xbraid/drivers/braid_mfem.hpp /^ int max_levels;$/;" m struct:BraidOptions +max_levels xbraid/drivers/braid_mfem_block.hpp /^ int max_levels;$/;" m class:SpaceTimeMeshInfo +max_levels xbraid/drivers/braid_mfem_block.hpp /^ int max_levels;$/;" m struct:BraidOptions +max_levels xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels,/;" v program:ex01_f90 +max_refinements xbraid/braid/_braid.h /^ braid_Int max_refinements; \/**< maximum number of refinements *\/$/;" m struct:_braid_Core_struct +maxl xbraid/misc/user_utils/cycleplot.py /^ maxl = max(level)$/;" v +maxoptimiter include/config.hpp /^ int maxoptimiter;$/;" m class:Config +mesh xbraid/drivers/braid_mfem.hpp /^ Array mesh;$/;" m class:MFEMBraidApp +mesh xbraid/drivers/braid_mfem_block.hpp /^ Array mesh;$/;" m class:MFEMBraidApp +mesh xbraid/drivers/viz-burgers-1D.py /^mesh = linspace(xstart, xstop, nspace)$/;" v +mesh xbraid/examples/viz-ex-02.py /^mesh = linspace(xstart, xstop, nspace)$/;" v +mesh_file xbraid/drivers/braid_mfem.hpp /^ const char *mesh_file;$/;" m struct:BraidOptions +mesh_file xbraid/drivers/braid_mfem_block.hpp /^ const char *mesh_file;$/;" m struct:BraidOptions +mesh_table xbraid/drivers/braid_mfem.hpp /^ Array mesh_table;$/;" m class:SpaceTimeMeshInfo +mesh_table xbraid/drivers/braid_mfem_block.hpp /^ Array mesh_table;$/;" m class:SpaceTimeMeshInfo +mesh_table_global xbraid/drivers/braid_mfem.hpp /^ Array mesh_table_global;$/;" m class:SpaceTimeMeshInfo +mesh_table_global xbraid/drivers/braid_mfem_block.hpp /^ Array mesh_table_global;$/;" m class:SpaceTimeMeshInfo +messagetype xbraid/braid/_braid.h /^ braid_Int messagetype; \/**< message type, 0: for Step(), 1: for load balancing *\/$/;" m struct:_braid_Core_struct +messagetype xbraid/braid/_braid_tape.h /^ braid_Int messagetype; \/**< message type, 0: for Step(), 1: for load balancing *\/$/;" m struct:_braid_Action_struct +mfem xbraid/drivers/braid_mfem_block.hpp /^namespace mfem$/;" n +mfem_arnoldi_HEADER xbraid/drivers/mfem_arnoldi.hpp 2;" d +mi xbraid/misc/user_utils/cycleplot.py /^ mi = min( tols[tols>0].min()\/500., r_to_print.min())$/;" v +min_coarse xbraid/braid/_braid.h /^ braid_Int min_coarse; \/**< minimum possible coarse grid size *\/$/;" m struct:_braid_Core_struct +min_coarse xbraid/drivers/braid_mfem.hpp /^ int min_coarse;$/;" m struct:BraidOptions +min_coarse xbraid/drivers/braid_mfem_block.hpp /^ int min_coarse;$/;" m struct:BraidOptions +min_coarse xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse,/;" v program:ex01_f90 +minl xbraid/misc/user_utils/cycleplot.py /^ minl = maxl - nlevels$/;" v +myAdjointBraidApp include/braid_wrapper.hpp /^class myAdjointBraidApp : public myBraidApp$/;" c +myBraidApp include/braid_wrapper.hpp /^class myBraidApp : public BraidApp$/;" c +myBraidVector include/braid_wrapper.hpp /^class myBraidVector $/;" c +my_app xbraid/examples/ex-01-expanded-f.f90 /^ type my_app$/;" t module:braid_types +my_vector xbraid/examples/ex-01-expanded-f.f90 /^ type my_vector$/;" t module:braid_types +mydt xbraid/examples/ex-01-expanded-f.f90 /^ integer :: mydt$/;" k type:my_app +mydt xbraid/examples/ex-01-expanded-f.f90 /^ integer mydt,/;" v program:ex01_f90 +myid include/braid_wrapper.hpp /^ int myid; \/* Processor rank*\/$/;" m class:myBraidApp +myid xbraid/braid/_braid.h /^ braid_Int myid; \/**< my rank in the time communicator *\/$/;" m struct:_braid_Core_struct +myid xbraid/braid/_braid_tape.h /^ braid_Int myid; \/**< processors id *\/$/;" m struct:_braid_Action_struct +myid_world xbraid/braid/_braid.h /^ braid_Int myid_world; \/**< my rank in the world communicator *\/$/;" m struct:_braid_Core_struct +navail include/dataset.hpp /^ int navail; \/* Auxilliary: holding number of currently available batchIDs *\/$/;" m class:DataSet +nbatch include/braid_wrapper.hpp /^ int nbatch; \/* Number of examples *\/$/;" m class:myBraidVector +nbatch include/config.hpp /^ int nbatch;$/;" m class:Config +nbatch include/dataset.hpp /^ int nbatch; \/* Size of the batch *\/$/;" m class:DataSet +nchannels include/braid_wrapper.hpp /^ int nchannels; \/* Number of channels *\/$/;" m class:myBraidVector +nchannels include/config.hpp /^ int nchannels;$/;" m class:Config +nchannels include/network.hpp /^ int nchannels; \/* Width of the network *\/$/;" m class:Network +nclasses include/config.hpp /^ int nclasses;$/;" m class:Config +nconv include/layer.hpp /^ int nconv;$/;" m class:Layer +ncpoints xbraid/braid/_braid.h /^ braid_Int ncpoints; \/**< number of C points *\/$/;" m struct:__anon3 +ndesign include/layer.hpp /^ int ndesign; \/* Total number of design variables *\/$/;" m class:Layer +ndesign_global include/network.hpp /^ int ndesign_global; \/* Global number of design vars *\/$/;" m class:Network +ndesign_layermax include/network.hpp /^ int ndesign_layermax; \/* Max. number of design variables of all hidden layers *\/$/;" m class:Network +ndesign_local include/network.hpp /^ int ndesign_local; \/* Number of design vars of this local network block *\/$/;" m class:Network +nelements include/dataset.hpp /^ int nelements; \/* Number of data elements *\/$/;" m class:DataSet +network include/braid_wrapper.hpp /^ Network* network; \/* Pointer to the DNN Network Block (local layer storage) *\/$/;" m class:myBraidApp +networkType include/config.hpp /^enum networkType{DENSE, CONVOLUTIONAL}; $/;" g +network_type include/config.hpp /^ int network_type;$/;" m class:Config +new_iterations xbraid/misc/user_utils/cycleplot.py /^ new_iterations = (level == maxl).nonzero()[0]$/;" v +new_iterations xbraid/misc/user_utils/cycleplot.py /^ new_iterations = new_iterations[ ((new_iterations[1:] - new_iterations[:-1]) != 1).nonzero()[0] ]$/;" v +newconfigfile examples/mnist/mnist_runs/submit_paramstudy.py /^ newconfigfile = jobname + ".cfg"$/;" v +newconfigfile pythonutil/submit_paramstudy.py /^ newconfigfile = jobname + ".cfg"$/;" v +next xbraid/braid/_braid_tape.h /^ struct _braid_tape_struct *next;$/;" m struct:_braid_tape_struct typeref:struct:_braid_tape_struct::_braid_tape_struct +nfeatures include/config.hpp /^ int nfeatures;$/;" m class:Config +nfeatures include/dataset.hpp /^ int nfeatures; \/* Number of features per element *\/$/;" m class:DataSet +nfmg xbraid/braid/_braid.h /^ braid_Int nfmg; \/**< number of fmg cycles to do initially before switching to V-cycles *\/$/;" m struct:_braid_Core_struct +nfmg xbraid/drivers/braid_mfem_block.hpp /^ int nfmg;$/;" m struct:BraidOptions +nfmg_Vcyc xbraid/braid/_braid.h /^ braid_Int nfmg_Vcyc; \/**< number of V-cycle calls at each level in FMG *\/$/;" m struct:_braid_Core_struct +nfmg_Vcyc xbraid/drivers/braid_mfem.hpp /^ int nfmg_Vcyc;$/;" m struct:BraidOptions +nfmg_Vcyc xbraid/drivers/braid_mfem_block.hpp /^ int nfmg_Vcyc;$/;" m struct:BraidOptions +nfmg_Vcyc xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level, access_level, nfmg_Vcyc,/;" v program:ex01_f90 +niter xbraid/braid/_braid.h /^ braid_Int niter; \/**< number of iterations *\/$/;" m struct:_braid_Core_struct +niter xbraid/misc/user_utils/cycleplot.py /^ niter = data[:,2].max()$/;" v +niter xbraid/misc/user_utils/cycleplot.py /^ niter = max(niter_max, data[:,2].max())$/;" v +niter_max xbraid/misc/user_utils/cycleplot.py /^ niter_max = 12$/;" v +niter_max xbraid/misc/user_utils/cycleplot.py /^ niter_max = int(argv[2])$/;" v +nlabels include/dataset.hpp /^ int nlabels; \/* Number of different labels (i.e. classes) per element *\/$/;" m class:DataSet +nlayers include/config.hpp /^ int nlayers;$/;" m class:Config +nlayers_global include/network.hpp /^ int nlayers_global; \/* Total number of Layers of the network *\/$/;" m class:Network +nlayers_local include/network.hpp /^ int nlayers_local; \/* Number of Layers in this network block *\/$/;" m class:Network +nlevel_max xbraid/misc/user_utils/cycleplot.py /^ nlevel_max = 5$/;" v +nlevel_max xbraid/misc/user_utils/cycleplot.py /^ nlevel_max = int(argv[3])$/;" v +nlevels xbraid/braid/_braid.h /^ braid_Int nlevels; \/**< number of temporal grid levels *\/$/;" m struct:_braid_Core_struct +nlevels xbraid/misc/user_utils/cycleplot.py /^ nlevels = data[:,0].max() - data[:,0].min()$/;" v +nlevels xbraid/misc/user_utils/cycleplot.py /^ nlevels = max(nlevel_max, data[:,0].max() - data[:,0].min())$/;" v +npt examples/mnist/mnist_runs/submit_paramstudy.py /^npt = 2 # number of processors$/;" v +npt pythonutil/submit_paramstudy.py /^npt = 2 # number of processors$/;" v +nptlist testing/testing.py /^nptlist = args.nprocs$/;" v +nrdefault xbraid/braid/_braid.h /^ braid_Int nrdefault; \/**< default number of pre-relaxations *\/$/;" m struct:_braid_Core_struct +nrefine xbraid/braid/_braid.h /^ braid_Int nrefine; \/**< number of refinements done *\/$/;" m struct:_braid_Core_struct +nrefine xbraid/braid/_braid_tape.h /^ braid_Int nrefine; \/**< number of refinements done *\/$/;" m struct:_braid_Action_struct +nrelax xbraid/drivers/braid_mfem.hpp /^ int nrelax;$/;" m struct:BraidOptions +nrelax xbraid/drivers/braid_mfem_block.hpp /^ int nrelax;$/;" m struct:BraidOptions +nrelax xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax,/;" v program:ex01_f90 +nrelax0 xbraid/drivers/braid_mfem.hpp /^ int nrelax0;$/;" m struct:BraidOptions +nrelax0 xbraid/drivers/braid_mfem_block.hpp /^ int nrelax0;$/;" m struct:BraidOptions +nrelax0 xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax, nrelax0,/;" v program:ex01_f90 +nrels xbraid/braid/_braid.h /^ braid_Int *nrels; \/**< number of pre-relaxations on each level *\/$/;" m struct:_braid_Core_struct +nspace xbraid/drivers/viz-burgers-1D.py /^nspace = int(data[3])$/;" v +nspace xbraid/examples/viz-ex-02.py /^nspace = int(data[3])$/;" v +nsteps xbraid/drivers/viz-burgers-1D.py /^nsteps = int(data[0])$/;" v +nsteps xbraid/examples/viz-ex-02.py /^nsteps = int(data[0])$/;" v +nsteps xbraid/examples/viz-ex-04.py /^nsteps = design.shape[0]$/;" v +ntime xbraid/braid/_braid.h /^ braid_Int ntime; \/**< initial number of time intervals *\/$/;" m struct:_braid_Core_struct +ntime xbraid/braid/braid.hpp /^ braid_Int ntime;$/;" m class:BraidApp +ntime xbraid/examples/ex-01-expanded-f.f90 /^ integer :: ntime$/;" k type:my_app +ntime xbraid/examples/ex-01-expanded-f.f90 /^ integer mydt, ntime,/;" v program:ex01_f90 +ntraining include/config.hpp /^ int ntraining;$/;" m class:Config +num_procs_x xbraid/drivers/braid_mfem.hpp /^ int num_procs_x;$/;" m struct:BraidOptions +num_procs_x xbraid/drivers/braid_mfem_block.hpp /^ int num_procs_x;$/;" m struct:BraidOptions +num_requests xbraid/braid/_braid.h /^ braid_Int num_requests; \/**< number of active requests for this handle, usually 1 *\/$/;" m struct:__anon2 +num_time_steps xbraid/drivers/braid_mfem.hpp /^ int num_time_steps;$/;" m struct:BraidOptions +num_time_steps xbraid/drivers/braid_mfem_block.hpp /^ int num_time_steps;$/;" m struct:BraidOptions +numarg xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg, wrapper_tests, print_help, i, numarg$/;" v program:ex01_f90 +nupoints xbraid/braid/_braid.h /^ braid_Int nupoints; \/**< number of unknown vector points *\/$/;" m struct:__anon3 +nvalidation include/config.hpp /^ int nvalidation;$/;" m class:Config +nweights include/layer.hpp /^ int nweights; \/* Number of weights *\/$/;" m class:Layer +objT_diff xbraid/braid/_braid.h /^ braid_PtFcnObjectiveTDiff objT_diff; \/**< User function: apply differentiated objective function *\/$/;" m struct:_braid_Core_struct +obj_only xbraid/braid/_braid.h /^ braid_Int obj_only; \/**< determines if adjoint code computes ONLY objective, no gradients. *\/$/;" m struct:_braid_Core_struct +objective include/braid_wrapper.hpp /^ MyReal objective; \/* Objective function *\/$/;" m class:myBraidApp +objective xbraid/braid/_braid.h /^ braid_Real objective; \/**< global objective function value *\/$/;" m struct:_braid_Optimization_struct +objectiveT xbraid/braid/_braid.h /^ braid_PtFcnObjectiveT objectiveT; \/**< User function: evaluate objective function at time t *\/$/;" m struct:_braid_Core_struct +ode xbraid/drivers/braid_mfem.hpp /^ Array ode;$/;" m class:MFEMBraidApp +ode xbraid/drivers/braid_mfem_block.hpp /^ Array ode;$/;" m class:MFEMBraidApp +old_fine_tolx xbraid/braid/_braid.h /^ braid_Real old_fine_tolx; \/**< Allows for storing the previously used fine tolerance from GetSpatialAccuracy *\/$/;" m struct:_braid_Core_struct +openlayer include/network.hpp /^ Layer* openlayer; \/* At first processor: openinglayer, else: NULL *\/$/;" m class:Network +openlayer_type include/config.hpp /^ int openlayer_type;$/;" m class:Config +operator = xbraid/drivers/braid_mfem.hpp /^ BraidVector &operator=(const Vector &source_vector)$/;" f class:BraidVector +operator = xbraid/drivers/braid_mfem.hpp /^ BraidVector &operator=(double value)$/;" f class:BraidVector +operator = xbraid/drivers/braid_mfem_block.hpp /^ BraidVector &operator=(const BlockVector &source_vector)$/;" f class:BraidVector +optim xbraid/braid/_braid.h /^ braid_Optim optim; \/**< structure that stores optimization variables (objective function, etc.) *\/ $/;" m struct:_braid_Core_struct +ordered_bunchify pythonutil/ordered_bunch.py /^def ordered_bunchify(x):$/;" f +ordered_unbunchify pythonutil/ordered_bunch.py /^def ordered_unbunchify(x):$/;" f +outTime xbraid/braid/_braid_tape.h /^ braid_Real outTime; \/**< time of the output vector *\/$/;" m struct:_braid_Action_struct +outfile testing/testing.py /^outfile = "optim.dat"$/;" v +own_data xbraid/drivers/braid_mfem.hpp /^ bool own_data;$/;" m class:MFEMBraidApp +own_data xbraid/drivers/braid_mfem_block.hpp /^ bool own_data;$/;" m class:MFEMBraidApp +par_ref_levels xbraid/drivers/braid_mfem.hpp /^ int par_ref_levels;$/;" m struct:BraidOptions +par_ref_levels xbraid/drivers/braid_mfem_block.hpp /^ int par_ref_levels;$/;" m struct:BraidOptions +params xbraid/misc/user_utils/cycleplot.py /^ params = return_rcparams(fig_width=fig_size[0], fig_height=fig_size[1], fontfamily='serif', fontsize=fontsize)$/;" v +parser testing/testing.py /^parser = argparse.ArgumentParser()$/;" v +pop pythonutil/ordered_dict.py /^ def pop(self, key, default=__marker):$/;" m class:OrderedDict +popitem pythonutil/ordered_dict.py /^ def popitem(self, last=True):$/;" m class:OrderedDict +postprocess_obj xbraid/braid/_braid.h /^ braid_PtFcnPostprocessObjective postprocess_obj; \/**< Optional user function: Modify the time-averaged objective function, e.g. for inverse design problems, adding relaxation term etc. *\/$/;" m struct:_braid_Core_struct +postprocess_obj_diff xbraid/braid/_braid.h /^ braid_PtFcnPostprocessObjective_diff postprocess_obj_diff; \/**< Optional user function: Derivative of postprocessing function *\/$/;" m struct:_braid_Core_struct +prev include/config.hpp /^ struct config_option* prev;$/;" m struct:Config::config_option typeref:struct:Config::config_option::config_option +primalcore include/braid_wrapper.hpp /^ BraidCore* primalcore; \/* pointer to primal core for accessing primal states *\/$/;" m class:myAdjointBraidApp +print_help xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg, wrapper_tests, print_help,/;" v program:ex01_f90 +print_level xbraid/braid/_braid.h /^ braid_Int print_level; \/**< determines amount of output printed to screen (0,1,2,3) *\/$/;" m struct:_braid_Core_struct +print_level xbraid/drivers/braid_mfem.hpp /^ int print_level;$/;" m struct:BraidOptions +print_level xbraid/drivers/braid_mfem_block.hpp /^ int print_level;$/;" m struct:BraidOptions +print_level xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level,/;" v program:ex01_f90 +print_timegrid xbraid/examples/ex-01-expanded-f.f90 /^subroutine print_timegrid(/;" s +probability include/layer.hpp /^ MyReal* probability; \/* vector of pedicted class probabilities *\/$/;" m class:ClassificationLayer +pstatus xbraid/braid/braid.hpp /^ braid_StepStatus pstatus;$/;" m class:BraidStepStatus +r xbraid/misc/user_utils/cycleplot.py /^ r = data[:,4]$/;" v +r_indices xbraid/misc/user_utils/cycleplot.py /^ r_indices = setdiff1d((dr != 0).nonzero()[0], (r==0).nonzero()[0]-1) # x-locations to print$/;" v +r_level xbraid/misc/user_utils/cycleplot.py /^ r_level = level[r_indices] # corresponding level numbers$/;" v +r_space xbraid/braid/_braid.h /^ braid_Int r_space; \/**< spatial refinment flag *\/$/;" m struct:_braid_Core_struct +r_to_print xbraid/misc/user_utils/cycleplot.py /^ r_to_print = r[r_indices+1]$/;" v +rank xbraid/drivers/viz-burgers-1D.py /^rank = 0 #int(sys.argv[1])$/;" v +rank xbraid/examples/ex-01-expanded-f.f90 /^ integer :: rank$/;" k type:my_app +rank xbraid/examples/ex-01-expanded-f.f90 /^ integer mydt, ntime, rank$/;" v program:ex01_f90 +rc xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc,/;" v program:ex01_f90 +read pythonutil/config.py /^ def read(self,filename):$/;" m class:Config +read_config pythonutil/config.py /^def read_config(filename):$/;" f +record xbraid/braid/_braid.h /^ braid_Int record; \/**< determines if actions are recorded to the tape or not. This separate $/;" m struct:_braid_Core_struct +recv_handle xbraid/braid/_braid.h /^ _braid_CommHandle *recv_handle; \/**< Handle for nonblocking receives of braid_BaseVectors *\/$/;" m struct:__anon3 +recv_index xbraid/braid/_braid.h /^ braid_Int recv_index; \/**< -1 means no receive *\/$/;" m struct:__anon3 +refine xbraid/braid/_braid.h /^ braid_Int refine; \/**< refine in time (refine = 1) *\/$/;" m struct:_braid_Core_struct +refname testing/testing.py /^ refname = testname + "." + outfile $/;" v +replace xbraid/examples/ex-01-expanded-f.f90 /^subroutine replace(/;" s +request xbraid/braid/_braid.h /^ MPI_Request *request; \/**< helper: Storing the MPI request of BufUnPackDiff *\/$/;" m struct:_braid_Optimization_struct +request_type xbraid/braid/_braid.h /^ braid_Int request_type; \/**< two values: recv type = 1, and send type = 0 *\/$/;" m struct:__anon2 +requests xbraid/braid/_braid.h /^ MPI_Request *requests; \/**< MPI request structure *\/$/;" m struct:__anon2 +res xbraid/drivers/braid_mfem_block.hpp /^ int res;$/;" m struct:BraidOptions +res xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level, access_level, nfmg_Vcyc, res$/;" v program:ex01_f90 +reset_gradient xbraid/braid/_braid.h /^ braid_PtFcnResetGradient reset_gradient; \/**< User function: Set the gradient to zero. Is called before each iteration *\/$/;" m struct:_braid_Core_struct +residual xbraid/braid/_braid.h /^ braid_PtFcnResidual residual; \/**< (optional) compute residual *\/$/;" m struct:_braid_Core_struct +return_rcparams xbraid/misc/user_utils/cycleplot.py /^def return_rcparams(fig_width=5, fig_height=5, fontsize=28, fontfamily='sans-serif'):$/;" f +reverted_ranks xbraid/braid/_braid.h /^ braid_Int reverted_ranks; $/;" m struct:_braid_Core_struct +rfactor xbraid/braid/_braid.h /^ braid_Int rfactor; \/**< if set by user, allows for subdivision of this interval for better time accuracy *\/$/;" m struct:_braid_Core_struct +rfactors xbraid/braid/_braid.h /^ braid_Int *rfactors; \/**< refinement factors for finest grid (if any) *\/$/;" m struct:_braid_Core_struct +rho include/hessianApprox.hpp /^ MyReal* rho; \/* storing M 1\/y^Ts values *\/$/;" m class:L_BFGS +rnorm xbraid/braid/_braid.h /^ braid_Real rnorm; \/**< norm of the state residual *\/$/;" m struct:_braid_Optimization_struct +rnorm xbraid/braid/_braid.h /^ braid_Real rnorm; \/**< residual norm *\/$/;" m struct:_braid_Core_struct +rnorm xbraid/misc/user_utils/cycleplot.py /^ rnorm = -1$/;" v +rnorm xbraid/misc/user_utils/cycleplot.py /^ rnorm = data[:,4]$/;" v +rnorm0 xbraid/braid/_braid.h /^ braid_Real rnorm0; \/**< initial residual norm *\/$/;" m struct:_braid_Core_struct +rnorm0 xbraid/braid/_braid.h /^ braid_Real rnorm0; \/**< initial norm of the state residual *\/$/;" m struct:_braid_Optimization_struct +rnorm0_adj xbraid/braid/_braid.h /^ braid_Real rnorm0_adj; \/**< initial norm of the adjoint residual *\/$/;" m struct:_braid_Optimization_struct +rnorm_adj xbraid/braid/_braid.h /^ braid_Real rnorm_adj; \/**< norm of the adjoint residual *\/$/;" m struct:_braid_Optimization_struct +rnorms xbraid/braid/_braid.h /^ braid_Real *rnorms; \/**< residual norm history *\/$/;" m struct:_braid_Core_struct +rstopped xbraid/braid/_braid.h /^ braid_Int rstopped; \/**< refinement stopped at iteration rstopped *\/$/;" m struct:_braid_Core_struct +rtol xbraid/braid/_braid.h /^ braid_Int rtol; \/**< use relative tolerance *\/$/;" m struct:_braid_Core_struct +rtol xbraid/drivers/braid_mfem.hpp /^ bool rtol;$/;" m struct:BraidOptions +rtol_adj xbraid/braid/_braid.h /^ braid_Int rtol_adj; \/**< flag: use relative tolerance for adjoint *\/$/;" m struct:_braid_Optimization_struct +runcommand examples/mnist/mnist_runs/submit_paramstudy.py /^runcommand = "mpirun -n"$/;" v +runcommand pythonutil/submit_paramstudy.py /^runcommand = "mpirun -n"$/;" v +runcommand testing/testing.py /^ runcommand = "mpirun -n " + str(npt) + " ..\/..\/main " + testconfig + " > tmp"$/;" v +s include/hessianApprox.hpp /^ MyReal* s; $/;" m class:BFGS +s include/hessianApprox.hpp /^ MyReal** s; \/* storing M (x_{k+1} - x_k) vectors *\/$/;" m class:L_BFGS +sclone xbraid/braid/_braid.h /^ braid_PtFcnSClone sclone; \/**< (optional) clone the shell of a vector *\/$/;" m struct:_braid_Core_struct +scoarsen xbraid/braid/_braid.h /^ braid_PtFcnSCoarsen scoarsen; \/**< (optional) return a spatially coarsened vector *\/$/;" m struct:_braid_Core_struct +send_handle xbraid/braid/_braid.h /^ _braid_CommHandle *send_handle; \/**< Handle for nonblocking sends of braid_BaseVectors *\/$/;" m struct:__anon3 +send_index xbraid/braid/_braid.h /^ braid_Int send_index; \/**< -1 means no send *\/$/;" m struct:__anon3 +send_recv_rank xbraid/braid/_braid.h /^ braid_Int send_recv_rank; \/***< holds the rank of the source \/ receiver from MPI_Send \/ MPI_Recv calls. *\/$/;" m struct:_braid_Core_struct +send_recv_rank xbraid/braid/_braid_tape.h /^ braid_Int send_recv_rank; \/**< processor rank of sender \/ receiver in my_bufpack \/ my_bufunpack *\/$/;" m struct:_braid_Action_struct +sendbuffer xbraid/braid/_braid.h /^ void *sendbuffer; \/**< helper: Memory for BufUnPackDiff communication *\/$/;" m struct:_braid_Optimization_struct +sendflag include/braid_wrapper.hpp /^ MyReal sendflag; $/;" m class:myBraidVector +seq_soln xbraid/braid/_braid.h /^ braid_Int seq_soln; \/**< boolean, controls if the initial guess is from sequential time stepping*\/$/;" m struct:_braid_Core_struct +ser_ref_levels xbraid/drivers/braid_mfem.hpp /^ int ser_ref_levels;$/;" m struct:BraidOptions +ser_ref_levels xbraid/drivers/braid_mfem_block.hpp /^ int ser_ref_levels;$/;" m struct:BraidOptions +setdefault pythonutil/ordered_dict.py /^ def setdefault(self, key, default=None):$/;" m class:OrderedDict +sfree xbraid/braid/_braid.h /^ braid_PtFcnSFree sfree; \/**< (optional) free up the data of a vector, keep the shell *\/$/;" m struct:_braid_Core_struct +sinit xbraid/braid/_braid.h /^ braid_PtFcnSInit sinit; \/**< (optional) return an initialized shell of braid_BaseVector *\/$/;" m struct:_braid_Core_struct +size xbraid/braid/_braid_tape.h /^ int size;$/;" m struct:_braid_tape_struct +size_buffer xbraid/braid/_braid.h /^ braid_Int size_buffer; \/**< if set by user, send buffer will be "size" bytes in length *\/$/;" m struct:_braid_Core_struct +size_buffer xbraid/braid/_braid_tape.h /^ braid_Int size_buffer; \/**< if set by user, size of send buffer is "size" bytes *\/$/;" m struct:_braid_Action_struct +sizeof_double xbraid/examples/ex-01-expanded-f.f90 /^ integer, parameter :: sizeof_double /;" v module:braid_types +sizeof_int xbraid/examples/ex-01-expanded-f.f90 /^ integer, parameter :: sizeof_int /;" v module:braid_types +skip xbraid/braid/_braid.h /^ braid_Int skip; \/**< boolean, controls skipping any work on first down-cycle *\/$/;" m struct:_braid_Core_struct +skip xbraid/drivers/braid_mfem.hpp /^ int skip;$/;" m struct:BraidOptions +skip xbraid/drivers/braid_mfem_block.hpp /^ int skip;$/;" m struct:BraidOptions +sol_sock xbraid/drivers/braid_mfem.hpp /^ socketstream sol_sock;$/;" m class:MFEMBraidApp +sol_sock xbraid/drivers/braid_mfem_block.hpp /^ socketstream sol_sock;$/;" m class:MFEMBraidApp +solver xbraid/drivers/braid_mfem.hpp /^ Array solver;$/;" m class:MFEMBraidApp +solver xbraid/drivers/braid_mfem_block.hpp /^ Array solver;$/;" m class:MFEMBraidApp +spatial_coarsen xbraid/drivers/braid_mfem.hpp /^ bool spatial_coarsen;$/;" m struct:BraidOptions +spatial_coarsen xbraid/drivers/braid_mfem_block.hpp /^ bool spatial_coarsen;$/;" m struct:BraidOptions +spatial_level xbraid/drivers/braid_mfem_block.hpp /^ int spatial_level;$/;" m class:BraidVector +spatialnorm xbraid/braid/_braid.h /^ braid_PtFcnSpatialNorm spatialnorm; \/**< Compute norm of a braid_BaseVector, this is a norm only over space *\/$/;" m struct:_braid_Core_struct +srefine xbraid/braid/_braid.h /^ braid_PtFcnSRefine srefine; \/**< (optional) return a spatially refined vector *\/$/;" m struct:_braid_Core_struct +startlayerID include/network.hpp /^ int startlayerID; \/* ID of the first layer on that processor *\/$/;" m class:Network +state include/braid_wrapper.hpp /^ MyReal **state; \/* Network state at one layer, dimensions: nbatch * nchannels *\/$/;" m class:myBraidVector +state_vec xbraid/examples/viz-ex-04.py /^ state_vec = loadtxt('ex-04.out.state')$/;" v +state_vec xbraid/examples/viz-ex-04.py /^ state_vec = zeros((nsteps,2))$/;" v +status xbraid/braid/_braid.h /^ MPI_Status *status; \/**< MPI status *\/$/;" m struct:__anon2 +status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_AccessStatus_struct +status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_BufferStatus_struct +status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_CoarsenRefStatus_struct +status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_ObjectiveStatus_struct +status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_StepStatus_struct +step xbraid/braid/_braid.h /^ braid_PtFcnStep step; \/**< apply step function *\/$/;" m struct:_braid_Core_struct +step xbraid/drivers/viz-burgers-1D.py /^step = 0$/;" v +step xbraid/examples/viz-ex-02.py /^step = 0$/;" v +step_diff xbraid/braid/_braid.h /^ braid_PtFcnStepDiff step_diff; \/**< User function: apply differentiated step function *\/$/;" m struct:_braid_Core_struct +stepsize_init include/config.hpp /^ MyReal stepsize_init;$/;" m class:Config +stepsize_type include/config.hpp /^ int stepsize_type;$/;" m class:Config +stepsizetype include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" g +storage xbraid/braid/_braid.h /^ braid_Int storage; \/**< storage = 0 (C-points), = 1 (all) *\/$/;" m struct:_braid_Core_struct +storage xbraid/drivers/braid_mfem.hpp /^ int storage;$/;" m struct:BraidOptions +storage xbraid/drivers/braid_mfem_block.hpp /^ int storage;$/;" m struct:BraidOptions +submit_job pythonutil/batch_job.py /^def submit_job(jobname, runcommand, ntasks, time_limit, executable, arguments,run=True):$/;" f +sum xbraid/braid/_braid.h /^ braid_PtFcnSum sum; \/**< vector sum *\/$/;" m struct:_braid_Core_struct +sum_alpha xbraid/braid/_braid_tape.h /^ braid_Real sum_alpha; \/**< first coefficient of my_sum *\/$/;" m struct:_braid_Action_struct +sum_beta xbraid/braid/_braid_tape.h /^ braid_Real sum_beta; \/**< second coefficient of my_sum *\/$/;" m struct:_braid_Action_struct +sum_user_obj xbraid/braid/_braid.h /^ braid_Real sum_user_obj; \/**< sum of user's objective function values over time *\/$/;" m struct:_braid_Optimization_struct +switch pythonutil/switch.py /^class switch(object):$/;" c +t xbraid/braid/_braid.h /^ braid_Real t; \/**< current time *\/$/;" m struct:_braid_Core_struct +t xbraid/examples/ex-01-expanded-f.f90 /^ double precision t,/;" v program:ex01_f90 +t_final xbraid/drivers/braid_mfem.hpp /^ double t_final;$/;" m struct:BraidOptions +t_final xbraid/drivers/braid_mfem_block.hpp /^ double t_final;$/;" m struct:BraidOptions +t_start xbraid/drivers/braid_mfem.hpp /^ double t_start;$/;" m struct:BraidOptions +t_start xbraid/drivers/braid_mfem_block.hpp /^ double t_start;$/;" m struct:BraidOptions +ta xbraid/braid/_braid.h /^ braid_Real *ta; \/**< time values (all points) *\/$/;" m struct:__anon3 +ta_alloc xbraid/braid/_braid.h /^ braid_Real *ta_alloc; \/**< original memory allocation for ta *\/$/;" m struct:__anon3 +tapeinput xbraid/braid/_braid.h /^ braid_VectorBar *tapeinput; \/**< helper: store pointer to input of one braid iteration *\/$/;" m struct:_braid_Optimization_struct +testconfig testing/testing.py /^ testconfig = testname + ".cfg"$/;" v +testfoldername testing/testing.py /^ testfoldername = "test." + testname$/;" v +testname testing/testing.py /^ testname = case + ".npt" + str(npt) + ".ml" + str(ml) $/;" v +tgrid xbraid/braid/_braid.h /^ braid_PtFcnTimeGrid tgrid; \/**< (optional) return time point values on level 0 *\/$/;" m struct:_braid_Core_struct +tight_fine_tolx xbraid/braid/_braid.h /^ braid_Int tight_fine_tolx; \/**< Boolean, indicating whether the tightest fine tolx has been used, condition for halting *\/$/;" m struct:_braid_Core_struct +tmesh xbraid/examples/viz-ex-04.py /^tmesh = linspace(0,1.0,nsteps+1)$/;" v +tnext xbraid/braid/_braid.h /^ braid_Real tnext; \/**< time value to evolve towards, time value to the right of tstart *\/$/;" m struct:_braid_Core_struct +tnorm xbraid/braid/_braid.h /^ braid_Int tnorm; \/**< choice of temporal norm *\/$/;" m struct:_braid_Core_struct +tnorm xbraid/drivers/braid_mfem.hpp /^ int tnorm;$/;" m struct:BraidOptions +tnorm xbraid/drivers/braid_mfem_block.hpp /^ int tnorm;$/;" m struct:BraidOptions +tnorm_a xbraid/braid/_braid.h /^ braid_Real *tnorm_a; \/**< local array of residual norms on a proc's interval, used for inf-norm *\/$/;" m struct:_braid_Core_struct +toJSON pythonutil/ordered_bunch.py /^ def toJSON(self, **options):$/;" f function:ordered_unbunchify +toOrderedDict pythonutil/ordered_bunch.py /^ def toOrderedDict(self):$/;" m class:OrderedBunch +toYAML pythonutil/ordered_bunch.py /^ def toYAML(self, **options):$/;" f +to_yaml pythonutil/ordered_bunch.py /^ def to_yaml(dumper, data):$/;" f +to_yaml_safe pythonutil/ordered_bunch.py /^ def to_yaml_safe(dumper, data):$/;" f +todo : Don't feed applyBWD with NULL! */ src/braid_wrapper.cpp /^ \/* TODO: Don't feed applyBWD with NULL! *\/$/;" t +todo : Fix src/network.cpp /^ \/\/ TODO: Fix$/;" t +todo : Remove these two lines, which are now useless since core==status */ xbraid/braid/_braid.c /^ \/* TODO : Remove these two lines, which are now useless since core==status *\/$/;" t +todo : read some design */ src/main.cpp /^ \/* TODO: read some design *\/$/;" t +todo : so something, if design is part of initial conditions!! */ xbraid/braid/_braid_tape.c /^ \/* TODO: so something, if design is part of initial conditions!! *\/$/;" t +todo Remove this line after modifing the _braid_StatusSetRFactor to set the rfactor in the array directly */ xbraid/braid/_braid.c /^ \/*TODO Remove this line after modifing the _braid_StatusSetRFactor to set the rfactor in the array directly *\/$/;" t +tol xbraid/braid/_braid.h /^ braid_Real tol; \/**< stopping tolerance *\/$/;" m struct:_braid_Core_struct +tol xbraid/braid/_braid_tape.h /^ braid_Real tol; \/**< primal stopping tolerance *\/ $/;" m struct:_braid_Action_struct +tol xbraid/drivers/braid_mfem.hpp /^ double tol;$/;" m struct:BraidOptions +tol xbraid/drivers/braid_mfem_block.hpp /^ double tol;$/;" m struct:BraidOptions +tol xbraid/examples/ex-01-expanded-f.f90 /^ double precision t, tol,/;" v program:ex01_f90 +tol xbraid/misc/user_utils/cycleplot.py /^ tol = data[:,5]$/;" v +tol_adj xbraid/braid/_braid.h /^ braid_Real tol_adj; \/**< tolerance of adjoint residual *\/$/;" m struct:_braid_Optimization_struct +tols xbraid/misc/user_utils/cycleplot.py /^ tols = data[:,5]$/;" v +tpoints_cutoff xbraid/braid/_braid.h /^ braid_Int tpoints_cutoff; \/**< refinements halt after the number of time steps exceed this value *\/$/;" m struct:_braid_Core_struct +tstart xbraid/braid/_braid.h /^ braid_Real tstart; \/**< start time *\/$/;" m struct:_braid_Core_struct +tstart xbraid/braid/braid.hpp /^ braid_Real tstart;$/;" m class:BraidApp +tstart xbraid/drivers/viz-burgers-1D.py /^tstart = float(data[1])$/;" v +tstart xbraid/examples/ex-01-expanded-f.f90 /^ double precision :: tstart$/;" k type:my_app +tstart xbraid/examples/ex-01-expanded-f.f90 /^ double precision t, tol, tstart,/;" v program:ex01_f90 +tstart xbraid/examples/viz-ex-02.py /^tstart = float(data[1])$/;" v +tstart_obj xbraid/braid/_braid.h /^ braid_Real tstart_obj; \/**< starting time for evaluating the user's local objective *\/$/;" m struct:_braid_Optimization_struct +tstop xbraid/braid/_braid.h /^ braid_Real tstop; \/**< stop time *\/$/;" m struct:_braid_Core_struct +tstop xbraid/braid/braid.hpp /^ braid_Real tstop;$/;" m class:BraidApp +tstop xbraid/drivers/viz-burgers-1D.py /^tstop = float(data[2])$/;" v +tstop xbraid/examples/ex-01-expanded-f.f90 /^ double precision :: tstop$/;" k type:my_app +tstop xbraid/examples/ex-01-expanded-f.f90 /^ double precision t, tol, tstart, tstop$/;" v program:ex01_f90 +tstop xbraid/examples/viz-ex-02.py /^tstop = float(data[2])$/;" v +tstop_obj xbraid/braid/_braid.h /^ braid_Real tstop_obj; \/**< stopping time for evaluating the user's local objective *\/$/;" m struct:_braid_Optimization_struct +type include/layer.hpp /^ int type; \/* Type of the layer (enum element) *\/$/;" m class:Layer +ua xbraid/braid/_braid.h /^ braid_BaseVector *ua; \/**< unknown vectors (C-points at least)*\/$/;" m struct:__anon3 +ua_alloc xbraid/braid/_braid.h /^ braid_BaseVector *ua_alloc; \/**< original memory allocation for ua *\/$/;" m struct:__anon3 +ulast xbraid/braid/_braid.h /^ braid_BaseVector ulast; \/**< stores last time step *\/$/;" m struct:__anon3 +update include/layer.hpp /^ MyReal *update; \/* Auxilliary for computing fwd update *\/$/;" m class:Layer +update pythonutil/ordered_dict.py /^ def update(*args, **kwds):$/;" m class:OrderedDict +update_bar include/layer.hpp /^ MyReal *update_bar; \/* Auxilliary for computing bwd update *\/$/;" m class:Layer +useCount xbraid/braid/_braid.h /^ braid_Int useCount; \/**< counts the number of pointers to this struct *\/$/;" m struct:_braid_VectorBar_struct +use_seq_soln xbraid/drivers/braid_mfem.hpp /^ int use_seq_soln;$/;" m struct:BraidOptions +userVector xbraid/braid/_braid.h /^ braid_Vector userVector; \/**< holds the users primal vector *\/$/;" m struct:_braid_BaseVector_struct +userVector xbraid/braid/_braid.h /^ braid_Vector userVector; \/**< holds the u_bar data *\/$/;" m struct:_braid_VectorBar_struct +userVectorTape xbraid/braid/_braid.h /^ _braid_Tape* userVectorTape; \/**< tape storing primal braid_vectors while recording *\/$/;" m struct:_braid_Core_struct +useshell xbraid/braid/_braid.h /^ braid_Int useshell; \/**< activate the shell structure of vectors *\/$/;" m struct:_braid_Core_struct +v xbraid/drivers/braid_mfem_block.hpp /^ Array v; \/\/ auxiliary ParGridFunctions for block v$/;" m class:MFEMBraidApp +va xbraid/braid/_braid.h /^ braid_BaseVector *va; \/**< restricted unknown vectors (all points, NULL on level 0) *\/$/;" m struct:__anon3 +va_alloc xbraid/braid/_braid.h /^ braid_BaseVector *va_alloc; \/**< original memory allocation for va *\/$/;" m struct:__anon3 +val xbraid/examples/ex-01-expanded-f.f90 /^ double precision val$/;" k type:my_vector +validationlevel include/config.hpp /^ int validationlevel;$/;" m class:Config +value include/config.hpp /^ char value[CONFIG_ARG_MAX_BYTES];$/;" m struct:Config::config_option +values pythonutil/ordered_dict.py /^ def values(self):$/;" m class:OrderedDict +vector_ptr xbraid/braid/_braid.h /^ braid_BaseVector *vector_ptr; \/**< braid_vector being sent\/received *\/$/;" m struct:__anon2 +verbose_adj xbraid/braid/_braid.h /^ braid_Int verbose_adj; \/**< verbosity of the adjoint tape, displays the actions that are pushed \/ popped to the tape*\/$/;" m struct:_braid_Core_struct +viewitems pythonutil/ordered_dict.py /^ def viewitems(self):$/;" m class:OrderedDict +viewkeys pythonutil/ordered_dict.py /^ def viewkeys(self):$/;" m class:OrderedDict +viewvalues pythonutil/ordered_dict.py /^ def viewvalues(self):$/;" m class:OrderedDict +vis_braid_steps xbraid/drivers/braid_mfem.hpp /^ int vis_braid_steps;$/;" m class:MFEMBraidApp +vis_braid_steps xbraid/drivers/braid_mfem_block.hpp /^ int vis_braid_steps;$/;" m class:MFEMBraidApp +vis_screenshots xbraid/drivers/braid_mfem.hpp /^ bool vis_screenshots;$/;" m class:MFEMBraidApp +vis_screenshots xbraid/drivers/braid_mfem_block.hpp /^ bool vis_screenshots;$/;" m class:MFEMBraidApp +vis_time_steps xbraid/drivers/braid_mfem.hpp /^ int vis_time_steps;$/;" m class:MFEMBraidApp +vis_time_steps xbraid/drivers/braid_mfem_block.hpp /^ int vis_time_steps;$/;" m class:MFEMBraidApp +vishost xbraid/drivers/braid_mfem.hpp /^ const char *vishost;$/;" m class:MFEMBraidApp +vishost xbraid/drivers/braid_mfem_block.hpp /^ const char *vishost;$/;" m class:MFEMBraidApp +vishost_default xbraid/drivers/braid_mfem.hpp /^ static const char *vishost_default;$/;" m class:MFEMBraidApp +vishost_default xbraid/drivers/braid_mfem.hpp /^const char *MFEMBraidApp::vishost_default = "localhost";$/;" m class:MFEMBraidApp +vishost_default xbraid/drivers/braid_mfem_block.hpp /^ static const char *vishost_default;$/;" m class:MFEMBraidApp +vishost_default xbraid/drivers/braid_mfem_block.hpp /^const char *MFEMBraidApp::vishost_default = "localhost";$/;" m class:MFEMBraidApp +visport xbraid/drivers/braid_mfem.hpp /^ int visport;$/;" m class:MFEMBraidApp +visport xbraid/drivers/braid_mfem_block.hpp /^ int visport;$/;" m class:MFEMBraidApp +visport_default xbraid/drivers/braid_mfem.hpp /^ static const int visport_default;$/;" m class:MFEMBraidApp +visport_default xbraid/drivers/braid_mfem.hpp /^const int MFEMBraidApp::visport_default = 19916;$/;" m class:MFEMBraidApp +visport_default xbraid/drivers/braid_mfem_block.hpp /^ static const int visport_default;$/;" m class:MFEMBraidApp +visport_default xbraid/drivers/braid_mfem_block.hpp /^const int MFEMBraidApp::visport_default = 19916;$/;" m class:MFEMBraidApp +warm_restart xbraid/braid/_braid.h /^ braid_Int warm_restart; \/**< boolean, indicates whether this is a warm restart of an existing braid_Core *\/$/;" m struct:_braid_Core_struct +weights include/layer.hpp /^ MyReal* weights; \/* Weight matrix, flattened as a vector *\/$/;" m class:Layer +weights_bar include/layer.hpp /^ MyReal* weights_bar; \/* Derivative of the Weight matrix*\/$/;" m class:Layer +weights_class_init include/config.hpp /^ MyReal weights_class_init;$/;" m class:Config +weights_init include/config.hpp /^ MyReal weights_init;$/;" m class:Config +weights_open_init include/config.hpp /^ MyReal weights_open_init;$/;" m class:Config +weightsclassificationfile include/config.hpp /^ const char* weightsclassificationfile;$/;" m class:Config +weightsopenfile include/config.hpp /^ const char* weightsopenfile;$/;" m class:Config +wrapper_test xbraid/braid/_braid.h /^ braid_Int wrapper_test; \/**< boolean describing whether this call is only a wrapper test *\/$/;" m struct:_braid_Core_struct +wrapper_tests xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg, wrapper_tests,/;" v program:ex01_f90 +write pythonutil/config.py /^ def write(self,filename=''):$/;" m class:Config +x xbraid/drivers/braid_mfem.hpp /^ Array x; \/\/ auxiliary ParGridFunctions$/;" m class:MFEMBraidApp +x xbraid/drivers/braid_mfem_block.hpp /^ Array x; \/\/ auxiliary ParGridFunctions for block x$/;" m class:MFEMBraidApp +x xbraid/drivers/viz-lorenz.py /^x = data[:,0]$/;" v +xstart xbraid/drivers/viz-burgers-1D.py /^xstart = float(data[4])$/;" v +xstart xbraid/examples/viz-ex-02.py /^xstart = float(data[4])$/;" v +xstop xbraid/drivers/viz-burgers-1D.py /^xstop = float(data[5])$/;" v +xstop xbraid/examples/viz-ex-02.py /^xstop = float(data[5])$/;" v +xticks xbraid/misc/user_utils/cycleplot.py /^ xticks = arange( level.shape[0] )[new_iterations]$/;" v +y include/hessianApprox.hpp /^ MyReal* y; $/;" m class:BFGS +y include/hessianApprox.hpp /^ MyReal** y; \/* storing M (\\nabla f_{k+1} - \\nabla f_k) vectors *\/$/;" m class:L_BFGS +y xbraid/drivers/viz-lorenz.py /^y = data[:,1]$/;" v +yticks xbraid/misc/user_utils/cycleplot.py /^ yticks = [ma, 10**((log10(mi)+log10(ma))*1.\/3.), 10**((log10(mi)+log10(ma))*2.\/3.), mi ]$/;" v +yticks xbraid/misc/user_utils/cycleplot.py /^ yticks = range(int(min(level)), int(max(level)+1))$/;" v +z xbraid/drivers/viz-lorenz.py /^z = data[:,2]$/;" v +~Arnoldi xbraid/drivers/mfem_arnoldi.hpp /^ ~Arnoldi()$/;" f class:Arnoldi +~BraidAccessStatus xbraid/braid/braid.hpp /^ ~BraidAccessStatus() { }$/;" f class:BraidAccessStatus +~BraidApp xbraid/braid/braid.hpp /^ virtual ~BraidApp() { }$/;" f class:BraidApp +~BraidBufferStatus xbraid/braid/braid.hpp /^ ~BraidBufferStatus() {} $/;" f class:BraidBufferStatus +~BraidCoarsenRefStatus xbraid/braid/braid.hpp /^ ~BraidCoarsenRefStatus() { }$/;" f class:BraidCoarsenRefStatus +~BraidCore xbraid/braid/braid.hpp /^ ~BraidCore() { braid_Destroy(core); }$/;" f class:BraidCore +~BraidStepStatus xbraid/braid/braid.hpp /^ ~BraidStepStatus() { }$/;" f class:BraidStepStatus +~BraidUtil xbraid/braid/braid.hpp /^ ~BraidUtil() { }$/;" f class:BraidUtil +~BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::~BraidVector()$/;" f class:BraidVector +~MFEMBraidApp xbraid/drivers/braid_mfem.hpp /^MFEMBraidApp::~MFEMBraidApp()$/;" f class:MFEMBraidApp +~MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::~MFEMBraidApp()$/;" f class:MFEMBraidApp From 6934e6f1278534fcb37bcb8577cc4ce35e84b22c Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 9 Jul 2019 10:23:44 +0200 Subject: [PATCH 02/38] Make todolist from Readme tasks --- Readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Readme.md b/Readme.md index 47f5a2e..f16eead 100644 --- a/Readme.md +++ b/Readme.md @@ -31,10 +31,10 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold ## 2Dos 😊 -* Clean up syntax (google std) -* Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles -* Extract methods and clean up objects -* Comment everything +* [ ] Clean up syntax (google std) +* [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles +* [ ] Extract methods and clean up objects +* [ ] Comment everything From 1c461917155a7144d8d41cfb9412568923fe84d8 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 9 Jul 2019 10:26:03 +0200 Subject: [PATCH 03/38] Clang-format the whole project for readability --- include/braid_wrapper.hpp | 334 +++---- include/config.hpp | 179 ++-- include/dataset.hpp | 84 +- include/defs.hpp | 5 +- include/hessianApprox.hpp | 145 ++- include/layer.hpp | 679 ++++++------- include/linalg.hpp | 59 +- include/network.hpp | 246 +++-- include/util.hpp | 39 +- src/braid_wrapper.cpp | 1319 +++++++++++++------------ src/config.cpp | 982 +++++++++---------- src/dataset.cpp | 345 ++++--- src/hessianApprox.cpp | 456 ++++----- src/layer.cpp | 1902 +++++++++++++++++-------------------- src/linalg.cpp | 169 ++-- src/main.cpp | 770 ++++++++------- src/network.cpp | 962 +++++++++---------- src/util.cpp | 232 ++--- 18 files changed, 4079 insertions(+), 4828 deletions(-) diff --git a/include/braid_wrapper.hpp b/include/braid_wrapper.hpp index f0465de..e9c2f1b 100644 --- a/include/braid_wrapper.hpp +++ b/include/braid_wrapper.hpp @@ -1,213 +1,179 @@ -#include #include +#include -#include "defs.hpp" #include "braid.hpp" +#include "defs.hpp" // #include "_braid.h" -#include "network.hpp" -#include "layer.hpp" #include "dataset.hpp" +#include "layer.hpp" +#include "network.hpp" #pragma once -/** - * Define the state vector at one time-step +/** + * Define the state vector at one time-step + */ +class myBraidVector { +protected: + int nbatch; /* Number of examples */ + int nchannels; /* Number of channels */ + + MyReal * + *state; /* Network state at one layer, dimensions: nbatch * nchannels */ + Layer *layer; /* Pointer to layer information */ + + /* Flag that determines if the layer and state have just been received and + * thus should be free'd after usage (flag > 0) */ + MyReal sendflag; + +public: + /* Get dimensions */ + int getnBatch(); + int getnChannels(); + + /* Get Pointer to the state at example exampleID */ + MyReal *getState(int exampleID); + + /* Get pointer to the full state matrix */ + MyReal **getState(); + + /* Get and set pointer to the layer */ + Layer *getLayer(); + void setLayer(Layer *layer); + + /* Get and set the sendflag */ + MyReal getSendflag(); + void setSendflag(MyReal value); + + /* Constructor */ + myBraidVector(int nChannels, int nBatch); + /* Destructor */ + ~myBraidVector(); +}; + +/** + * Wrapper for the primal braid app. + * virtual function are overwritten from the adjoint app class */ -class myBraidVector -{ - protected: - int nbatch; /* Number of examples */ - int nchannels; /* Number of channels */ +class myBraidApp : public BraidApp { +protected: + // BraidApp defines tstart, tstop, ntime and comm_t + int myid; /* Processor rank*/ + Network *network; /* Pointer to the DNN Network Block (local layer storage) */ + DataSet *data; /* Pointer to the Data set */ + + BraidCore *core; /* Braid core for running PinT simulation */ + + /* Output */ + MyReal objective; /* Objective function */ + +public: + /* Constructor */ + myBraidApp(DataSet *Data, Network *Network, Config *Config, MPI_Comm Comm); - MyReal **state; /* Network state at one layer, dimensions: nbatch * nchannels */ - Layer* layer; /* Pointer to layer information */ + /* Destructor */ + ~myBraidApp(); - /* Flag that determines if the layer and state have just been received and thus should be free'd after usage (flag > 0) */ - MyReal sendflag; + /* Return objective function */ + MyReal getObjective(); - public: - /* Get dimensions */ - int getnBatch(); - int getnChannels(); + /* Return the core */ + BraidCore *getCore(); - /* Get Pointer to the state at example exampleID */ - MyReal* getState(int exampleID); + /* Get xbraid's grid distribution */ + void GetGridDistribution(int *ilower_ptr, int *iupper_ptr); - /* Get pointer to the full state matrix */ - MyReal** getState(); + /* Return the time step index of current time t */ + braid_Int GetTimeStepIndex(MyReal t); - /* Get and set pointer to the layer */ - Layer* getLayer(); - void setLayer(Layer* layer); + /* Apply one time step */ + virtual braid_Int Step(braid_Vector u_, braid_Vector ustop_, + braid_Vector fstop_, BraidStepStatus &pstatus); - /* Get and set the sendflag */ - MyReal getSendflag(); - void setSendflag(MyReal value); + /* Compute residual: Does nothing. */ + braid_Int Residual(braid_Vector u_, braid_Vector r_, + BraidStepStatus &pstatus); - /* Constructor */ - myBraidVector(int nChannels, - int nBatch); - /* Destructor */ - ~myBraidVector(); -}; + /* Allocate a new vector in *v_ptr, which is a deep copy of u_. */ + braid_Int Clone(braid_Vector u_, braid_Vector *v_ptr); + /* Allocate a new vector in *u_ptr and initialize it with an + initial guess appropriate for time t. */ + virtual braid_Int Init(braid_Real t, braid_Vector *u_ptr); + /* De-allocate the vector @a u_. */ + braid_Int Free(braid_Vector u_); + /* Perform the operation: y_ = alpha * x_ + beta * @a y_. */ + braid_Int Sum(braid_Real alpha, braid_Vector x_, braid_Real beta, + braid_Vector y_); + + /* Compute in @a *norm_ptr an appropriate spatial norm of @a u_. */ + braid_Int SpatialNorm(braid_Vector u_, braid_Real *norm_ptr); + + /* @see braid_PtFcnAccess. */ + braid_Int Access(braid_Vector u_, BraidAccessStatus &astatus); + + /* @see braid_PtFcnBufSize. */ + virtual braid_Int BufSize(braid_Int *size_ptr, BraidBufferStatus &bstatus); + + /* @see braid_PtFcnBufPack. */ + virtual braid_Int BufPack(braid_Vector u_, void *buffer, + BraidBufferStatus &bstatus); + + /* @see braid_PtFcnBufUnpack. */ + virtual braid_Int BufUnpack(void *buffer, braid_Vector *u_ptr, + BraidBufferStatus &bstatus); + + /* Set the initial condition */ + virtual braid_Int SetInitialCondition(); + + /* evaluate objective function */ + virtual braid_Int EvaluateObjective(); + + /* Run Braid drive, return norm */ + MyReal run(); +}; /** - * Wrapper for the primal braid app. - * virtual function are overwritten from the adjoint app class + * Adjoint braid App for solving adjoint eqations with xbraid. */ -class myBraidApp : public BraidApp -{ - protected: - // BraidApp defines tstart, tstop, ntime and comm_t - int myid; /* Processor rank*/ - Network* network; /* Pointer to the DNN Network Block (local layer storage) */ - DataSet* data; /* Pointer to the Data set */ - - BraidCore* core; /* Braid core for running PinT simulation */ - - /* Output */ - MyReal objective; /* Objective function */ - - public: - - /* Constructor */ - myBraidApp(DataSet* Data, - Network* Network, - Config* Config, - MPI_Comm Comm); - - - /* Destructor */ - ~myBraidApp(); - - /* Return objective function */ - MyReal getObjective(); - - /* Return the core */ - BraidCore* getCore(); - - /* Get xbraid's grid distribution */ - void GetGridDistribution(int *ilower_ptr, - int *iupper_ptr); - - /* Return the time step index of current time t */ - braid_Int GetTimeStepIndex(MyReal t); - - /* Apply one time step */ - virtual braid_Int Step(braid_Vector u_, - braid_Vector ustop_, - braid_Vector fstop_, - BraidStepStatus &pstatus); - - /* Compute residual: Does nothing. */ - braid_Int Residual(braid_Vector u_, - braid_Vector r_, - BraidStepStatus &pstatus); - - /* Allocate a new vector in *v_ptr, which is a deep copy of u_. */ - braid_Int Clone(braid_Vector u_, - braid_Vector *v_ptr); - - /* Allocate a new vector in *u_ptr and initialize it with an - initial guess appropriate for time t. */ - virtual braid_Int Init(braid_Real t, - braid_Vector *u_ptr); - - /* De-allocate the vector @a u_. */ - braid_Int Free(braid_Vector u_); - - /* Perform the operation: y_ = alpha * x_ + beta * @a y_. */ - braid_Int Sum(braid_Real alpha, - braid_Vector x_, - braid_Real beta, - braid_Vector y_); - - /* Compute in @a *norm_ptr an appropriate spatial norm of @a u_. */ - braid_Int SpatialNorm(braid_Vector u_, - braid_Real *norm_ptr); - - /* @see braid_PtFcnAccess. */ - braid_Int Access(braid_Vector u_, - BraidAccessStatus &astatus); - - /* @see braid_PtFcnBufSize. */ - virtual braid_Int BufSize(braid_Int *size_ptr, - BraidBufferStatus &bstatus); - - /* @see braid_PtFcnBufPack. */ - virtual braid_Int BufPack(braid_Vector u_, - void *buffer, - BraidBufferStatus &bstatus); - - /* @see braid_PtFcnBufUnpack. */ - virtual braid_Int BufUnpack(void *buffer, - braid_Vector *u_ptr, - BraidBufferStatus &bstatus); - - /* Set the initial condition */ - virtual braid_Int SetInitialCondition(); - - /* evaluate objective function */ - virtual braid_Int EvaluateObjective(); - - /* Run Braid drive, return norm */ - MyReal run(); -}; +class myAdjointBraidApp : public myBraidApp { +protected: + BraidCore + *primalcore; /* pointer to primal core for accessing primal states */ +public: + myAdjointBraidApp(DataSet *Data, Network *Network, Config *config, + BraidCore *Primalcoreptr, MPI_Comm comm); + ~myAdjointBraidApp(); + /* Get the storage index of primal (reversed) */ + int GetPrimalIndex(int ts); + /* Apply one time step */ + braid_Int Step(braid_Vector u_, braid_Vector ustop_, braid_Vector fstop_, + BraidStepStatus &pstatus); -/** - * Adjoint braid App for solving adjoint eqations with xbraid. - */ -class myAdjointBraidApp : public myBraidApp -{ - protected: - BraidCore* primalcore; /* pointer to primal core for accessing primal states */ - - public: - myAdjointBraidApp(DataSet* Data, - Network* Network, - Config* config, - BraidCore* Primalcoreptr, - MPI_Comm comm); - - ~myAdjointBraidApp(); - - /* Get the storage index of primal (reversed) */ - int GetPrimalIndex(int ts); - - /* Apply one time step */ - braid_Int Step(braid_Vector u_, - braid_Vector ustop_, - braid_Vector fstop_, - BraidStepStatus &pstatus); - - /* Allocate a new vector in *u_ptr and initialize it with an - initial guess appropriate for time t. */ - braid_Int Init(braid_Real t, - braid_Vector *u_ptr); - - /* @see braid_PtFcnBufSize. */ - braid_Int BufSize(braid_Int *size_ptr, - BraidBufferStatus &bstatus); - - /* @see braid_PtFcnBufPack. */ - braid_Int BufPack(braid_Vector u_, - void *buffer, - BraidBufferStatus &bstatus); - - /* @see braid_PtFcnBufUnpack. */ - braid_Int BufUnpack(void *buffer, - braid_Vector *u_ptr, - BraidBufferStatus &bstatus); + /* Allocate a new vector in *u_ptr and initialize it with an + initial guess appropriate for time t. */ + braid_Int Init(braid_Real t, braid_Vector *u_ptr); + + /* @see braid_PtFcnBufSize. */ + braid_Int BufSize(braid_Int *size_ptr, BraidBufferStatus &bstatus); + + /* @see braid_PtFcnBufPack. */ + braid_Int BufPack(braid_Vector u_, void *buffer, BraidBufferStatus &bstatus); + + /* @see braid_PtFcnBufUnpack. */ + braid_Int BufUnpack(void *buffer, braid_Vector *u_ptr, + BraidBufferStatus &bstatus); - /* Set the adjoint initial condition (derivative of primal objective function) */ - braid_Int SetInitialCondition(); + /* Set the adjoint initial condition (derivative of primal objective function) + */ + braid_Int SetInitialCondition(); - /* evaluate objective function (being just the derivative of the opening layer) */ - braid_Int EvaluateObjective(); -}; \ No newline at end of file + /* evaluate objective function (being just the derivative of the opening + * layer) */ + braid_Int EvaluateObjective(); +}; \ No newline at end of file diff --git a/include/config.hpp b/include/config.hpp index 01447d3..0620427 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -7,105 +7,104 @@ #define CONFIG_ARG_MAX_BYTES 128 /* Available activation functions */ -enum activation{TANH, RELU, SMRELU}; +enum activation { TANH, RELU, SMRELU }; /* Available network types */ -enum networkType{DENSE, CONVOLUTIONAL}; +enum networkType { DENSE, CONVOLUTIONAL }; /* Available batch types */ -enum batchtype{DETERMINISTIC, STOCHASTIC}; +enum batchtype { DETERMINISTIC, STOCHASTIC }; /* Available hessian approximation types */ -enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY}; +enum hessiantype { BFGS_SERIAL, LBFGS, IDENTITY }; /* Available stepsize selection methods */ -enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK}; +enum stepsizetype { FIXED, BACKTRACKINGLS, ONEOVERK }; class Config { - private: - - /* Linked list for reading config options */ - struct config_option { - struct config_option* prev; - // config_option_t prev; - char key[CONFIG_ARG_MAX_BYTES]; - char value[CONFIG_ARG_MAX_BYTES]; - }; - - /* Helper function: Parse the config file */ - config_option* parsefile(char* path); - - public: /* List all configuration options here */ - /* Data set */ - const char* datafolder; - const char* ftrain_ex; - const char* ftrain_labels; - const char* fval_ex; - const char* fval_labels; - const char* weightsopenfile; - const char* weightsclassificationfile; - - int ntraining; - int nvalidation; - int nfeatures; - int nclasses; - - /* Neural Network */ - int nchannels; - int nlayers; - MyReal T; - int activation; - int network_type; - int openlayer_type; - MyReal weights_open_init; - MyReal weights_init; - MyReal weights_class_init; - - /* XBraid */ - int braid_cfactor0; - int braid_cfactor; - int braid_maxlevels; - int braid_mincoarse; - int braid_maxiter; - MyReal braid_abstol; - MyReal braid_abstoladj; - int braid_printlevel; - int braid_accesslevel; - int braid_setskip; - int braid_fmg; - int braid_nrelax; - int braid_nrelax0; - - /* Optimization */ - int batch_type; - int nbatch; - MyReal gamma_tik; - MyReal gamma_ddt; - MyReal gamma_class; - int stepsize_type; - MyReal stepsize_init; - int maxoptimiter; - MyReal gtol; - int ls_maxiter; - MyReal ls_factor; - int hessianapprox_type; - int lbfgs_stages; - int validationlevel; - - - /* Constructor sets default values */ - Config(); - - /* Destructor */ - ~Config(); - - /* Reads the config options from file */ - int readFromFile(char* configfilename); - - /* Writes config options to the file (File must be open!) */ - int writeToFile(FILE* outfile); - - /* Returns a stepsize, depending on the selected stepsize type and current optimization iteration */ - MyReal getStepsize(int optimiter); +private: + /* Linked list for reading config options */ + struct config_option { + struct config_option *prev; + // config_option_t prev; + char key[CONFIG_ARG_MAX_BYTES]; + char value[CONFIG_ARG_MAX_BYTES]; + }; + + /* Helper function: Parse the config file */ + config_option *parsefile(char *path); + +public: /* List all configuration options here */ + /* Data set */ + const char *datafolder; + const char *ftrain_ex; + const char *ftrain_labels; + const char *fval_ex; + const char *fval_labels; + const char *weightsopenfile; + const char *weightsclassificationfile; + + int ntraining; + int nvalidation; + int nfeatures; + int nclasses; + + /* Neural Network */ + int nchannels; + int nlayers; + MyReal T; + int activation; + int network_type; + int openlayer_type; + MyReal weights_open_init; + MyReal weights_init; + MyReal weights_class_init; + + /* XBraid */ + int braid_cfactor0; + int braid_cfactor; + int braid_maxlevels; + int braid_mincoarse; + int braid_maxiter; + MyReal braid_abstol; + MyReal braid_abstoladj; + int braid_printlevel; + int braid_accesslevel; + int braid_setskip; + int braid_fmg; + int braid_nrelax; + int braid_nrelax0; + + /* Optimization */ + int batch_type; + int nbatch; + MyReal gamma_tik; + MyReal gamma_ddt; + MyReal gamma_class; + int stepsize_type; + MyReal stepsize_init; + int maxoptimiter; + MyReal gtol; + int ls_maxiter; + MyReal ls_factor; + int hessianapprox_type; + int lbfgs_stages; + int validationlevel; + + /* Constructor sets default values */ + Config(); + + /* Destructor */ + ~Config(); + + /* Reads the config options from file */ + int readFromFile(char *configfilename); + + /* Writes config options to the file (File must be open!) */ + int writeToFile(FILE *outfile); + + /* Returns a stepsize, depending on the selected stepsize type and current + * optimization iteration */ + MyReal getStepsize(int optimiter); }; diff --git a/include/dataset.hpp b/include/dataset.hpp index 686eca6..edebd4f 100644 --- a/include/dataset.hpp +++ b/include/dataset.hpp @@ -1,65 +1,59 @@ -#include -#include "util.hpp" -#include "defs.hpp" #include "config.hpp" +#include "defs.hpp" +#include "util.hpp" +#include #include #pragma once class DataSet { +protected: + int nelements; /* Number of data elements */ + int nfeatures; /* Number of features per element */ + int nlabels; /* Number of different labels (i.e. classes) per element */ - protected: - - int nelements; /* Number of data elements */ - int nfeatures; /* Number of features per element */ - int nlabels; /* Number of different labels (i.e. classes) per element */ - - MyReal **examples; /* Array of Feature vectors (dim: nelements x nfeatures) */ - MyReal **labels; /* Array of Label vectors (dim: nelements x nlabels) */ - - int nbatch; /* Size of the batch */ - int *batchIDs; /* Array of batch indicees */ - - int MPIsize; /* Size of the global communicator */ - int MPIrank; /* Processors rank */ - - int* availIDs; /* Auxilliary: holding available batchIDs when generating a batch */ - int navail; /* Auxilliary: holding number of currently available batchIDs */ + MyReal **examples; /* Array of Feature vectors (dim: nelements x nfeatures) */ + MyReal **labels; /* Array of Label vectors (dim: nelements x nlabels) */ - public: + int nbatch; /* Size of the batch */ + int *batchIDs; /* Array of batch indicees */ - /* Default constructor */ - DataSet(); + int MPIsize; /* Size of the global communicator */ + int MPIrank; /* Processors rank */ - /* Destructor */ - ~DataSet(); + int *availIDs; /* Auxilliary: holding available batchIDs when generating a + batch */ + int navail; /* Auxilliary: holding number of currently available batchIDs */ - void initialize(int nElements, - int nFeatures, - int nLabels, - int nBatch, - MPI_Comm Comm); +public: + /* Default constructor */ + DataSet(); + /* Destructor */ + ~DataSet(); - /* Return the batch size*/ - int getnBatch(); + void initialize(int nElements, int nFeatures, int nLabels, int nBatch, + MPI_Comm Comm); - /* Return the feature vector of a certain batchID. If not stored on this processor, return NULL */ - MyReal* getExample(int id); + /* Return the batch size*/ + int getnBatch(); - /* Return the label vector of a certain batchID. If not stored on this processor, return NULL */ - MyReal* getLabel(int id); + /* Return the feature vector of a certain batchID. If not stored on this + * processor, return NULL */ + MyReal *getExample(int id); - /* Read data from file */ - void readData(const char* datafolder, - const char* examplefile, - const char* labelfile); + /* Return the label vector of a certain batchID. If not stored on this + * processor, return NULL */ + MyReal *getLabel(int id); - /* Select the current batch from all available IDs, either deterministic or stochastic */ - void selectBatch(int batch_type, - MPI_Comm comm); + /* Read data from file */ + void readData(const char *datafolder, const char *examplefile, + const char *labelfile); + /* Select the current batch from all available IDs, either deterministic or + * stochastic */ + void selectBatch(int batch_type, MPI_Comm comm); - /* print current batch to screen */ - void printBatch(); + /* print current batch to screen */ + void printBatch(); }; \ No newline at end of file diff --git a/include/defs.hpp b/include/defs.hpp index d5e9b31..bdd6900 100644 --- a/include/defs.hpp +++ b/include/defs.hpp @@ -1,8 +1,9 @@ #include #pragma once -/* - * Switch between single (float) and double precision by un-/commenting the corresponding lines. +/* + * Switch between single (float) and double precision by un-/commenting the + * corresponding lines. */ // typedef float MyReal; diff --git a/include/hessianApprox.hpp b/include/hessianApprox.hpp index bd1dce6..42c0556 100644 --- a/include/hessianApprox.hpp +++ b/include/hessianApprox.hpp @@ -1,114 +1,89 @@ -#include -#include "linalg.hpp" #include "defs.hpp" +#include "linalg.hpp" +#include #pragma once class HessianApprox { - protected: - int dimN; /* Dimension of the gradient vector */ - MPI_Comm MPIcomm; /* MPI communicator for parallel L-BFGS updates */ +protected: + int dimN; /* Dimension of the gradient vector */ + MPI_Comm MPIcomm; /* MPI communicator for parallel L-BFGS updates */ - public: +public: + HessianApprox(MPI_Comm comm); + virtual ~HessianApprox(); - HessianApprox(MPI_Comm comm); - virtual ~HessianApprox(); - - /** - * Compute the BFGS descent direction - */ - virtual void computeAscentDir(int k, - MyReal* gradient, - MyReal* ascentdir) = 0; - - /** - * Update the BFGS memory (like s, y, rho, H0...) - */ - virtual void updateMemory(int k, - MyReal* design, - MyReal* gradient) = 0; + /** + * Compute the BFGS descent direction + */ + virtual void computeAscentDir(int k, MyReal *gradient, MyReal *ascentdir) = 0; + /** + * Update the BFGS memory (like s, y, rho, H0...) + */ + virtual void updateMemory(int k, MyReal *design, MyReal *gradient) = 0; }; - class L_BFGS : public HessianApprox { - protected: - int M; /* Length of the l-bfgs memory (stages) */ - - /* L-BFGS memory */ - MyReal** s; /* storing M (x_{k+1} - x_k) vectors */ - MyReal** y; /* storing M (\nabla f_{k+1} - \nabla f_k) vectors */ - MyReal* rho; /* storing M 1/y^Ts values */ - MyReal H0; /* Initial Hessian scaling factor */ - MyReal* design_old; /* Design at previous iteration */ - MyReal* gradient_old; /* Gradient at previous iteration */ +protected: + int M; /* Length of the l-bfgs memory (stages) */ - public: - L_BFGS(MPI_Comm comm, - int dimN, /* Local design dimension */ - int stage); - ~L_BFGS(); + /* L-BFGS memory */ + MyReal **s; /* storing M (x_{k+1} - x_k) vectors */ + MyReal **y; /* storing M (\nabla f_{k+1} - \nabla f_k) vectors */ + MyReal *rho; /* storing M 1/y^Ts values */ + MyReal H0; /* Initial Hessian scaling factor */ + MyReal *design_old; /* Design at previous iteration */ + MyReal *gradient_old; /* Gradient at previous iteration */ - void computeAscentDir(int k, - MyReal* gradient, - MyReal* ascentdir); +public: + L_BFGS(MPI_Comm comm, int dimN, /* Local design dimension */ + int stage); + ~L_BFGS(); - void updateMemory(int k, - MyReal* design, - MyReal* gradient); + void computeAscentDir(int k, MyReal *gradient, MyReal *ascentdir); - + void updateMemory(int k, MyReal *design, MyReal *gradient); }; - class BFGS : public HessianApprox { - private: - MyReal* A; - MyReal* B; - MyReal* Hy; - - protected: - MyReal* s; - MyReal* y; - MyReal* Hessian; /* Storing the Hessian approximation (flattened: dimN*dimN) */ - MyReal* design_old; /* Design at previous iteration */ - MyReal* gradient_old; /* Gradient at previous iteration */ - - public: - BFGS(MPI_Comm comm, int N); - ~BFGS(); - - void setIdentity(); - - void computeAscentDir(int k, - MyReal* gradient, - MyReal* ascentdir); - - void updateMemory(int k, - MyReal* design, - MyReal* gradient); -}; +private: + MyReal *A; + MyReal *B; + MyReal *Hy; +protected: + MyReal *s; + MyReal *y; + MyReal + *Hessian; /* Storing the Hessian approximation (flattened: dimN*dimN) */ + MyReal *design_old; /* Design at previous iteration */ + MyReal *gradient_old; /* Gradient at previous iteration */ +public: + BFGS(MPI_Comm comm, int N); + ~BFGS(); -/** - * No second order: Use Identity for Hessian Approximation - */ -class Identity : public HessianApprox{ + void setIdentity(); + + void computeAscentDir(int k, MyReal *gradient, MyReal *ascentdir); - public: - Identity(MPI_Comm comm, int N); - ~Identity(); + void updateMemory(int k, MyReal *design, MyReal *gradient); +}; + +/** + * No second order: Use Identity for Hessian Approximation + */ +class Identity : public HessianApprox { - void computeAscentDir(int k, - MyReal* currgrad, - MyReal* ascentdir); +public: + Identity(MPI_Comm comm, int N); + ~Identity(); - void updateMemory(int k, - MyReal* design, - MyReal* gradient); + void computeAscentDir(int k, MyReal *currgrad, MyReal *ascentdir); + void updateMemory(int k, MyReal *design, MyReal *gradient); }; diff --git a/include/layer.hpp b/include/layer.hpp index b33bcca..eefd261 100644 --- a/include/layer.hpp +++ b/include/layer.hpp @@ -1,194 +1,183 @@ -#include -#include +#include "config.hpp" +#include "defs.hpp" +#include "linalg.hpp" #include #include -#include "linalg.hpp" -#include "defs.hpp" -#include "config.hpp" - +#include +#include #pragma once /** - * Abstract base class for the network layers + * Abstract base class for the network layers * Subclasses implement - * - applyFWD: Forward propagation of data - * - applyBWD: Backward propagation of data + * - applyFWD: Forward propagation of data + * - applyBWD: Backward propagation of data */ -class Layer -{ - protected: - int dim_In; /* Dimension of incoming data */ - int dim_Out; /* Dimension of outgoing data */ - int dim_Bias; /* Dimension of the bias vector */ - int nweights; /* Number of weights */ - int ndesign; /* Total number of design variables */ - - int nconv; - int csize; - - int index; /* Number of the layer */ - MyReal dt; /* Step size for Layer update */ - MyReal* weights; /* Weight matrix, flattened as a vector */ - MyReal* weights_bar; /* Derivative of the Weight matrix*/ - MyReal* bias; /* Bias */ - MyReal* bias_bar; /* Derivative of bias */ - MyReal gamma_tik; /* Parameter for Tikhonov regularization of weights and bias */ - MyReal gamma_ddt; /* Parameter for DDT regularization of weights and bias */ - int activ; /* Activaation function (enum element) */ - int type; /* Type of the layer (enum element) */ - - MyReal *update; /* Auxilliary for computing fwd update */ - MyReal *update_bar; /* Auxilliary for computing bwd update */ - - public: - - /* Available layer types */ - enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6}; - - Layer(); - Layer(int idx, - int Type, - int dimI, - int dimO, - int dimB, - int dimW, // number of weights - MyReal deltaT, - int Activ, - MyReal gammatik, - MyReal gammaddt); - - virtual ~Layer(); - - /* Set time step size */ - void setDt(MyReal DT); - - /* Set design and gradient memory location */ - void setMemory(MyReal* design_memloc, - MyReal* gradient_memloc); - - /* Some Get..() functions */ - MyReal getDt(); - MyReal getGammaTik(); - MyReal getGammaDDT(); - int getActivation(); - int getType(); - - - /* Get pointer to the weights bias*/ - MyReal* getWeights(); - MyReal* getBias(); - - /* Get pointer to the weights bias bar */ - MyReal* getWeightsBar(); - MyReal* getBiasBar(); - - /* Get the dimensions */ - int getDimIn(); - int getDimOut(); - int getDimBias(); - int getnWeights(); - int getnDesign(); - - int getnConv(); - int getCSize(); - - /* Get the layer index (i.e. the time step) */ - int getIndex(); - - /* Prints to screen */ - void print_data(MyReal* data_Out); - - /* Activation function and derivative */ - MyReal activation(MyReal x); - MyReal dactivation(MyReal x); - - - /** - * Pack weights and bias into a buffer - */ - void packDesign(MyReal* buffer, - int size); - - /** - * Unpack weights and bias from a buffer - */ - void unpackDesign(MyReal* buffer); - - - /* Scales the weights by a factor and resets the gradient to zero. */ - void scaleDesign(MyReal factor); - - /** - * Sets the bar variables to zero - */ - void resetBar(); - - /** - * Evaluate Tikhonov Regularization - * Returns 1/2 * \|weights||^2 + 1/2 * \|bias\|^2 - */ - MyReal evalTikh(); - - /** - * Derivative of Tikhonov Regularization - */ - void evalTikh_diff(MyReal regul_bar); - - - /** - * Regularization for the time-derivative of the layer weights - */ - MyReal evalRegulDDT(Layer* layer_prev, - MyReal deltat); - - /** - * Derivative of ddt-regularization term - */ - void evalRegulDDT_diff(Layer* layer_prev, - Layer* layer_next, - MyReal deltat); - - - /** - * In opening layers: set pointer to the current example - */ - virtual void setExample(MyReal* example_ptr); - - /** - * In classification layers: set pointer to the current label - */ - virtual void setLabel(MyReal* label_ptr); - - /** - * Forward propagation of an example - * In/Out: vector holding the current propagated example - */ - virtual void applyFWD(MyReal* state) = 0; - - - /** - * Backward propagation of an example - * In: data - current example data - * In/Out: data_bar - adjoint example data that is to be propagated backwards - * In: compute_gradient - flag to determin if gradient should be computed (i.e. if weights_bar,bias_bar should be updated or not. In general, update is only done on the finest layer-grid.) - */ - virtual void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) = 0; - - /* ReLu Activation and derivative */ - MyReal ReLu_act(MyReal x); - MyReal dReLu_act(MyReal x); - - /* Smooth ReLu activation: Uses a quadratic approximation around zero (range: default 0.1) */ - MyReal SmoothReLu_act(MyReal x); - MyReal dSmoothReLu_act(MyReal x); - - /* tanh Activation and derivative */ - MyReal tanh_act(MyReal x); - MyReal dtanh_act(MyReal x); - +class Layer { +protected: + int dim_In; /* Dimension of incoming data */ + int dim_Out; /* Dimension of outgoing data */ + int dim_Bias; /* Dimension of the bias vector */ + int nweights; /* Number of weights */ + int ndesign; /* Total number of design variables */ + + int nconv; + int csize; + + int index; /* Number of the layer */ + MyReal dt; /* Step size for Layer update */ + MyReal *weights; /* Weight matrix, flattened as a vector */ + MyReal *weights_bar; /* Derivative of the Weight matrix*/ + MyReal *bias; /* Bias */ + MyReal *bias_bar; /* Derivative of bias */ + MyReal + gamma_tik; /* Parameter for Tikhonov regularization of weights and bias */ + MyReal gamma_ddt; /* Parameter for DDT regularization of weights and bias */ + int activ; /* Activaation function (enum element) */ + int type; /* Type of the layer (enum element) */ + + MyReal *update; /* Auxilliary for computing fwd update */ + MyReal *update_bar; /* Auxilliary for computing bwd update */ + +public: + /* Available layer types */ + enum layertype { + OPENZERO = 0, + OPENDENSE = 1, + DENSE = 2, + CLASSIFICATION = 3, + OPENCONV = 4, + OPENCONVMNIST = 5, + CONVOLUTION = 6 + }; + + Layer(); + Layer(int idx, int Type, int dimI, int dimO, int dimB, + int dimW, // number of weights + MyReal deltaT, int Activ, MyReal gammatik, MyReal gammaddt); + + virtual ~Layer(); + + /* Set time step size */ + void setDt(MyReal DT); + + /* Set design and gradient memory location */ + void setMemory(MyReal *design_memloc, MyReal *gradient_memloc); + + /* Some Get..() functions */ + MyReal getDt(); + MyReal getGammaTik(); + MyReal getGammaDDT(); + int getActivation(); + int getType(); + + /* Get pointer to the weights bias*/ + MyReal *getWeights(); + MyReal *getBias(); + + /* Get pointer to the weights bias bar */ + MyReal *getWeightsBar(); + MyReal *getBiasBar(); + + /* Get the dimensions */ + int getDimIn(); + int getDimOut(); + int getDimBias(); + int getnWeights(); + int getnDesign(); + + int getnConv(); + int getCSize(); + + /* Get the layer index (i.e. the time step) */ + int getIndex(); + + /* Prints to screen */ + void print_data(MyReal *data_Out); + + /* Activation function and derivative */ + MyReal activation(MyReal x); + MyReal dactivation(MyReal x); + + /** + * Pack weights and bias into a buffer + */ + void packDesign(MyReal *buffer, int size); + + /** + * Unpack weights and bias from a buffer + */ + void unpackDesign(MyReal *buffer); + + /* Scales the weights by a factor and resets the gradient to zero. */ + void scaleDesign(MyReal factor); + + /** + * Sets the bar variables to zero + */ + void resetBar(); + + /** + * Evaluate Tikhonov Regularization + * Returns 1/2 * \|weights||^2 + 1/2 * \|bias\|^2 + */ + MyReal evalTikh(); + + /** + * Derivative of Tikhonov Regularization + */ + void evalTikh_diff(MyReal regul_bar); + + /** + * Regularization for the time-derivative of the layer weights + */ + MyReal evalRegulDDT(Layer *layer_prev, MyReal deltat); + + /** + * Derivative of ddt-regularization term + */ + void evalRegulDDT_diff(Layer *layer_prev, Layer *layer_next, MyReal deltat); + + /** + * In opening layers: set pointer to the current example + */ + virtual void setExample(MyReal *example_ptr); + + /** + * In classification layers: set pointer to the current label + */ + virtual void setLabel(MyReal *label_ptr); + + /** + * Forward propagation of an example + * In/Out: vector holding the current propagated example + */ + virtual void applyFWD(MyReal *state) = 0; + + /** + * Backward propagation of an example + * In: data - current example data + * In/Out: data_bar - adjoint example data that is to be propagated backwards + * In: compute_gradient - flag to determin if gradient should be computed + * (i.e. if weights_bar,bias_bar should be updated or not. In general, update + * is only done on the finest layer-grid.) + */ + virtual void applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) = 0; + + /* ReLu Activation and derivative */ + MyReal ReLu_act(MyReal x); + MyReal dReLu_act(MyReal x); + + /* Smooth ReLu activation: Uses a quadratic approximation around zero (range: + * default 0.1) */ + MyReal SmoothReLu_act(MyReal x); + MyReal dSmoothReLu_act(MyReal x); + + /* tanh Activation and derivative */ + MyReal tanh_act(MyReal x); + MyReal dtanh_act(MyReal x); }; /** @@ -198,23 +187,15 @@ class Layer */ class DenseLayer : public Layer { - public: - DenseLayer(int idx, - int dimI, - int dimO, - MyReal deltaT, - int activation, - MyReal gammatik, - MyReal gammaddt); - ~DenseLayer(); - - void applyFWD(MyReal* state); - - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); -}; +public: + DenseLayer(int idx, int dimI, int dimO, MyReal deltaT, int activation, + MyReal gammatik, MyReal gammaddt); + ~DenseLayer(); + void applyFWD(MyReal *state); + + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); +}; /** * Opening Layer using dense weight matrix K \in R^{nxn} @@ -222,201 +203,168 @@ class DenseLayer : public Layer { */ class OpenDenseLayer : public DenseLayer { - protected: - MyReal* example; /* Pointer to the current example data */ +protected: + MyReal *example; /* Pointer to the current example data */ - public: - OpenDenseLayer(int dimI, - int dimO, - int activation, - MyReal gammatik); - ~OpenDenseLayer(); +public: + OpenDenseLayer(int dimI, int dimO, int activation, MyReal gammatik); + ~OpenDenseLayer(); - void setExample(MyReal* example_ptr); + void setExample(MyReal *example_ptr); - void applyFWD(MyReal* state); + void applyFWD(MyReal *state); - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); }; - - /* * Opening layer that expands the data by zeros */ -class OpenExpandZero : public Layer -{ - protected: - MyReal* example; /* Pointer to the current example data */ - public: - OpenExpandZero(int dimI, - int dimO); - ~OpenExpandZero(); - - void setExample(MyReal* example_ptr); - - void applyFWD(MyReal* state); - - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); -}; +class OpenExpandZero : public Layer { +protected: + MyReal *example; /* Pointer to the current example data */ +public: + OpenExpandZero(int dimI, int dimO); + ~OpenExpandZero(); + void setExample(MyReal *example_ptr); + + void applyFWD(MyReal *state); + + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); +}; /** * Classification layer */ -class ClassificationLayer : public Layer -{ - protected: - MyReal* label; /* Pointer to the current label vector */ - - MyReal* probability; /* vector of pedicted class probabilities */ - - public: - ClassificationLayer(int idx, - int dimI, - int dimO, - MyReal gammatik); - ~ClassificationLayer(); - - void setLabel(MyReal* label_ptr); - - void applyFWD(MyReal* state); - - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); - - /** - * Evaluate the cross entropy function - */ - MyReal crossEntropy(MyReal *finalstate); - - /** - * Algorithmic derivative of evaluating cross entropy loss - */ - void crossEntropy_diff(MyReal *data_Out, - MyReal *data_Out_bar, - MyReal loss_bar); - - /** - * Compute the class probabilities - * return 1 if predicted class was correct, 0 else. - * out: *class_id_ptr holding the predicted class - */ - int prediction(MyReal* data_out, - int* class_id_ptr); - - /** - * Translate the data: - * Substracts the maximum value from all entries - */ - void normalize(MyReal* data); - - /** - * Algorithmic derivative of the normalize funciton - */ - void normalize_diff(MyReal* data, - MyReal* data_bar); - +class ClassificationLayer : public Layer { +protected: + MyReal *label; /* Pointer to the current label vector */ + + MyReal *probability; /* vector of pedicted class probabilities */ + +public: + ClassificationLayer(int idx, int dimI, int dimO, MyReal gammatik); + ~ClassificationLayer(); + + void setLabel(MyReal *label_ptr); + + void applyFWD(MyReal *state); + + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); + + /** + * Evaluate the cross entropy function + */ + MyReal crossEntropy(MyReal *finalstate); + + /** + * Algorithmic derivative of evaluating cross entropy loss + */ + void crossEntropy_diff(MyReal *data_Out, MyReal *data_Out_bar, + MyReal loss_bar); + + /** + * Compute the class probabilities + * return 1 if predicted class was correct, 0 else. + * out: *class_id_ptr holding the predicted class + */ + int prediction(MyReal *data_out, int *class_id_ptr); + + /** + * Translate the data: + * Substracts the maximum value from all entries + */ + void normalize(MyReal *data); + + /** + * Algorithmic derivative of the normalize funciton + */ + void normalize_diff(MyReal *data, MyReal *data_bar); }; - /** - * Layer using a convolution C of size csize X csize, - * with nconv total convolutions. + * Layer using a convolution C of size csize X csize, + * with nconv total convolutions. * Layer transformation: y = y + dt * sigma(W(C) y + b) * if not openlayer: requires dimI = dimO ! */ class ConvLayer : public Layer { - int csize2; - int fcsize; - - int img_size; - int img_size_sqrt; - - public: - ConvLayer(int idx, - int dimI, - int dimO, - int csize_in, - int nconv_in, - MyReal deltaT, - int Activ, - MyReal Gammatik, - MyReal Gammaddt); - ~ConvLayer(); - - void applyFWD(MyReal* state); - - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); - - inline MyReal apply_conv(MyReal* state, // state vector to apply convolution to - int output_conv, // output convolution - int j, // row index - int k); // column index - - inline MyReal apply_conv_trans(MyReal* state, // state vector to apply convolution to - int output_conv, // output convolution - int j, // row index - int k); // column index - - /** - * This method is designed to be used only in the applyBWD. It computes the - * derivative of the objective with respect to the weights. In particular - * if you objective is $g$ and your kernel operator has value tau at index - * a,b then - * - * weights_bar[magic_index] = d_tau [ g] = \sum_{image j,k} tau state_{j+a,k+b} * update_bar_{j,k} - * - * Note that we assume that update_bar is - * - * update_bar = dt * dactivation * state_bar - * - * Where state_bar _must_ be at the old time. Note that the adjoint variable - * state_bar carries withit all the information of the objective derivative. - * - * On exit this method modifies weights_bar - */ - inline MyReal updateWeightDerivative( - MyReal* state, // state vector - MyReal * update_bar, // combines derivative and adjoint info (see comments) - int output_conv, // output convolution - int j, // row index - int k); // column index + int csize2; + int fcsize; + + int img_size; + int img_size_sqrt; + +public: + ConvLayer(int idx, int dimI, int dimO, int csize_in, int nconv_in, + MyReal deltaT, int Activ, MyReal Gammatik, MyReal Gammaddt); + ~ConvLayer(); + + void applyFWD(MyReal *state); + + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); + + inline MyReal + apply_conv(MyReal *state, // state vector to apply convolution to + int output_conv, // output convolution + int j, // row index + int k); // column index + + inline MyReal + apply_conv_trans(MyReal *state, // state vector to apply convolution to + int output_conv, // output convolution + int j, // row index + int k); // column index + + /** + * This method is designed to be used only in the applyBWD. It computes the + * derivative of the objective with respect to the weights. In particular + * if you objective is $g$ and your kernel operator has value tau at index + * a,b then + * + * weights_bar[magic_index] = d_tau [ g] = \sum_{image j,k} tau + * state_{j+a,k+b} * update_bar_{j,k} + * + * Note that we assume that update_bar is + * + * update_bar = dt * dactivation * state_bar + * + * Where state_bar _must_ be at the old time. Note that the adjoint variable + * state_bar carries withit all the information of the objective derivative. + * + * On exit this method modifies weights_bar + */ + inline MyReal updateWeightDerivative( + MyReal *state, // state vector + MyReal *update_bar, // combines derivative and adjoint info (see comments) + int output_conv, // output convolution + int j, // row index + int k); // column index }; - /** * Opening Layer for use with convolutional layers. Examples are replicated. * Layer transformation: y = ([I; I; ... I] y_ex) */ class OpenConvLayer : public Layer { - protected: - MyReal* example; /* Pointer to the current example data */ +protected: + MyReal *example; /* Pointer to the current example data */ - public: - OpenConvLayer(int dimI, - int dimO); - ~OpenConvLayer(); +public: + OpenConvLayer(int dimI, int dimO); + ~OpenConvLayer(); - void setExample(MyReal* example_ptr); + void setExample(MyReal *example_ptr); - void applyFWD(MyReal* state); + void applyFWD(MyReal *state); - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); }; -/** +/** * Opening Layer for use with convolutional layers. Examples are replicated * and then have an activation function applied. * @@ -427,16 +375,11 @@ class OpenConvLayer : public Layer { class OpenConvLayerMNIST : public OpenConvLayer { - public: - OpenConvLayerMNIST(int dimI, - int dimO); - ~OpenConvLayerMNIST(); +public: + OpenConvLayerMNIST(int dimI, int dimO); + ~OpenConvLayerMNIST(); - void applyFWD(MyReal* state); + void applyFWD(MyReal *state); - void applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient); + void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); }; - - diff --git a/include/linalg.hpp b/include/linalg.hpp index f8f2a77..f580e04 100644 --- a/include/linalg.hpp +++ b/include/linalg.hpp @@ -1,77 +1,55 @@ -#include -#include #include "defs.hpp" +#include #include +#include #pragma once - /** * Compute scalar product of two vectors xTy * In: dimension dimN * vectors x and y of dimemsion dimN * Out: returns xTy */ -MyReal vecdot(int dimN, - MyReal* x, - MyReal* y); - +MyReal vecdot(int dimN, MyReal *x, MyReal *y); /** - * Parallel dot-product xTy, invokes an MPI_Allreduce call + * Parallel dot-product xTy, invokes an MPI_Allreduce call * In: dimension dimN * vectors x and y of dimemsion dimN - * MPI communicator + * MPI communicator * Out: returns global xTy on all procs */ -MyReal vecdot_par(int dimN, - MyReal* x, - MyReal* y, - MPI_Comm comm); - +MyReal vecdot_par(int dimN, MyReal *x, MyReal *y, MPI_Comm comm); /** - * Return the maximum value of a vector + * Return the maximum value of a vector */ -MyReal vecmax(int dimN, - MyReal* x); - +MyReal vecmax(int dimN, MyReal *x); /** - * Return the index of the maximum entry of the vector + * Return the index of the maximum entry of the vector */ -int argvecmax(int dimN, - MyReal* x); - +int argvecmax(int dimN, MyReal *x); /** * Computes square of the l2-norm of x */ -MyReal vecnormsq(int dimN, - MyReal *x); +MyReal vecnormsq(int dimN, MyReal *x); /** * Parallel l2-norm computation, invokes an MPI_Allreduce x */ -MyReal vecnorm_par(int dimN, - MyReal *x, - MPI_Comm comm); - +MyReal vecnorm_par(int dimN, MyReal *x, MPI_Comm comm); /** - * Copy a vector u into u_copy + * Copy a vector u into u_copy */ -int vec_copy(int N, - MyReal* u, - MyReal* u_copy); - +int vec_copy(int N, MyReal *u, MyReal *u_copy); /** * Compute matrix x* y^T */ -void vecvecT(int N, - MyReal* x, - MyReal* y, - MyReal* XYT); +void vecvecT(int N, MyReal *x, MyReal *y, MyReal *XYT); /** * Compute Matrix-vector product Hx @@ -80,9 +58,4 @@ void vecvecT(int N, * vector x * Out: H*x will be stored in Hx */ -void matvec(int dimN, - MyReal* H, - MyReal* x, - MyReal* Hx); - - +void matvec(int dimN, MyReal *H, MyReal *x, MyReal *Hx); diff --git a/include/network.hpp b/include/network.hpp index a199586..ec32a6a 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -1,142 +1,130 @@ -#include +#include "config.hpp" +#include "dataset.hpp" #include "layer.hpp" +#include "util.hpp" #include #include #include +#include #include -#include "config.hpp" -#include "util.hpp" -#include "dataset.hpp" #pragma once +class Network { +protected: + int nlayers_global; /* Total number of Layers of the network */ + int nlayers_local; /* Number of Layers in this network block */ -class Network -{ - protected: - int nlayers_global; /* Total number of Layers of the network */ - int nlayers_local; /* Number of Layers in this network block */ + int nchannels; /* Width of the network */ + MyReal dt; /* Time step size */ + MyReal loss; /* Value of the loss function */ + MyReal accuracy; /* Accuracy of the network prediction (percentage of + successfully predicted classes) */ - int nchannels; /* Width of the network */ - MyReal dt; /* Time step size */ - MyReal loss; /* Value of the loss function */ - MyReal accuracy; /* Accuracy of the network prediction (percentage of successfully predicted classes) */ + int startlayerID; /* ID of the first layer on that processor */ + int endlayerID; /* ID of the last layer on that processor */ - int startlayerID; /* ID of the first layer on that processor */ - int endlayerID; /* ID of the last layer on that processor */ + int ndesign_global; /* Global number of design vars */ + int ndesign_local; /* Number of design vars of this local network block */ + int ndesign_layermax; /* Max. number of design variables of all hidden layers + */ - int ndesign_global; /* Global number of design vars */ - int ndesign_local; /* Number of design vars of this local network block */ - int ndesign_layermax; /* Max. number of design variables of all hidden layers */ - - MyReal* design; /* Local vector of design variables*/ - MyReal* gradient; /* Local Gradient */ + MyReal *design; /* Local vector of design variables*/ + MyReal *gradient; /* Local Gradient */ - Layer* openlayer; /* At first processor: openinglayer, else: NULL */ - Layer** layers; /* Array of hidden layers (includes classification layer at last processor */ - Layer* layer_left; /* Copy of last layer of left-neighbouring processor */ - Layer* layer_right; /* Copy of first layer of right-neighbouring processor */ - - MPI_Comm comm; /* MPI communicator */ - - public: - - Network(); - - ~Network(); - - void createNetworkBlock(int StartLayerID, - int EndLayerID, - Config* config, - MPI_Comm Comm); - - /* Get number of channels */ - int getnChannels(); - - /* Get global number of layers */ - int getnLayersGlobal(); - - /* Get initial time step size */ - MyReal getDT(); - - /* Get local storage index of the a layer */ - int getLocalID(int ilayer); - - /* Return value of the loss function */ - MyReal getLoss(); - - /* Return accuracy value */ - MyReal getAccuracy(); - - /* Return a pointer to the design vector */ - MyReal* getDesign(); - - /* Return a pointer to the gradient vector */ - MyReal* getGradient(); - - /* Get ID of first and last layer on this processor */ - int getStartLayerID(); - int getEndLayerID(); - - /** - * Return number of design variables (local on this processor or global) */ - int getnDesignLocal(); - int getnDesignGlobal(); - - /** - * Compute max. number of layer's ndesign on this processor - * excluding opening and classification layer - */ - int computeLayermax(); - - /* Return ndesign_layermax */ - int getnDesignLayermax(); - - /* Return MPI communicator */ - MPI_Comm getComm(); - - /** - * Get the layer at a certain layer index, i.e. a certain time step - * Returns NULL, if this layer is not stored on this processor - */ - Layer* getLayer(int layerindex); - - - /* - * Set an initial guess on the network design: - * Random initialization, scaled by given factors - * If set, reads in opening and classification weights from file - */ - void setInitialDesign(Config *config); - - - Layer* createLayer(int index, - Config *config); - - - /* Replace the layer with one that is received from the left neighbouring processor */ - void MPI_CommunicateNeighbours(MPI_Comm comm); - - /** - * Applies the classification and evaluates loss/accuracy - */ - void evalClassification(DataSet* data, - MyReal** state, - int output); - - /** - * On classification layer: derivative of evalClassification - */ - void evalClassification_diff(DataSet* data, - MyReal** primalstate, - MyReal** adjointstate, - int compute_gradient); - - - /** - * Update the network design parameters: new_design = old_design + stepsize * direction - */ - void updateDesign(MyReal stepsize, - MyReal *direction, - MPI_Comm comm); -}; + Layer *openlayer; /* At first processor: openinglayer, else: NULL */ + Layer **layers; /* Array of hidden layers (includes classification layer at + last processor */ + Layer *layer_left; /* Copy of last layer of left-neighbouring processor */ + Layer *layer_right; /* Copy of first layer of right-neighbouring processor */ + + MPI_Comm comm; /* MPI communicator */ + +public: + Network(); + + ~Network(); + + void createNetworkBlock(int StartLayerID, int EndLayerID, Config *config, + MPI_Comm Comm); + + /* Get number of channels */ + int getnChannels(); + + /* Get global number of layers */ + int getnLayersGlobal(); + + /* Get initial time step size */ + MyReal getDT(); + + /* Get local storage index of the a layer */ + int getLocalID(int ilayer); + /* Return value of the loss function */ + MyReal getLoss(); + + /* Return accuracy value */ + MyReal getAccuracy(); + + /* Return a pointer to the design vector */ + MyReal *getDesign(); + + /* Return a pointer to the gradient vector */ + MyReal *getGradient(); + + /* Get ID of first and last layer on this processor */ + int getStartLayerID(); + int getEndLayerID(); + + /** + * Return number of design variables (local on this processor or global) */ + int getnDesignLocal(); + int getnDesignGlobal(); + + /** + * Compute max. number of layer's ndesign on this processor + * excluding opening and classification layer + */ + int computeLayermax(); + + /* Return ndesign_layermax */ + int getnDesignLayermax(); + + /* Return MPI communicator */ + MPI_Comm getComm(); + + /** + * Get the layer at a certain layer index, i.e. a certain time step + * Returns NULL, if this layer is not stored on this processor + */ + Layer *getLayer(int layerindex); + + /* + * Set an initial guess on the network design: + * Random initialization, scaled by given factors + * If set, reads in opening and classification weights from file + */ + void setInitialDesign(Config *config); + + Layer *createLayer(int index, Config *config); + + /* Replace the layer with one that is received from the left neighbouring + * processor */ + void MPI_CommunicateNeighbours(MPI_Comm comm); + + /** + * Applies the classification and evaluates loss/accuracy + */ + void evalClassification(DataSet *data, MyReal **state, int output); + + /** + * On classification layer: derivative of evalClassification + */ + void evalClassification_diff(DataSet *data, MyReal **primalstate, + MyReal **adjointstate, int compute_gradient); + + /** + * Update the network design parameters: new_design = old_design + stepsize * + * direction + */ + void updateDesign(MyReal stepsize, MyReal *direction, MPI_Comm comm); +}; diff --git a/include/util.hpp b/include/util.hpp index d0cdf1b..d05ce0b 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -1,45 +1,32 @@ +#include "defs.hpp" +#include #include #include -#include -#include "defs.hpp" #pragma once /** - * Read data from file + * Read data from file */ -void read_matrix(char* filename, - MyReal** var, - int dimx, - int dimy); +void read_matrix(char *filename, MyReal **var, int dimx, int dimy); /** - * Read data from file + * Read data from file */ -void read_vector(char* filename, - MyReal* var, - int dimy); +void read_vector(char *filename, MyReal *var, int dimy); /** * Write data to file */ -void write_vector(char *filename, - MyReal *var, - int dimN); - +void write_vector(char *filename, MyReal *var, int dimN); /** * Gather a local vector of size localsendcount into global recvbuffer at root */ -void MPI_GatherVector(MyReal* sendbuffer, - int localsendcount, - MyReal* recvbuffer, - int rootprocessID, - MPI_Comm comm); +void MPI_GatherVector(MyReal *sendbuffer, int localsendcount, + MyReal *recvbuffer, int rootprocessID, MPI_Comm comm); /** - * Scatter parts of a global vector on root to local vectors on each processor (size localrecvsize) + * Scatter parts of a global vector on root to local vectors on each processor + * (size localrecvsize) */ -void MPI_ScatterVector(MyReal* sendbuffer, - MyReal* recvbuffer, - int localrecvcount, - int rootprocessID, - MPI_Comm comm); +void MPI_ScatterVector(MyReal *sendbuffer, MyReal *recvbuffer, + int localrecvcount, int rootprocessID, MPI_Comm comm); diff --git a/src/braid_wrapper.cpp b/src/braid_wrapper.cpp index 225823d..dde5e8f 100644 --- a/src/braid_wrapper.cpp +++ b/src/braid_wrapper.cpp @@ -1,819 +1,778 @@ #include "braid_wrapper.hpp" /* ========================================================= */ -myBraidVector::myBraidVector(int nChannels, - int nBatch) -{ - nchannels = nChannels; - nbatch = nBatch; - - - state = NULL; - layer = NULL; - sendflag = -1.0; - - /* Allocate the state vector */ - state = new MyReal*[nbatch]; - for (int iex = 0; iex < nbatch; iex++) - { - state[iex] = new MyReal[nchannels]; - for (int ic = 0; ic < nchannels; ic++) - { - state[iex][ic] = 0.0; - } +myBraidVector::myBraidVector(int nChannels, int nBatch) { + nchannels = nChannels; + nbatch = nBatch; + + state = NULL; + layer = NULL; + sendflag = -1.0; + + /* Allocate the state vector */ + state = new MyReal *[nbatch]; + for (int iex = 0; iex < nbatch; iex++) { + state[iex] = new MyReal[nchannels]; + for (int ic = 0; ic < nchannels; ic++) { + state[iex][ic] = 0.0; } + } } -myBraidVector::~myBraidVector() -{ - /* Deallocate the state vector */ - for (int iex = 0; iex < nbatch; iex++) - { - delete [] state[iex]; - } - delete [] state; - state = NULL; +myBraidVector::~myBraidVector() { + /* Deallocate the state vector */ + for (int iex = 0; iex < nbatch; iex++) { + delete[] state[iex]; + } + delete[] state; + state = NULL; } +int myBraidVector::getnChannels() { return nchannels; } -int myBraidVector::getnChannels() { return nchannels; } +int myBraidVector::getnBatch() { return nbatch; } -int myBraidVector::getnBatch() { return nbatch; } +MyReal *myBraidVector::getState(int exampleID) { return state[exampleID]; } -MyReal* myBraidVector::getState(int exampleID) { return state[exampleID]; } +MyReal **myBraidVector::getState() { return state; } -MyReal** myBraidVector::getState() { return state; } - -Layer* myBraidVector::getLayer() { return layer; } -void myBraidVector::setLayer(Layer* layerptr) { layer = layerptr; } - -MyReal myBraidVector::getSendflag() { return sendflag; } -void myBraidVector::setSendflag(MyReal value) { sendflag = value; } +Layer *myBraidVector::getLayer() { return layer; } +void myBraidVector::setLayer(Layer *layerptr) { layer = layerptr; } +MyReal myBraidVector::getSendflag() { return sendflag; } +void myBraidVector::setSendflag(MyReal value) { sendflag = value; } /* ========================================================= */ /* ========================================================= */ /* ========================================================= */ -myBraidApp::myBraidApp(DataSet* Data, - Network* Network, - Config* config, - MPI_Comm comm) : BraidApp(comm, 0.0, config->T, config->nlayers-2) -{ - MPI_Comm_rank(comm, &myid); - network = Network; - data = Data; - objective = 0.0; - - /* Initialize XBraid core */ - core = new BraidCore(comm, this); - - /* Set braid options */ - core->SetMaxLevels(config->braid_maxlevels); - core->SetMinCoarse(config->braid_mincoarse); - core->SetPrintLevel(config->braid_printlevel); - core->SetCFactor(0, config->braid_cfactor0); - core->SetCFactor(-1, config->braid_cfactor); - core->SetAccessLevel(config->braid_accesslevel); - core->SetMaxIter(config->braid_maxiter); - core->SetSkip(config->braid_setskip); - if (config->braid_fmg){ - core->SetFMG(); - } - core->SetNRelax(-1, config->braid_nrelax); - core->SetNRelax( 0, config->braid_nrelax0); - core->SetAbsTol(config->braid_abstol); - +myBraidApp::myBraidApp(DataSet *Data, Network *Network, Config *config, + MPI_Comm comm) + : BraidApp(comm, 0.0, config->T, config->nlayers - 2) { + MPI_Comm_rank(comm, &myid); + network = Network; + data = Data; + objective = 0.0; + + /* Initialize XBraid core */ + core = new BraidCore(comm, this); + + /* Set braid options */ + core->SetMaxLevels(config->braid_maxlevels); + core->SetMinCoarse(config->braid_mincoarse); + core->SetPrintLevel(config->braid_printlevel); + core->SetCFactor(0, config->braid_cfactor0); + core->SetCFactor(-1, config->braid_cfactor); + core->SetAccessLevel(config->braid_accesslevel); + core->SetMaxIter(config->braid_maxiter); + core->SetSkip(config->braid_setskip); + if (config->braid_fmg) { + core->SetFMG(); + } + core->SetNRelax(-1, config->braid_nrelax); + core->SetNRelax(0, config->braid_nrelax0); + core->SetAbsTol(config->braid_abstol); } -myBraidApp::~myBraidApp() -{ - /* Delete the core, if drive() has been called */ - if ( core->GetWarmRestart() ) delete core; +myBraidApp::~myBraidApp() { + /* Delete the core, if drive() has been called */ + if (core->GetWarmRestart()) + delete core; } MyReal myBraidApp::getObjective() { return objective; } -BraidCore* myBraidApp::getCore() { return core; } - -void myBraidApp::GetGridDistribution(int *ilower_ptr, - int *iupper_ptr) -{ - core->GetDistribution(ilower_ptr, iupper_ptr); -} +BraidCore *myBraidApp::getCore() { return core; } +void myBraidApp::GetGridDistribution(int *ilower_ptr, int *iupper_ptr) { + core->GetDistribution(ilower_ptr, iupper_ptr); +} -braid_Int myBraidApp::GetTimeStepIndex(MyReal t) -{ - /* Round to the closes integer */ - int ts = round(t / network->getDT()) ; - return ts; +braid_Int myBraidApp::GetTimeStepIndex(MyReal t) { + /* Round to the closes integer */ + int ts = round(t / network->getDT()); + return ts; } -braid_Int myBraidApp::Step(braid_Vector u_, - braid_Vector ustop_, - braid_Vector fstop_, - BraidStepStatus &pstatus) -{ - int ts_stop; - MyReal tstart, tstop; - MyReal deltaT; +braid_Int myBraidApp::Step(braid_Vector u_, braid_Vector ustop_, + braid_Vector fstop_, BraidStepStatus &pstatus) { + int ts_stop; + MyReal tstart, tstop; + MyReal deltaT; - myBraidVector *u = (myBraidVector*) u_; - int nbatch = data->getnBatch(); + myBraidVector *u = (myBraidVector *)u_; + int nbatch = data->getnBatch(); - /* Get the time-step size and current time index*/ - pstatus.GetTstartTstop(&tstart, &tstop); - ts_stop = GetTimeStepIndex(tstop); - deltaT = tstop - tstart; + /* Get the time-step size and current time index*/ + pstatus.GetTstartTstop(&tstart, &tstop); + ts_stop = GetTimeStepIndex(tstop); + deltaT = tstop - tstart; - /* Set time step size */ - u->getLayer()->setDt(deltaT); + /* Set time step size */ + u->getLayer()->setDt(deltaT); - // printf("%d: step %d,%f -> %d, %f layer %d using %1.14e state %1.14e, %d\n", app->myid, tstart, ts_stop, tstop, u->layer->getIndex(), u->layer->getWeights()[3], u->state[1][1], u->layer->getnDesign()); + // printf("%d: step %d,%f -> %d, %f layer %d using %1.14e state %1.14e, %d\n", + // app->myid, tstart, ts_stop, tstop, u->layer->getIndex(), + // u->layer->getWeights()[3], u->state[1][1], u->layer->getnDesign()); - /* apply the layer for all examples */ - for (int iex = 0; iex < nbatch; iex++) - { - /* Apply the layer */ - u->getLayer()->applyFWD(u->getState(iex)); - } + /* apply the layer for all examples */ + for (int iex = 0; iex < nbatch; iex++) { + /* Apply the layer */ + u->getLayer()->applyFWD(u->getState(iex)); + } + /* Free the layer, if it has just been send to this processor */ + if (u->getSendflag() > 0.0) { + delete[] u->getLayer()->getWeights(); + delete[] u->getLayer()->getWeightsBar(); + delete u->getLayer(); + } + u->setSendflag(-1.0); - /* Free the layer, if it has just been send to this processor */ - if (u->getSendflag() > 0.0) - { - delete [] u->getLayer()->getWeights(); - delete [] u->getLayer()->getWeightsBar(); - delete u->getLayer(); - } - u->setSendflag(-1.0); + /* Move the layer pointer of u forward to that of tstop */ + u->setLayer(network->getLayer(ts_stop)); - /* Move the layer pointer of u forward to that of tstop */ - u->setLayer(network->getLayer(ts_stop)); + /* no refinement */ + pstatus.SetRFactor(1); + return 0; +} - /* no refinement */ - pstatus.SetRFactor(1); +/* Compute residual: Does nothing. */ +braid_Int myBraidApp::Residual(braid_Vector u_, braid_Vector r_, + BraidStepStatus &pstatus) { + printf("\n\n I SHOUD NOT BE CALLED... I AM NOT IMPLEMENTED!\n\n"); - return 0; -} + return 0; +} -/* Compute residual: Does nothing. */ -braid_Int myBraidApp::Residual(braid_Vector u_, - braid_Vector r_, - BraidStepStatus &pstatus) -{ - printf("\n\n I SHOUD NOT BE CALLED... I AM NOT IMPLEMENTED!\n\n"); +braid_Int myBraidApp::Clone(braid_Vector u_, braid_Vector *v_ptr) { + myBraidVector *u = (myBraidVector *)u_; - return 0; -} + int nchannels = u->getnChannels(); + int nbatch = u->getnBatch(); -braid_Int myBraidApp::Clone(braid_Vector u_, - braid_Vector *v_ptr) -{ - myBraidVector *u = (myBraidVector*) u_; + /* Allocate a new vector */ + myBraidVector *v = new myBraidVector(nchannels, nbatch); - int nchannels = u->getnChannels(); - int nbatch = u->getnBatch(); + /* Copy the values */ + for (int iex = 0; iex < nbatch; iex++) { + for (int ic = 0; ic < nchannels; ic++) { + v->getState(iex)[ic] = u->getState(iex)[ic]; + } + } + v->setLayer(u->getLayer()); + v->setSendflag(u->getSendflag()); - /* Allocate a new vector */ - myBraidVector* v = new myBraidVector(nchannels, nbatch); + /* Set the return pointer */ + *v_ptr = (braid_Vector)v; - /* Copy the values */ - for (int iex = 0; iex < nbatch; iex++) - { - for (int ic = 0; ic < nchannels; ic++) - { - v->getState(iex)[ic] = u->getState(iex)[ic]; - } - } - v->setLayer(u->getLayer()); - v->setSendflag(u->getSendflag()); - - /* Set the return pointer */ - *v_ptr = (braid_Vector) v; - - return 0; + return 0; } -braid_Int myBraidApp::Init(braid_Real t, - braid_Vector *u_ptr) -{ - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); +braid_Int myBraidApp::Init(braid_Real t, braid_Vector *u_ptr) { + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); - myBraidVector* u = new myBraidVector(nchannels, nbatch); + myBraidVector *u = new myBraidVector(nchannels, nbatch); - /* Apply the opening layer */ - if (t == 0) - { - Layer* openlayer = network->getLayer(-1); - // printf("%d: Init %f: layer %d using %1.14e state %1.14e, %d\n", app->myid, t, openlayer->getIndex(), openlayer->getWeights()[3], u->state[1][1], openlayer->getnDesign()); - for (int iex = 0; iex < nbatch; iex++) - { - /* set example */ - openlayer->setExample(data->getExample(iex)); - - /* Apply the layer */ - openlayer->applyFWD(u->getState(iex)); - } - } - - /* Set the layer pointer */ - if (t >=0 ) // this should always be the case... - { - int ilayer = GetTimeStepIndex(t); - u->setLayer(network->getLayer(ilayer)); + /* Apply the opening layer */ + if (t == 0) { + Layer *openlayer = network->getLayer(-1); + // printf("%d: Init %f: layer %d using %1.14e state %1.14e, %d\n", + // app->myid, t, openlayer->getIndex(), openlayer->getWeights()[3], + // u->state[1][1], openlayer->getnDesign()); + for (int iex = 0; iex < nbatch; iex++) { + /* set example */ + openlayer->setExample(data->getExample(iex)); + + /* Apply the layer */ + openlayer->applyFWD(u->getState(iex)); } + } + + /* Set the layer pointer */ + if (t >= 0) // this should always be the case... + { + int ilayer = GetTimeStepIndex(t); + u->setLayer(network->getLayer(ilayer)); + } - /* Return the pointer */ - *u_ptr = (braid_Vector) u; + /* Return the pointer */ + *u_ptr = (braid_Vector)u; - return 0; -} + return 0; +} -braid_Int myBraidApp::Free(braid_Vector u_) -{ - myBraidVector *u = (myBraidVector*) u_; - delete u; - return 0; +braid_Int myBraidApp::Free(braid_Vector u_) { + myBraidVector *u = (myBraidVector *)u_; + delete u; + return 0; } -braid_Int myBraidApp::Sum(braid_Real alpha, - braid_Vector x_, - braid_Real beta, - braid_Vector y_) -{ - myBraidVector *x = (myBraidVector*) x_; - myBraidVector *y = (myBraidVector*) y_; +braid_Int myBraidApp::Sum(braid_Real alpha, braid_Vector x_, braid_Real beta, + braid_Vector y_) { + myBraidVector *x = (myBraidVector *)x_; + myBraidVector *y = (myBraidVector *)y_; - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); - for (int iex = 0; iex < nbatch; iex++) - { - for (int ic = 0; ic < nchannels; ic++) - { - y->getState(iex)[ic] = alpha*(x->getState(iex)[ic]) + beta*(y->getState(iex)[ic]); - } + for (int iex = 0; iex < nbatch; iex++) { + for (int ic = 0; ic < nchannels; ic++) { + y->getState(iex)[ic] = + alpha * (x->getState(iex)[ic]) + beta * (y->getState(iex)[ic]); } + } - return 0; + return 0; } - - -braid_Int myBraidApp::SpatialNorm(braid_Vector u_, - braid_Real *norm_ptr) -{ - myBraidVector *u = (myBraidVector*) u_; - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); - - MyReal dot = 0.0; - for (int iex = 0; iex < nbatch; iex++) - { - dot += vecdot(nchannels, u->getState(iex), u->getState(iex)); - } - *norm_ptr = sqrt(dot) / nbatch; +braid_Int myBraidApp::SpatialNorm(braid_Vector u_, braid_Real *norm_ptr) { + myBraidVector *u = (myBraidVector *)u_; + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); + MyReal dot = 0.0; + for (int iex = 0; iex < nbatch; iex++) { + dot += vecdot(nchannels, u->getState(iex), u->getState(iex)); + } + *norm_ptr = sqrt(dot) / nbatch; - return 0; + return 0; } -braid_Int myBraidApp::Access(braid_Vector u_, - BraidAccessStatus &astatus) -{ - printf("my_Access: To be implemented...\n"); +braid_Int myBraidApp::Access(braid_Vector u_, BraidAccessStatus &astatus) { + printf("my_Access: To be implemented...\n"); - return 0; + return 0; } -braid_Int myBraidApp::BufSize(braid_Int *size_ptr, - BraidBufferStatus &bstatus) -{ - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); +braid_Int myBraidApp::BufSize(braid_Int *size_ptr, BraidBufferStatus &bstatus) { + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); - /* Gather number of variables */ - int nuvector = nchannels*nbatch; - int nlayerinfo = 12; - int nlayerdesign = network->getnDesignLayermax(); + /* Gather number of variables */ + int nuvector = nchannels * nbatch; + int nlayerinfo = 12; + int nlayerdesign = network->getnDesignLayermax(); - /* Set the size */ - *size_ptr = (nuvector + nlayerinfo + nlayerdesign) * sizeof(MyReal); + /* Set the size */ + *size_ptr = (nuvector + nlayerinfo + nlayerdesign) * sizeof(MyReal); - return 0; + return 0; } -braid_Int myBraidApp::BufPack(braid_Vector u_, - void *buffer, - BraidBufferStatus &bstatus) -{ - int size; - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); - MyReal *dbuffer = (MyReal*) buffer; - myBraidVector *u = (myBraidVector*) u_; - - /* Store network state */ - int idx = 0; - for (int iex = 0; iex < nbatch; iex++) - { - for (int ic = 0; ic < nchannels; ic++) - { - dbuffer[idx] = u->getState(iex)[ic]; - idx++; - } - } - size = nchannels*nbatch*sizeof(MyReal); - - int nweights = u->getLayer()->getnWeights(); - int nbias = u->getLayer()->getDimBias(); - - dbuffer[idx] = u->getLayer()->getType(); idx++; - dbuffer[idx] = u->getLayer()->getIndex(); idx++; - dbuffer[idx] = u->getLayer()->getDimIn(); idx++; - dbuffer[idx] = u->getLayer()->getDimOut(); idx++; - dbuffer[idx] = u->getLayer()->getDimBias(); idx++; - dbuffer[idx] = u->getLayer()->getnWeights(); idx++; - dbuffer[idx] = u->getLayer()->getActivation(); idx++; - dbuffer[idx] = u->getLayer()->getnDesign(); idx++; - dbuffer[idx] = u->getLayer()->getGammaTik(); idx++; - dbuffer[idx] = u->getLayer()->getGammaDDT(); idx++; - dbuffer[idx] = u->getLayer()->getnConv(); idx++; - dbuffer[idx] = u->getLayer()->getCSize(); idx++; - for (int i = 0; i < nweights; i++) - { - dbuffer[idx] = u->getLayer()->getWeights()[i]; idx++; - // dbuffer[idx] = u->layer->getWeightsBar()[i]; idx++; - } - for (int i = 0; i < nbias; i++) - { - dbuffer[idx] = u->getLayer()->getBias()[i]; idx++; - // dbuffer[idx] = u->layer->getBiasBar()[i]; idx++; +braid_Int myBraidApp::BufPack(braid_Vector u_, void *buffer, + BraidBufferStatus &bstatus) { + int size; + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); + MyReal *dbuffer = (MyReal *)buffer; + myBraidVector *u = (myBraidVector *)u_; + + /* Store network state */ + int idx = 0; + for (int iex = 0; iex < nbatch; iex++) { + for (int ic = 0; ic < nchannels; ic++) { + dbuffer[idx] = u->getState(iex)[ic]; + idx++; } - size += (12 + (nweights+nbias))*sizeof(MyReal); - - bstatus.SetSize(size); - - return 0; + } + size = nchannels * nbatch * sizeof(MyReal); + + int nweights = u->getLayer()->getnWeights(); + int nbias = u->getLayer()->getDimBias(); + + dbuffer[idx] = u->getLayer()->getType(); + idx++; + dbuffer[idx] = u->getLayer()->getIndex(); + idx++; + dbuffer[idx] = u->getLayer()->getDimIn(); + idx++; + dbuffer[idx] = u->getLayer()->getDimOut(); + idx++; + dbuffer[idx] = u->getLayer()->getDimBias(); + idx++; + dbuffer[idx] = u->getLayer()->getnWeights(); + idx++; + dbuffer[idx] = u->getLayer()->getActivation(); + idx++; + dbuffer[idx] = u->getLayer()->getnDesign(); + idx++; + dbuffer[idx] = u->getLayer()->getGammaTik(); + idx++; + dbuffer[idx] = u->getLayer()->getGammaDDT(); + idx++; + dbuffer[idx] = u->getLayer()->getnConv(); + idx++; + dbuffer[idx] = u->getLayer()->getCSize(); + idx++; + for (int i = 0; i < nweights; i++) { + dbuffer[idx] = u->getLayer()->getWeights()[i]; + idx++; + // dbuffer[idx] = u->layer->getWeightsBar()[i]; idx++; + } + for (int i = 0; i < nbias; i++) { + dbuffer[idx] = u->getLayer()->getBias()[i]; + idx++; + // dbuffer[idx] = u->layer->getBiasBar()[i]; idx++; + } + size += (12 + (nweights + nbias)) * sizeof(MyReal); + + bstatus.SetSize(size); + + return 0; } +braid_Int myBraidApp::BufUnpack(void *buffer, braid_Vector *u_ptr, + BraidBufferStatus &bstatus) { + Layer *tmplayer = 0; + MyReal *dbuffer = (MyReal *)buffer; + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); -braid_Int myBraidApp::BufUnpack(void *buffer, - braid_Vector *u_ptr, - BraidBufferStatus &bstatus) -{ - Layer *tmplayer = 0; - MyReal *dbuffer = (MyReal*) buffer; - - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); - - /* Allocate a new vector */ - myBraidVector* u = new myBraidVector(nchannels, nbatch); + /* Allocate a new vector */ + myBraidVector *u = new myBraidVector(nchannels, nbatch); - /* Unpack the buffer */ - int idx = 0; - for (int iex = 0; iex < nbatch; iex++) - { - for (int ic = 0; ic < nchannels; ic++) - { - u->getState(iex)[ic] = dbuffer[idx]; - idx++; - } + /* Unpack the buffer */ + int idx = 0; + for (int iex = 0; iex < nbatch; iex++) { + for (int ic = 0; ic < nchannels; ic++) { + u->getState(iex)[ic] = dbuffer[idx]; + idx++; } - - /* Receive and initialize a layer. Set the sendflag */ - int layertype = dbuffer[idx]; idx++; - int index = dbuffer[idx]; idx++; - int dimIn = dbuffer[idx]; idx++; - int dimOut = dbuffer[idx]; idx++; - int dimBias = dbuffer[idx]; idx++; - int nweights = dbuffer[idx]; idx++; - int activ = dbuffer[idx]; idx++; - int nDesign = dbuffer[idx]; idx++; - int gammatik = dbuffer[idx]; idx++; - int gammaddt = dbuffer[idx]; idx++; - int nconv = dbuffer[idx]; idx++; - int csize = dbuffer[idx]; idx++; - - /* layertype decides on which layer should be created */ - switch (layertype) - { - case Layer::OPENZERO: - tmplayer = new OpenExpandZero(dimIn, dimOut); - break; - case Layer::OPENDENSE: - tmplayer = new OpenDenseLayer(dimIn, dimOut, activ, gammatik); - break; - case Layer::DENSE: - tmplayer = new DenseLayer(index, dimIn, dimOut, 1.0, activ, gammatik, gammaddt); - break; - case Layer::CLASSIFICATION: - tmplayer = new ClassificationLayer(index, dimIn, dimOut, gammatik); - break; - case Layer::OPENCONV: - tmplayer = new OpenConvLayer(dimIn, dimOut); - break; - case Layer::OPENCONVMNIST: - tmplayer = new OpenConvLayerMNIST(dimIn, dimOut); - break; - case Layer::CONVOLUTION: - tmplayer = new ConvLayer(index, dimIn, dimOut, csize, nconv, 1.0, activ, gammatik, gammaddt); - break; - default: - printf("\n\n ERROR while unpacking a buffer: Layertype unknown!!\n\n"); - } - - /* Allocate design and gradient */ - MyReal *design = new MyReal[nDesign]; - MyReal *gradient = new MyReal[nDesign]; - tmplayer->setMemory(design, gradient); - /* Set the weights */ - for (int i = 0; i < nweights; i++) - { - tmplayer->getWeights()[i] = dbuffer[idx]; idx++; - } - for (int i = 0; i < dimBias; i++) - { - tmplayer->getBias()[i] = dbuffer[idx]; idx++; - } - u->setLayer(tmplayer); - u->setSendflag(1.0); - - /* Return the pointer */ - *u_ptr = (braid_Vector) u; - return 0; + } + + /* Receive and initialize a layer. Set the sendflag */ + int layertype = dbuffer[idx]; + idx++; + int index = dbuffer[idx]; + idx++; + int dimIn = dbuffer[idx]; + idx++; + int dimOut = dbuffer[idx]; + idx++; + int dimBias = dbuffer[idx]; + idx++; + int nweights = dbuffer[idx]; + idx++; + int activ = dbuffer[idx]; + idx++; + int nDesign = dbuffer[idx]; + idx++; + int gammatik = dbuffer[idx]; + idx++; + int gammaddt = dbuffer[idx]; + idx++; + int nconv = dbuffer[idx]; + idx++; + int csize = dbuffer[idx]; + idx++; + + /* layertype decides on which layer should be created */ + switch (layertype) { + case Layer::OPENZERO: + tmplayer = new OpenExpandZero(dimIn, dimOut); + break; + case Layer::OPENDENSE: + tmplayer = new OpenDenseLayer(dimIn, dimOut, activ, gammatik); + break; + case Layer::DENSE: + tmplayer = + new DenseLayer(index, dimIn, dimOut, 1.0, activ, gammatik, gammaddt); + break; + case Layer::CLASSIFICATION: + tmplayer = new ClassificationLayer(index, dimIn, dimOut, gammatik); + break; + case Layer::OPENCONV: + tmplayer = new OpenConvLayer(dimIn, dimOut); + break; + case Layer::OPENCONVMNIST: + tmplayer = new OpenConvLayerMNIST(dimIn, dimOut); + break; + case Layer::CONVOLUTION: + tmplayer = new ConvLayer(index, dimIn, dimOut, csize, nconv, 1.0, activ, + gammatik, gammaddt); + break; + default: + printf("\n\n ERROR while unpacking a buffer: Layertype unknown!!\n\n"); + } + + /* Allocate design and gradient */ + MyReal *design = new MyReal[nDesign]; + MyReal *gradient = new MyReal[nDesign]; + tmplayer->setMemory(design, gradient); + /* Set the weights */ + for (int i = 0; i < nweights; i++) { + tmplayer->getWeights()[i] = dbuffer[idx]; + idx++; + } + for (int i = 0; i < dimBias; i++) { + tmplayer->getBias()[i] = dbuffer[idx]; + idx++; + } + u->setLayer(tmplayer); + u->setSendflag(1.0); + + /* Return the pointer */ + *u_ptr = (braid_Vector)u; + return 0; } +braid_Int myBraidApp::SetInitialCondition() { + Layer *openlayer = network->getLayer(-1); + int nbatch = data->getnBatch(); + braid_BaseVector ubase; + myBraidVector *u; + + /* Apply initial condition if warm_restart (otherwise it is set in my_Init() + */ + /* can not be set here if !(warm_restart) because braid_grid is created only + * in braid_drive(). */ + if (core->GetWarmRestart()) { + /* Get vector at t == 0 */ + _braid_UGetVectorRef(core->GetCore(), 0, 0, &ubase); + if (ubase != NULL) // only true on one first processor ! + { + u = (myBraidVector *)ubase->userVector; -braid_Int myBraidApp::SetInitialCondition() -{ - Layer* openlayer = network->getLayer(-1); - int nbatch = data->getnBatch(); - braid_BaseVector ubase; - myBraidVector* u; + /* Apply opening layer */ + for (int iex = 0; iex < nbatch; iex++) { + /* set example */ + openlayer->setExample(data->getExample(iex)); - /* Apply initial condition if warm_restart (otherwise it is set in my_Init() */ - /* can not be set here if !(warm_restart) because braid_grid is created only in braid_drive(). */ - if ( core->GetWarmRestart() ) - { - /* Get vector at t == 0 */ - _braid_UGetVectorRef(core->GetCore(), 0, 0, &ubase); - if (ubase != NULL) // only true on one first processor ! - { - u = (myBraidVector*) ubase->userVector; - - /* Apply opening layer */ - for (int iex = 0; iex < nbatch; iex++) - { - /* set example */ - openlayer->setExample(data->getExample(iex)); - - /* Apply the layer */ - openlayer->applyFWD(u->getState(iex)); - } - } + /* Apply the layer */ + openlayer->applyFWD(u->getState(iex)); + } } + } - return 0; + return 0; } - -braid_Int myBraidApp::EvaluateObjective() -{ - - - braid_BaseVector ubase; - myBraidVector* u; - Layer* layer; - MyReal myobjective; - MyReal regul; - - /* Get range of locally stored layers */ - int startlayerID = network->getStartLayerID(); - int endlayerID = network->getEndLayerID(); - if (startlayerID == 0) startlayerID -= 1; // this includes opening layer (id = -1) at first processor - - - /* Iterate over the local layers */ - regul = 0.0; - for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) - { - /* Get the layer */ - layer = network->getLayer(ilayer); - - /* Tikhonov - Regularization*/ - regul += layer->evalTikh(); - - /* DDT - Regularization on intermediate layers */ - regul += layer->evalRegulDDT(network->getLayer(ilayer-1), network->getDT()); - - /* At last layer: Classification and Loss evaluation */ - if (ilayer == network->getnLayersGlobal()-2) - { - _braid_UGetLast(core->GetCore(), &ubase); - u = (myBraidVector*) ubase->userVector; - network->evalClassification(data, u->getState(), 0); - } - // printf("%d: layerid %d using %1.14e, tik %1.14e, ddt %1.14e, loss %1.14e\n", app->myid, layer->getIndex(), layer->getWeights()[0], regultik, regulddt, loss_loc); +braid_Int myBraidApp::EvaluateObjective() { + + braid_BaseVector ubase; + myBraidVector *u; + Layer *layer; + MyReal myobjective; + MyReal regul; + + /* Get range of locally stored layers */ + int startlayerID = network->getStartLayerID(); + int endlayerID = network->getEndLayerID(); + if (startlayerID == 0) + startlayerID -= + 1; // this includes opening layer (id = -1) at first processor + + /* Iterate over the local layers */ + regul = 0.0; + for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { + /* Get the layer */ + layer = network->getLayer(ilayer); + + /* Tikhonov - Regularization*/ + regul += layer->evalTikh(); + + /* DDT - Regularization on intermediate layers */ + regul += + layer->evalRegulDDT(network->getLayer(ilayer - 1), network->getDT()); + + /* At last layer: Classification and Loss evaluation */ + if (ilayer == network->getnLayersGlobal() - 2) { + _braid_UGetLast(core->GetCore(), &ubase); + u = (myBraidVector *)ubase->userVector; + network->evalClassification(data, u->getState(), 0); } - - - /* Collect objective function from all processors */ - myobjective = network->getLoss() + regul; - objective = 0.0; - MPI_Allreduce(&myobjective, &objective, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - - return 0; + // printf("%d: layerid %d using %1.14e, tik %1.14e, ddt %1.14e, loss + // %1.14e\n", app->myid, layer->getIndex(), layer->getWeights()[0], + // regultik, regulddt, loss_loc); + } + + /* Collect objective function from all processors */ + myobjective = network->getLoss() + regul; + objective = 0.0; + MPI_Allreduce(&myobjective, &objective, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + + return 0; } +MyReal myBraidApp::run() { + int nreq = -1; + MyReal norm; + SetInitialCondition(); + core->Drive(); + EvaluateObjective(); + core->GetRNorms(&nreq, &norm); -MyReal myBraidApp::run() -{ - int nreq = -1; - MyReal norm; - - SetInitialCondition(); - core->Drive(); - EvaluateObjective(); - core->GetRNorms(&nreq, &norm); - - return norm; + return norm; } - - - /* ========================================================= */ /* ========================================================= */ /* ========================================================= */ -myAdjointBraidApp::myAdjointBraidApp(DataSet* Data, - Network* Network, - Config* config, - BraidCore* Primalcoreptr, - MPI_Comm comm) : myBraidApp(Data, Network, config, comm) -{ - primalcore = Primalcoreptr; +myAdjointBraidApp::myAdjointBraidApp(DataSet *Data, Network *Network, + Config *config, BraidCore *Primalcoreptr, + MPI_Comm comm) + : myBraidApp(Data, Network, config, comm) { + primalcore = Primalcoreptr; - /* Store all primal points */ - primalcore->SetStorage(0); + /* Store all primal points */ + primalcore->SetStorage(0); - /* Revert processor ranks for solving adjoint with xbraid */ - core->SetRevertedRanks(1); -} + /* Revert processor ranks for solving adjoint with xbraid */ + core->SetRevertedRanks(1); +} -myAdjointBraidApp::~myAdjointBraidApp(){} +myAdjointBraidApp::~myAdjointBraidApp() {} +int myAdjointBraidApp::GetPrimalIndex(int ts) { + int idx = network->getnLayersGlobal() - 2 - ts; + return idx; +} -int myAdjointBraidApp::GetPrimalIndex(int ts) -{ - int idx = network->getnLayersGlobal() - 2 - ts; - return idx; +braid_Int myAdjointBraidApp::Step(braid_Vector u_, braid_Vector ustop_, + braid_Vector fstop_, + BraidStepStatus &pstatus) { + int ts_stop; + int level, compute_gradient; + MyReal tstart, tstop; + MyReal deltaT; + int finegrid = 0; + int primaltimestep; + braid_BaseVector ubaseprimal; + myBraidVector *uprimal; + + int nbatch = data->getnBatch(); + myBraidVector *u = (myBraidVector *)u_; + + /* Update gradient only on the finest grid */ + pstatus.GetLevel(&level); + if (level == 0) + compute_gradient = 1; + else + compute_gradient = 0; + + /* Get the time-step size and current time index*/ + pstatus.GetTstartTstop(&tstart, &tstop); + ts_stop = GetTimeStepIndex(tstop); + deltaT = tstop - tstart; + primaltimestep = GetPrimalIndex(ts_stop); + + /* Get the primal vector from the primal core */ + _braid_UGetVectorRef(primalcore->GetCore(), finegrid, primaltimestep, + &ubaseprimal); + uprimal = (myBraidVector *)ubaseprimal->userVector; + + /* Reset gradient before the update */ + if (compute_gradient) + uprimal->getLayer()->resetBar(); + + /* Take one step backwards, updates adjoint state and gradient, if desired. */ + uprimal->getLayer()->setDt(deltaT); + for (int iex = 0; iex < nbatch; iex++) { + uprimal->getLayer()->applyBWD(uprimal->getState(iex), u->getState(iex), + compute_gradient); + } + + // printf("%d: level %d step_adj %d->%d using layer %d,%1.14e, primal %1.14e, + // adj %1.14e, grad[0] %1.14e, %d\n", app->myid, level, ts_stop, + // uprimal->layer->getIndex(), uprimal->layer->getWeights()[3], + // uprimal->state[1][1], u->state[1][1], uprimal->layer->getWeightsBar()[0], + // uprimal->layer->getnDesign()); + + /* Derivative of DDT-Regularization */ + if (compute_gradient) { + Layer *prev = network->getLayer(primaltimestep - 1); + Layer *next = network->getLayer(primaltimestep + 1); + uprimal->getLayer()->evalRegulDDT_diff(prev, next, network->getDT()); + } + + /* Derivative of tikhonov */ + if (compute_gradient) + uprimal->getLayer()->evalTikh_diff(1.0); + + /* no refinement */ + pstatus.SetRFactor(1); + + return 0; } +braid_Int myAdjointBraidApp::Init(braid_Real t, braid_Vector *u_ptr) { -braid_Int myAdjointBraidApp::Step(braid_Vector u_, - braid_Vector ustop_, - braid_Vector fstop_, - BraidStepStatus &pstatus) -{ - int ts_stop; - int level, compute_gradient; - MyReal tstart, tstop; - MyReal deltaT; - int finegrid = 0; - int primaltimestep; - braid_BaseVector ubaseprimal; - myBraidVector* uprimal; - - int nbatch = data->getnBatch(); - myBraidVector *u = (myBraidVector*) u_; - - /* Update gradient only on the finest grid */ - pstatus.GetLevel(&level); - if (level == 0) compute_gradient = 1; - else compute_gradient = 0; - - /* Get the time-step size and current time index*/ - pstatus.GetTstartTstop(&tstart, &tstop); - ts_stop = GetTimeStepIndex(tstop); - deltaT = tstop - tstart; - primaltimestep = GetPrimalIndex(ts_stop); - - /* Get the primal vector from the primal core */ - _braid_UGetVectorRef(primalcore->GetCore(), finegrid, primaltimestep, &ubaseprimal); - uprimal = (myBraidVector*) ubaseprimal->userVector; - - /* Reset gradient before the update */ - if (compute_gradient) uprimal->getLayer()->resetBar(); - - /* Take one step backwards, updates adjoint state and gradient, if desired. */ - uprimal->getLayer()->setDt(deltaT); - for (int iex = 0; iex < nbatch; iex++) - { - uprimal->getLayer()->applyBWD(uprimal->getState(iex), u->getState(iex), compute_gradient); - } + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); - // printf("%d: level %d step_adj %d->%d using layer %d,%1.14e, primal %1.14e, adj %1.14e, grad[0] %1.14e, %d\n", app->myid, level, ts_stop, uprimal->layer->getIndex(), uprimal->layer->getWeights()[3], uprimal->state[1][1], u->state[1][1], uprimal->layer->getWeightsBar()[0], uprimal->layer->getnDesign()); + braid_BaseVector ubaseprimal; + myBraidVector *uprimal; - /* Derivative of DDT-Regularization */ - if (compute_gradient) - { - Layer* prev = network->getLayer(primaltimestep - 1); - Layer* next = network->getLayer(primaltimestep + 1); - uprimal->getLayer()->evalRegulDDT_diff(prev, next, network->getDT()); - } + // printf("%d: Init %d (primaltimestep %d)\n", app->myid, ilayer, + // primaltimestep); - /* Derivative of tikhonov */ - if (compute_gradient) uprimal->getLayer()->evalTikh_diff(1.0); + /* Allocate the adjoint vector and set to zero */ + myBraidVector *u = new myBraidVector(nchannels, nbatch); - /* no refinement */ - pstatus.SetRFactor(1); + /* Adjoint initial (i.e. terminal) condition is derivative of classification + * layer */ + if (t == 0) { + /* Get the primal vector */ + _braid_UGetLast(primalcore->GetCore(), &ubaseprimal); + uprimal = (myBraidVector *)ubaseprimal->userVector; - return 0; -} + /* Reset the gradient before updating it */ + uprimal->getLayer()->resetBar(); + /* Derivative of classification */ + network->evalClassification_diff(data, uprimal->getState(), u->getState(), + 1); -braid_Int myAdjointBraidApp::Init(braid_Real t, - braid_Vector *u_ptr) -{ + /* Derivative of tikhonov regularization) */ + uprimal->getLayer()->evalTikh_diff(1.0); - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); + // printf("%d: Init_adj Loss at %d, using %1.14e, primal %1.14e, adj + // %1.14e, grad[0] %1.14e\n", app->myid, layer->getIndex(), + // layer->getWeights()[0], primalstate[1][1], u->state[1][1], + // layer->getWeightsBar()[0]); + } - braid_BaseVector ubaseprimal; - myBraidVector* uprimal; + *u_ptr = (braid_Vector)u; - // printf("%d: Init %d (primaltimestep %d)\n", app->myid, ilayer, primaltimestep); + return 0; +} - /* Allocate the adjoint vector and set to zero */ - myBraidVector* u = new myBraidVector(nchannels, nbatch); +braid_Int myAdjointBraidApp::BufSize(braid_Int *size_ptr, + BraidBufferStatus &bstatus) { + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); - /* Adjoint initial (i.e. terminal) condition is derivative of classification layer */ - if (t==0) - { - /* Get the primal vector */ - _braid_UGetLast(primalcore->GetCore(), &ubaseprimal); - uprimal = (myBraidVector*) ubaseprimal->userVector; + *size_ptr = nchannels * nbatch * sizeof(MyReal); + return 0; +} - /* Reset the gradient before updating it */ - uprimal->getLayer()->resetBar(); +braid_Int myAdjointBraidApp::BufPack(braid_Vector u_, void *buffer, + BraidBufferStatus &bstatus) { + + int size; + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); + MyReal *dbuffer = (MyReal *)buffer; + myBraidVector *u = (myBraidVector *)u_; + + /* Store network state */ + int idx = 0; + for (int iex = 0; iex < nbatch; iex++) { + for (int ic = 0; ic < nchannels; ic++) { + dbuffer[idx] = u->getState(iex)[ic]; + idx++; + } + } + size = nchannels * nbatch * sizeof(MyReal); - /* Derivative of classification */ - network->evalClassification_diff(data, uprimal->getState(), u->getState(), 1); + bstatus.SetSize(size); + return 0; +} - /* Derivative of tikhonov regularization) */ - uprimal->getLayer()->evalTikh_diff(1.0); - - // printf("%d: Init_adj Loss at %d, using %1.14e, primal %1.14e, adj %1.14e, grad[0] %1.14e\n", app->myid, layer->getIndex(), layer->getWeights()[0], primalstate[1][1], u->state[1][1], layer->getWeightsBar()[0]); - } +braid_Int myAdjointBraidApp::BufUnpack(void *buffer, braid_Vector *u_ptr, + BraidBufferStatus &bstatus) { - *u_ptr = (braid_Vector) u; - - return 0; -} - - -braid_Int myAdjointBraidApp::BufSize(braid_Int *size_ptr, - BraidBufferStatus &bstatus) -{ - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); - - *size_ptr = nchannels*nbatch*sizeof(MyReal); - return 0; -} - - -braid_Int myAdjointBraidApp::BufPack(braid_Vector u_, - void *buffer, - BraidBufferStatus &bstatus) -{ - - int size; - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); - MyReal *dbuffer = (MyReal*) buffer; - myBraidVector* u = (myBraidVector*) u_; - - /* Store network state */ - int idx = 0; - for (int iex = 0; iex < nbatch; iex++) - { - for (int ic = 0; ic < nchannels; ic++) - { - dbuffer[idx] = u->getState(iex)[ic]; - idx++; - } - } - size = nchannels*nbatch*sizeof(MyReal); - - bstatus.SetSize(size); - return 0; -} - -braid_Int myAdjointBraidApp::BufUnpack(void *buffer, - braid_Vector *u_ptr, - BraidBufferStatus &bstatus) -{ - - int nchannels = network->getnChannels(); - int nbatch = data->getnBatch(); - MyReal *dbuffer = (MyReal*) buffer; - - /* Allocate the vector */ - myBraidVector* u = new myBraidVector(nchannels, nbatch); - - /* Unpack the buffer */ - int idx = 0; - for (int iex = 0; iex < nbatch; iex++) - { - for (int ic = 0; ic < nchannels; ic++) - { - u->getState(iex)[ic] = dbuffer[idx]; - idx++; - } - } - u->setLayer(NULL); - u->setSendflag(-1.0); + int nchannels = network->getnChannels(); + int nbatch = data->getnBatch(); + MyReal *dbuffer = (MyReal *)buffer; - *u_ptr = (braid_Vector) u; - return 0; -} + /* Allocate the vector */ + myBraidVector *u = new myBraidVector(nchannels, nbatch); -braid_Int myAdjointBraidApp::SetInitialCondition() -{ - braid_BaseVector ubaseprimal, ubaseadjoint; - // braid_Vector uprimal, uadjoint; - myBraidVector *uprimal, *uadjoint; + /* Unpack the buffer */ + int idx = 0; + for (int iex = 0; iex < nbatch; iex++) { + for (int ic = 0; ic < nchannels; ic++) { + u->getState(iex)[ic] = dbuffer[idx]; + idx++; + } + } + u->setLayer(NULL); + u->setSendflag(-1.0); - /* Only gradient for primal time step N here. Other time steps are in my_Step_adj. */ + *u_ptr = (braid_Vector)u; + return 0; +} - /* If warm_restart: set adjoint initial condition here. Otherwise it's set in my_Init_Adj */ - /* It can not be done here if drive() has not been called before, because the braid grid is allocated only at the beginning of drive() */ - if ( core->GetWarmRestart() ) +braid_Int myAdjointBraidApp::SetInitialCondition() { + braid_BaseVector ubaseprimal, ubaseadjoint; + // braid_Vector uprimal, uadjoint; + myBraidVector *uprimal, *uadjoint; + + /* Only gradient for primal time step N here. Other time steps are in + * my_Step_adj. */ + + /* If warm_restart: set adjoint initial condition here. Otherwise it's set in + * my_Init_Adj */ + /* It can not be done here if drive() has not been called before, because the + * braid grid is allocated only at the beginning of drive() */ + if (core->GetWarmRestart()) { + /* Get primal and adjoint state */ + _braid_UGetLast(primalcore->GetCore(), &ubaseprimal); + _braid_UGetVectorRef(core->GetCore(), 0, 0, &ubaseadjoint); + + if (ubaseprimal != NULL && + ubaseadjoint != + NULL) // this is the case at first primal and last adjoint time step { - /* Get primal and adjoint state */ - _braid_UGetLast(primalcore->GetCore(), &ubaseprimal); - _braid_UGetVectorRef(core->GetCore(), 0, 0, &ubaseadjoint); - - if (ubaseprimal != NULL && ubaseadjoint !=NULL) // this is the case at first primal and last adjoint time step - { - uprimal = (myBraidVector*) ubaseprimal->userVector; - uadjoint = (myBraidVector*) ubaseadjoint->userVector; + uprimal = (myBraidVector *)ubaseprimal->userVector; + uadjoint = (myBraidVector *)ubaseadjoint->userVector; - /* Reset the gradient before updating it */ - uprimal->getLayer()->resetBar(); + /* Reset the gradient before updating it */ + uprimal->getLayer()->resetBar(); - // printf("%d: objective_diff at ilayer %d using %1.14e primal %1.14e\n", app->myid, uprimal->layer->getIndex(), uprimal->layer->getWeights()[0], uprimal->state[1][1]); + // printf("%d: objective_diff at ilayer %d using %1.14e primal %1.14e\n", + // app->myid, uprimal->layer->getIndex(), uprimal->layer->getWeights()[0], + // uprimal->state[1][1]); - /* Derivative of classification */ - network->evalClassification_diff(data, uprimal->getState(), uadjoint->getState(), 1); + /* Derivative of classification */ + network->evalClassification_diff(data, uprimal->getState(), + uadjoint->getState(), 1); - /* Derivative of tikhonov regularization) */ - uprimal->getLayer()->evalTikh_diff(1.0); - } - } + /* Derivative of tikhonov regularization) */ + uprimal->getLayer()->evalTikh_diff(1.0); + } + } - return 0; + return 0; } +braid_Int myAdjointBraidApp::EvaluateObjective() { + braid_BaseVector ubase; + myBraidVector *uadjoint; -braid_Int myAdjointBraidApp::EvaluateObjective() -{ - braid_BaseVector ubase; - myBraidVector* uadjoint; + Layer *openlayer = network->getLayer(-1); + int nbatch = data->getnBatch(); - Layer* openlayer = network->getLayer(-1); - int nbatch = data->getnBatch(); + /* Get \bar y^0 (which is the LAST xbraid vector, stored on proc 0) */ + _braid_UGetLast(core->GetCore(), &ubase); + if (ubase != NULL) // This is true only on first processor (reverted ranks!) + { + uadjoint = (myBraidVector *)ubase->userVector; - /* Get \bar y^0 (which is the LAST xbraid vector, stored on proc 0) */ - _braid_UGetLast(core->GetCore(), &ubase); - if (ubase != NULL) // This is true only on first processor (reverted ranks!) - { - uadjoint = (myBraidVector*) ubase->userVector; - - /* Reset the gradient */ - openlayer->resetBar(); - - /* Apply opening layer backwards for all examples */ - for (int iex = 0; iex < nbatch; iex++) - { - openlayer->setExample(data->getExample(iex)); - /* TODO: Don't feed applyBWD with NULL! */ - openlayer->applyBWD(NULL, uadjoint->getState(iex), 1); - } - - // printf("%d: Init_diff layerid %d using %1.14e, adj %1.14e grad[0] %1.14e\n", app->myid, openlayer->getIndex(), openlayer->getWeights()[3], ubase->userVector->state[1][1], openlayer->getWeightsBar()[0] ); - - /* Derivative of Tikhonov Regularization */ - openlayer->evalTikh_diff(1.0); + /* Reset the gradient */ + openlayer->resetBar(); + + /* Apply opening layer backwards for all examples */ + for (int iex = 0; iex < nbatch; iex++) { + openlayer->setExample(data->getExample(iex)); + /* TODO: Don't feed applyBWD with NULL! */ + openlayer->applyBWD(NULL, uadjoint->getState(iex), 1); } - return 0; + // printf("%d: Init_diff layerid %d using %1.14e, adj %1.14e grad[0] + // %1.14e\n", app->myid, openlayer->getIndex(), openlayer->getWeights()[3], + // ubase->userVector->state[1][1], openlayer->getWeightsBar()[0] ); + + /* Derivative of Tikhonov Regularization */ + openlayer->evalTikh_diff(1.0); + } + + return 0; } \ No newline at end of file diff --git a/src/config.cpp b/src/config.cpp index b610240..04cb47d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,571 +1,447 @@ #include "config.hpp" +#include #include #include -#include - - - -Config::Config() -{ - - /* --- Set DEFAULT parameters of the config file options --- */ - - /* Data st */ - datafolder = "NONE"; - ftrain_ex = "NONE"; - fval_ex = "NONE"; - ftrain_labels = "NONE"; - fval_labels = "NONE"; - weightsopenfile = "NONE"; - weightsclassificationfile = "NONE"; - - ntraining = 5000; - nvalidation = 200; - nfeatures = 2; - nclasses = 5; - - /* Neural Network */ - nchannels = 8; - nlayers = 32; - T = 10.0; - activation = RELU; - network_type = DENSE; - openlayer_type = 0; - weights_open_init = 0.001; - weights_init = 0.0; - weights_class_init = 0.001; - - /* XBraid */ - braid_cfactor0 = 4; - braid_cfactor = 4; - braid_maxlevels = 10; - braid_mincoarse = 10; - braid_maxiter = 3; - braid_abstol = 1e-10; - braid_abstoladj = 1e-06; - braid_printlevel = 1; - braid_accesslevel = 0; - braid_setskip = 0; - braid_fmg = 0; - braid_nrelax0 = 1; - braid_nrelax = 1; - - /* Optimization */ - batch_type = DETERMINISTIC; - nbatch = ntraining; // full batch - gamma_tik = 1e-07; - gamma_ddt = 1e-07; - gamma_class = 1e-07; - stepsize_type = BACKTRACKINGLS; - stepsize_init = 1.0; - maxoptimiter = 500; - gtol = 1e-08; - ls_maxiter = 20; - ls_factor = 0.5; - hessianapprox_type = LBFGS; - lbfgs_stages = 20; - validationlevel = 1; +Config::Config() { + + /* --- Set DEFAULT parameters of the config file options --- */ + + /* Data st */ + datafolder = "NONE"; + ftrain_ex = "NONE"; + fval_ex = "NONE"; + ftrain_labels = "NONE"; + fval_labels = "NONE"; + weightsopenfile = "NONE"; + weightsclassificationfile = "NONE"; + + ntraining = 5000; + nvalidation = 200; + nfeatures = 2; + nclasses = 5; + + /* Neural Network */ + nchannels = 8; + nlayers = 32; + T = 10.0; + activation = RELU; + network_type = DENSE; + openlayer_type = 0; + weights_open_init = 0.001; + weights_init = 0.0; + weights_class_init = 0.001; + + /* XBraid */ + braid_cfactor0 = 4; + braid_cfactor = 4; + braid_maxlevels = 10; + braid_mincoarse = 10; + braid_maxiter = 3; + braid_abstol = 1e-10; + braid_abstoladj = 1e-06; + braid_printlevel = 1; + braid_accesslevel = 0; + braid_setskip = 0; + braid_fmg = 0; + braid_nrelax0 = 1; + braid_nrelax = 1; + + /* Optimization */ + batch_type = DETERMINISTIC; + nbatch = ntraining; // full batch + gamma_tik = 1e-07; + gamma_ddt = 1e-07; + gamma_class = 1e-07; + stepsize_type = BACKTRACKINGLS; + stepsize_init = 1.0; + maxoptimiter = 500; + gtol = 1e-08; + ls_maxiter = 20; + ls_factor = 0.5; + hessianapprox_type = LBFGS; + lbfgs_stages = 20; + validationlevel = 1; } -Config::~Config(){} - - -int Config::readFromFile(char* configfilename) -{ - /* Parse the config file */ - config_option* co; - if ((co = parsefile(configfilename)) == NULL) { - perror("parsefile()"); - return -1; +Config::~Config() {} + +int Config::readFromFile(char *configfilename) { + /* Parse the config file */ + config_option *co; + if ((co = parsefile(configfilename)) == NULL) { + perror("parsefile()"); + return -1; + } + + /* Set the config options */ + while (1) { + + if (strcmp(co->key, "datafolder") == 0) { + datafolder = co->value; + } else if (strcmp(co->key, "ftrain_ex") == 0) { + ftrain_ex = co->value; + } else if (strcmp(co->key, "ftrain_labels") == 0) { + ftrain_labels = co->value; + } else if (strcmp(co->key, "fval_ex") == 0) { + fval_ex = co->value; + } else if (strcmp(co->key, "fval_labels") == 0) { + fval_labels = co->value; + } else if (strcmp(co->key, "ntraining") == 0) { + ntraining = atoi(co->value); + } else if (strcmp(co->key, "nvalidation") == 0) { + nvalidation = atoi(co->value); + } else if (strcmp(co->key, "nfeatures") == 0) { + nfeatures = atoi(co->value); + } else if (strcmp(co->key, "nchannels") == 0) { + nchannels = atoi(co->value); + } else if (strcmp(co->key, "nclasses") == 0) { + nclasses = atoi(co->value); } - - /* Set the config options */ - while(1) { - - if ( strcmp(co->key, "datafolder") == 0 ) - { - datafolder = co->value; - } - else if ( strcmp(co->key, "ftrain_ex") == 0 ) - { - ftrain_ex = co->value; - } - else if ( strcmp(co->key, "ftrain_labels") == 0 ) - { - ftrain_labels = co->value; - } - else if ( strcmp(co->key, "fval_ex") == 0 ) - { - fval_ex = co->value; - } - else if ( strcmp(co->key, "fval_labels") == 0 ) - { - fval_labels = co->value; - } - else if ( strcmp(co->key, "ntraining") == 0 ) - { - ntraining = atoi(co->value); - } - else if ( strcmp(co->key, "nvalidation") == 0 ) - { - nvalidation = atoi(co->value); - } - else if ( strcmp(co->key, "nfeatures") == 0 ) - { - nfeatures = atoi(co->value); - } - else if ( strcmp(co->key, "nchannels") == 0 ) - { - nchannels = atoi(co->value); - } - else if ( strcmp(co->key, "nclasses") == 0 ) - { - nclasses = atoi(co->value); - } - if ( strcmp(co->key, "weightsopenfile") == 0 ) - { - weightsopenfile = co->value; - } - if ( strcmp(co->key, "weightsclassificationfile") == 0 ) - { - weightsclassificationfile = co->value; - } - else if ( strcmp(co->key, "nlayers") == 0 ) - { - nlayers = atoi(co->value); - - if (nlayers < 3) - { - printf("\n\n ERROR: nlayers=%d too small! Choose minimum three layers (openlayer, one hidden layer, classification layer)!\n\n", nlayers); - return -1; - } - } - else if ( strcmp(co->key, "activation") == 0 ) - { - if (strcmp(co->value, "tanh") == 0 ) - { - activation = TANH; - } - else if ( strcmp(co->value, "ReLu") == 0 ) - { - activation = RELU; - } - else if (strcmp(co->value, "SmoothReLu") == 0 ) - { - activation = SMRELU; - } - else - { - printf("Invalid activation function!"); - return -1; - } - } - else if ( strcmp(co->key, "network_type") == 0 ) - { - if (strcmp(co->value, "dense") == 0 ) - { - network_type = DENSE; - } - else if (strcmp(co->value, "convolutional") == 0 ) - { - network_type = CONVOLUTIONAL; - } - else - { - printf("Invalid network type !"); - return -1; - } - } - else if ( strcmp(co->key, "T") == 0 ) - { - T = atof(co->value); - } - else if ( strcmp(co->key, "braid_cfactor") == 0 ) - { - braid_cfactor = atoi(co->value); - } - else if ( strcmp(co->key, "braid_cfactor0") == 0 ) - { - braid_cfactor0 = atoi(co->value); - } - else if ( strcmp(co->key, "braid_maxlevels") == 0 ) - { - braid_maxlevels = atoi(co->value); - } - else if ( strcmp(co->key, "braid_mincoarse") == 0 ) - { - braid_mincoarse = atoi(co->value); - } - else if ( strcmp(co->key, "braid_maxiter") == 0 ) - { - braid_maxiter = atoi(co->value); - } - else if ( strcmp(co->key, "braid_abstol") == 0 ) - { - braid_abstol = atof(co->value); - } - else if ( strcmp(co->key, "braid_adjtol") == 0 ) - { - braid_abstoladj = atof(co->value); - } - else if ( strcmp(co->key, "braid_printlevel") == 0 ) - { - braid_printlevel = atoi(co->value); - } - else if ( strcmp(co->key, "braid_accesslevel") == 0 ) - { - braid_accesslevel = atoi(co->value); - } - else if ( strcmp(co->key, "braid_setskip") == 0 ) - { - braid_setskip = atoi(co->value); - } - else if ( strcmp(co->key, "braid_fmg") == 0 ) - { - braid_fmg = atoi(co->value); - } - else if ( strcmp(co->key, "braid_nrelax") == 0 ) - { - braid_nrelax = atoi(co->value); - } - else if ( strcmp(co->key, "braid_nrelax0") == 0 ) - { - braid_nrelax0 = atoi(co->value); - } - else if (strcmp(co->key, "batch_type") == 0 ) - { - if ( strcmp(co->value, "deterministic") == 0 ) - { - batch_type = DETERMINISTIC; - } - else if (strcmp(co->value, "stochastic") == 0 ) - { - batch_type = STOCHASTIC; - } - else - { - printf("Invalid optimization type! Should be either 'deterministic' or 'stochastic'!"); - return -1; - } - } - else if ( strcmp(co->key, "nbatch") == 0 ) - { - nbatch = atoi(co->value); - } - else if ( strcmp(co->key, "gamma_tik") == 0 ) - { - gamma_tik = atof(co->value); - } - else if ( strcmp(co->key, "gamma_ddt") == 0 ) - { - gamma_ddt = atof(co->value); - } - else if ( strcmp(co->key, "gamma_class") == 0 ) - { - gamma_class= atof(co->value); - } - else if (strcmp(co->key, "stepsize_type") == 0 ) - { - if ( strcmp(co->value, "fixed") == 0 ) - { - stepsize_type = FIXED; - } - else if (strcmp(co->value, "backtrackingLS") == 0 ) - { - stepsize_type = BACKTRACKINGLS; - } - else if (strcmp(co->value, "oneoverk") == 0 ) - { - stepsize_type = ONEOVERK; - } - else - { - printf("Invalid stepsize type! Should be either 'fixed' or 'backtrackingLS' or 'oneoverk' !"); - return -1; - } - } - else if ( strcmp(co->key, "stepsize") == 0 ) - { - stepsize_init = atof(co->value); - } - else if ( strcmp(co->key, "optim_maxiter") == 0 ) - { - maxoptimiter = atoi(co->value); - } - else if ( strcmp(co->key, "gtol") == 0 ) - { - gtol = atof(co->value); - } - else if ( strcmp(co->key, "ls_maxiter") == 0 ) - { - ls_maxiter = atoi(co->value); - } - else if ( strcmp(co->key, "ls_factor") == 0 ) - { - ls_factor = atof(co->value); - } - else if ( strcmp(co->key, "weights_open_init") == 0 ) - { - weights_open_init = atof(co->value); - } - else if ( strcmp(co->key, "type_openlayer") == 0 ) - { - if (strcmp(co->value, "replicate") == 0 ) - { - openlayer_type = 0; - } - else if ( strcmp(co->value, "activate") == 0 ) - { - openlayer_type = 1; - } - else - { - printf("Invalid type_openlayer!\n"); - MPI_Finalize(); - return(0); - } - } - else if ( strcmp(co->key, "weights_init") == 0 ) - { - weights_init = atof(co->value); - } - else if ( strcmp(co->key, "weights_class_init") == 0 ) - { - weights_class_init = atof(co->value); - } - else if ( strcmp(co->key, "hessian_approx") == 0 ) - { - if ( strcmp(co->value, "BFGS") == 0 ) - { - hessianapprox_type = BFGS_SERIAL; - } - else if (strcmp(co->value, "L-BFGS") == 0 ) - { - hessianapprox_type = LBFGS; - } - else if (strcmp(co->value, "Identity") == 0 ) - { - hessianapprox_type = IDENTITY; - } - else - { - printf("Invalid Hessian approximation!"); - return -1; - } - } - else if ( strcmp(co->key, "lbfgs_stages") == 0 ) - { - lbfgs_stages = atoi(co->value); - } - else if ( strcmp(co->key, "validationlevel") == 0 ) - { - validationlevel = atoi(co->value); - } - if (co->prev != NULL) { - co = co->prev; - } else { - break; - } + if (strcmp(co->key, "weightsopenfile") == 0) { + weightsopenfile = co->value; } - - - /* Sanity check */ - if (nfeatures > nchannels || - nclasses > nchannels) - { - printf("ERROR! Choose a wider netword!\n"); - printf(" -- nFeatures = %d\n", nfeatures); - printf(" -- nChannels = %d\n", nchannels); - printf(" -- nClasses = %d\n", nclasses); - exit(1); + if (strcmp(co->key, "weightsclassificationfile") == 0) { + weightsclassificationfile = co->value; + } else if (strcmp(co->key, "nlayers") == 0) { + nlayers = atoi(co->value); + + if (nlayers < 3) { + printf("\n\n ERROR: nlayers=%d too small! Choose minimum three layers " + "(openlayer, one hidden layer, classification layer)!\n\n", + nlayers); + return -1; + } + } else if (strcmp(co->key, "activation") == 0) { + if (strcmp(co->value, "tanh") == 0) { + activation = TANH; + } else if (strcmp(co->value, "ReLu") == 0) { + activation = RELU; + } else if (strcmp(co->value, "SmoothReLu") == 0) { + activation = SMRELU; + } else { + printf("Invalid activation function!"); + return -1; + } + } else if (strcmp(co->key, "network_type") == 0) { + if (strcmp(co->value, "dense") == 0) { + network_type = DENSE; + } else if (strcmp(co->value, "convolutional") == 0) { + network_type = CONVOLUTIONAL; + } else { + printf("Invalid network type !"); + return -1; + } + } else if (strcmp(co->key, "T") == 0) { + T = atof(co->value); + } else if (strcmp(co->key, "braid_cfactor") == 0) { + braid_cfactor = atoi(co->value); + } else if (strcmp(co->key, "braid_cfactor0") == 0) { + braid_cfactor0 = atoi(co->value); + } else if (strcmp(co->key, "braid_maxlevels") == 0) { + braid_maxlevels = atoi(co->value); + } else if (strcmp(co->key, "braid_mincoarse") == 0) { + braid_mincoarse = atoi(co->value); + } else if (strcmp(co->key, "braid_maxiter") == 0) { + braid_maxiter = atoi(co->value); + } else if (strcmp(co->key, "braid_abstol") == 0) { + braid_abstol = atof(co->value); + } else if (strcmp(co->key, "braid_adjtol") == 0) { + braid_abstoladj = atof(co->value); + } else if (strcmp(co->key, "braid_printlevel") == 0) { + braid_printlevel = atoi(co->value); + } else if (strcmp(co->key, "braid_accesslevel") == 0) { + braid_accesslevel = atoi(co->value); + } else if (strcmp(co->key, "braid_setskip") == 0) { + braid_setskip = atoi(co->value); + } else if (strcmp(co->key, "braid_fmg") == 0) { + braid_fmg = atoi(co->value); + } else if (strcmp(co->key, "braid_nrelax") == 0) { + braid_nrelax = atoi(co->value); + } else if (strcmp(co->key, "braid_nrelax0") == 0) { + braid_nrelax0 = atoi(co->value); + } else if (strcmp(co->key, "batch_type") == 0) { + if (strcmp(co->value, "deterministic") == 0) { + batch_type = DETERMINISTIC; + } else if (strcmp(co->value, "stochastic") == 0) { + batch_type = STOCHASTIC; + } else { + printf("Invalid optimization type! Should be either 'deterministic' or " + "'stochastic'!"); + return -1; + } + } else if (strcmp(co->key, "nbatch") == 0) { + nbatch = atoi(co->value); + } else if (strcmp(co->key, "gamma_tik") == 0) { + gamma_tik = atof(co->value); + } else if (strcmp(co->key, "gamma_ddt") == 0) { + gamma_ddt = atof(co->value); + } else if (strcmp(co->key, "gamma_class") == 0) { + gamma_class = atof(co->value); + } else if (strcmp(co->key, "stepsize_type") == 0) { + if (strcmp(co->value, "fixed") == 0) { + stepsize_type = FIXED; + } else if (strcmp(co->value, "backtrackingLS") == 0) { + stepsize_type = BACKTRACKINGLS; + } else if (strcmp(co->value, "oneoverk") == 0) { + stepsize_type = ONEOVERK; + } else { + printf("Invalid stepsize type! Should be either 'fixed' or " + "'backtrackingLS' or 'oneoverk' !"); + return -1; + } + } else if (strcmp(co->key, "stepsize") == 0) { + stepsize_init = atof(co->value); + } else if (strcmp(co->key, "optim_maxiter") == 0) { + maxoptimiter = atoi(co->value); + } else if (strcmp(co->key, "gtol") == 0) { + gtol = atof(co->value); + } else if (strcmp(co->key, "ls_maxiter") == 0) { + ls_maxiter = atoi(co->value); + } else if (strcmp(co->key, "ls_factor") == 0) { + ls_factor = atof(co->value); + } else if (strcmp(co->key, "weights_open_init") == 0) { + weights_open_init = atof(co->value); + } else if (strcmp(co->key, "type_openlayer") == 0) { + if (strcmp(co->value, "replicate") == 0) { + openlayer_type = 0; + } else if (strcmp(co->value, "activate") == 0) { + openlayer_type = 1; + } else { + printf("Invalid type_openlayer!\n"); + MPI_Finalize(); + return (0); + } + } else if (strcmp(co->key, "weights_init") == 0) { + weights_init = atof(co->value); + } else if (strcmp(co->key, "weights_class_init") == 0) { + weights_class_init = atof(co->value); + } else if (strcmp(co->key, "hessian_approx") == 0) { + if (strcmp(co->value, "BFGS") == 0) { + hessianapprox_type = BFGS_SERIAL; + } else if (strcmp(co->value, "L-BFGS") == 0) { + hessianapprox_type = LBFGS; + } else if (strcmp(co->value, "Identity") == 0) { + hessianapprox_type = IDENTITY; + } else { + printf("Invalid Hessian approximation!"); + return -1; + } + } else if (strcmp(co->key, "lbfgs_stages") == 0) { + lbfgs_stages = atoi(co->value); + } else if (strcmp(co->key, "validationlevel") == 0) { + validationlevel = atoi(co->value); } - - return 0; + if (co->prev != NULL) { + co = co->prev; + } else { + break; + } + } + + /* Sanity check */ + if (nfeatures > nchannels || nclasses > nchannels) { + printf("ERROR! Choose a wider netword!\n"); + printf(" -- nFeatures = %d\n", nfeatures); + printf(" -- nChannels = %d\n", nchannels); + printf(" -- nClasses = %d\n", nclasses); + exit(1); + } + + return 0; } - - -Config::config_option* Config::parsefile(char* path) { - FILE* fp; - - if ((fp = fopen(path, "r+")) == NULL) { - perror("fopen()"); - return NULL; - } - - config_option* last_co_addr = NULL; - - while(1) { - config_option* co = NULL; - if ((co = (config_option*) calloc(1, sizeof(config_option))) == NULL) - continue; - memset(co, 0, sizeof(struct config_option)); - co->prev = last_co_addr; - - if (fscanf(fp, "%s = %s", &co->key[0], &co->value[0]) != 2) { - if (feof(fp)) { - break; - } - if (co->key[0] == '#') { - while (fgetc(fp) != '\n') { - // Do nothing (to move the cursor to the end of the line). - } - free(co); - continue; - } - perror("fscanf()"); - free(co); - continue; - } - //printf("Key: %s\nValue: %s\n", co->key, co->value); - last_co_addr = co; +Config::config_option *Config::parsefile(char *path) { + FILE *fp; + + if ((fp = fopen(path, "r+")) == NULL) { + perror("fopen()"); + return NULL; + } + + config_option *last_co_addr = NULL; + + while (1) { + config_option *co = NULL; + if ((co = (config_option *)calloc(1, sizeof(config_option))) == NULL) + continue; + memset(co, 0, sizeof(struct config_option)); + co->prev = last_co_addr; + + if (fscanf(fp, "%s = %s", &co->key[0], &co->value[0]) != 2) { + if (feof(fp)) { + break; + } + if (co->key[0] == '#') { + while (fgetc(fp) != '\n') { + // Do nothing (to move the cursor to the end of the line). + } + free(co); + continue; + } + perror("fscanf()"); + free(co); + continue; } - return last_co_addr; + // printf("Key: %s\nValue: %s\n", co->key, co->value); + last_co_addr = co; + } + return last_co_addr; } - - -int Config::writeToFile(FILE* outfile) -{ - const char *activname, *networktypename, *hessetypename, *optimtypename, *stepsizetypename; - - /* Get names of some int options */ - switch (activation) - { - case TANH: - activname = "tanh"; - break; - case RELU: - activname = "ReLu"; - break; - case SMRELU: - activname = "SmoothReLU"; - break; - default: - activname = "invalid!"; - } - switch (network_type) - { - case DENSE: - networktypename = "dense"; - break; - case CONVOLUTIONAL: - networktypename = "convolutional"; - break; - default: - networktypename = "invalid!"; - } - switch (hessianapprox_type) - { - case BFGS_SERIAL: - hessetypename = "BFGS"; - break; - case LBFGS: - hessetypename = "L-BFGS"; - break; - case IDENTITY: - hessetypename = "Identity"; - break; - default: - hessetypename = "invalid!"; - } - switch (batch_type) - { - case DETERMINISTIC: - optimtypename = "deterministic"; - break; - case STOCHASTIC: - optimtypename = "stochastic"; - break; - default: - optimtypename = "invalid!"; - } - switch (stepsize_type) - { - case FIXED: - stepsizetypename = "fixed"; - break; - case BACKTRACKINGLS: - stepsizetypename = "backtracking line-search"; - break; - case ONEOVERK: - stepsizetypename = "1/k"; - break; - default: - stepsizetypename = "invalid!"; - } - - - /* print config option */ - fprintf(outfile, "# Problem setup: datafolder %s \n", datafolder); - fprintf(outfile, "# training examples %s \n", ftrain_ex); - fprintf(outfile, "# training labels %s \n", ftrain_labels); - fprintf(outfile, "# validation examples %s \n", fval_ex); - fprintf(outfile, "# validation labels %s \n", fval_labels); - fprintf(outfile, "# ntraining %d \n", ntraining); - fprintf(outfile, "# nvalidation %d \n", nvalidation); - fprintf(outfile, "# nfeatures %d \n", nfeatures); - fprintf(outfile, "# nclasses %d \n", nclasses); - fprintf(outfile, "# nchannels %d \n", nchannels); - fprintf(outfile, "# nlayers %d \n", nlayers); - fprintf(outfile, "# T %f \n", T); - fprintf(outfile, "# network type %s \n", networktypename); - fprintf(outfile, "# Activation %s \n", activname); - fprintf(outfile, "# openlayer type %d \n", openlayer_type); - fprintf(outfile, "# XBraid setup: max levels %d \n", braid_maxlevels); - fprintf(outfile, "# min coarse %d \n", braid_mincoarse); - fprintf(outfile, "# coasening %d \n", braid_cfactor); - fprintf(outfile, "# coasening (level 0) %d \n", braid_cfactor0); - fprintf(outfile, "# max. braid iter %d \n", braid_maxiter); - fprintf(outfile, "# abs. tol %1.e \n", braid_abstol); - fprintf(outfile, "# abs. toladj %1.e \n", braid_abstoladj); - fprintf(outfile, "# print level %d \n", braid_printlevel); - fprintf(outfile, "# access level %d \n", braid_accesslevel); - fprintf(outfile, "# skip? %d \n", braid_setskip); - fprintf(outfile, "# fmg? %d \n", braid_fmg); - fprintf(outfile, "# nrelax (level 0) %d \n", braid_nrelax0); - fprintf(outfile, "# nrelax %d \n", braid_nrelax); - fprintf(outfile, "# Optimization: optimization type %s \n", optimtypename); - fprintf(outfile, "# nbatch %d \n", nbatch); - fprintf(outfile, "# gamma_tik %1.e \n", gamma_tik); - fprintf(outfile, "# gamma_ddt %1.e \n", gamma_ddt); - fprintf(outfile, "# gamma_class %1.e \n", gamma_class); - fprintf(outfile, "# stepsize type %s \n", stepsizetypename); - fprintf(outfile, "# stepsize %f \n", stepsize_init); - fprintf(outfile, "# max. optim iter %d \n", maxoptimiter); - fprintf(outfile, "# gtol %1.e \n", gtol); - fprintf(outfile, "# max. ls iter %d \n", ls_maxiter); - fprintf(outfile, "# ls factor %f \n", ls_factor); - fprintf(outfile, "# weights_init %f \n", weights_init); - fprintf(outfile, "# weights_open_init %f \n", weights_open_init); - fprintf(outfile, "# weights_class_init %f \n", weights_class_init) ; - fprintf(outfile, "# hessianapprox_type %s \n", hessetypename); - fprintf(outfile, "# lbfgs_stages %d \n", lbfgs_stages); - fprintf(outfile, "# validationlevel %d \n", validationlevel); - fprintf(outfile, "\n"); - - return 0; +int Config::writeToFile(FILE *outfile) { + const char *activname, *networktypename, *hessetypename, *optimtypename, + *stepsizetypename; + + /* Get names of some int options */ + switch (activation) { + case TANH: + activname = "tanh"; + break; + case RELU: + activname = "ReLu"; + break; + case SMRELU: + activname = "SmoothReLU"; + break; + default: + activname = "invalid!"; + } + switch (network_type) { + case DENSE: + networktypename = "dense"; + break; + case CONVOLUTIONAL: + networktypename = "convolutional"; + break; + default: + networktypename = "invalid!"; + } + switch (hessianapprox_type) { + case BFGS_SERIAL: + hessetypename = "BFGS"; + break; + case LBFGS: + hessetypename = "L-BFGS"; + break; + case IDENTITY: + hessetypename = "Identity"; + break; + default: + hessetypename = "invalid!"; + } + switch (batch_type) { + case DETERMINISTIC: + optimtypename = "deterministic"; + break; + case STOCHASTIC: + optimtypename = "stochastic"; + break; + default: + optimtypename = "invalid!"; + } + switch (stepsize_type) { + case FIXED: + stepsizetypename = "fixed"; + break; + case BACKTRACKINGLS: + stepsizetypename = "backtracking line-search"; + break; + case ONEOVERK: + stepsizetypename = "1/k"; + break; + default: + stepsizetypename = "invalid!"; + } + + /* print config option */ + fprintf(outfile, "# Problem setup: datafolder %s \n", datafolder); + fprintf(outfile, "# training examples %s \n", ftrain_ex); + fprintf(outfile, "# training labels %s \n", + ftrain_labels); + fprintf(outfile, "# validation examples %s \n", fval_ex); + fprintf(outfile, "# validation labels %s \n", fval_labels); + fprintf(outfile, "# ntraining %d \n", ntraining); + fprintf(outfile, "# nvalidation %d \n", nvalidation); + fprintf(outfile, "# nfeatures %d \n", nfeatures); + fprintf(outfile, "# nclasses %d \n", nclasses); + fprintf(outfile, "# nchannels %d \n", nchannels); + fprintf(outfile, "# nlayers %d \n", nlayers); + fprintf(outfile, "# T %f \n", T); + fprintf(outfile, "# network type %s \n", + networktypename); + fprintf(outfile, "# Activation %s \n", activname); + fprintf(outfile, "# openlayer type %d \n", + openlayer_type); + fprintf(outfile, "# XBraid setup: max levels %d \n", + braid_maxlevels); + fprintf(outfile, "# min coarse %d \n", + braid_mincoarse); + fprintf(outfile, "# coasening %d \n", + braid_cfactor); + fprintf(outfile, "# coasening (level 0) %d \n", + braid_cfactor0); + fprintf(outfile, "# max. braid iter %d \n", + braid_maxiter); + fprintf(outfile, "# abs. tol %1.e \n", + braid_abstol); + fprintf(outfile, "# abs. toladj %1.e \n", + braid_abstoladj); + fprintf(outfile, "# print level %d \n", + braid_printlevel); + fprintf(outfile, "# access level %d \n", + braid_accesslevel); + fprintf(outfile, "# skip? %d \n", + braid_setskip); + fprintf(outfile, "# fmg? %d \n", braid_fmg); + fprintf(outfile, "# nrelax (level 0) %d \n", + braid_nrelax0); + fprintf(outfile, "# nrelax %d \n", braid_nrelax); + fprintf(outfile, "# Optimization: optimization type %s \n", + optimtypename); + fprintf(outfile, "# nbatch %d \n", nbatch); + fprintf(outfile, "# gamma_tik %1.e \n", gamma_tik); + fprintf(outfile, "# gamma_ddt %1.e \n", gamma_ddt); + fprintf(outfile, "# gamma_class %1.e \n", + gamma_class); + fprintf(outfile, "# stepsize type %s \n", + stepsizetypename); + fprintf(outfile, "# stepsize %f \n", + stepsize_init); + fprintf(outfile, "# max. optim iter %d \n", maxoptimiter); + fprintf(outfile, "# gtol %1.e \n", gtol); + fprintf(outfile, "# max. ls iter %d \n", ls_maxiter); + fprintf(outfile, "# ls factor %f \n", ls_factor); + fprintf(outfile, "# weights_init %f \n", weights_init); + fprintf(outfile, "# weights_open_init %f \n", + weights_open_init); + fprintf(outfile, "# weights_class_init %f \n", + weights_class_init); + fprintf(outfile, "# hessianapprox_type %s \n", + hessetypename); + fprintf(outfile, "# lbfgs_stages %d \n", lbfgs_stages); + fprintf(outfile, "# validationlevel %d \n", + validationlevel); + fprintf(outfile, "\n"); + + return 0; } - - -MyReal Config::getStepsize(int optimiter) -{ - MyReal stepsize = 0.0; - - switch (stepsize_type) - { - case FIXED: - stepsize = stepsize_init; - break; - case BACKTRACKINGLS: - stepsize = stepsize_init; - break; - case ONEOVERK: - stepsize = 1.0 / (MyReal) (optimiter+1); // add one because optimiter starts with 0 - } - - return stepsize; +MyReal Config::getStepsize(int optimiter) { + MyReal stepsize = 0.0; + + switch (stepsize_type) { + case FIXED: + stepsize = stepsize_init; + break; + case BACKTRACKINGLS: + stepsize = stepsize_init; + break; + case ONEOVERK: + stepsize = 1.0 / (MyReal)(optimiter + + 1); // add one because optimiter starts with 0 + } + + return stepsize; } diff --git a/src/dataset.cpp b/src/dataset.cpp index ac0a617..054d502 100644 --- a/src/dataset.cpp +++ b/src/dataset.cpp @@ -1,209 +1,184 @@ #include "dataset.hpp" -DataSet::DataSet() -{ - nelements = 0; - nfeatures = 0; - nlabels = 0; - nbatch = 0; - MPIsize = 0; - MPIrank = 0; - navail = 0; - - examples = NULL; - labels = NULL; - batchIDs = NULL; - availIDs = NULL; +DataSet::DataSet() { + nelements = 0; + nfeatures = 0; + nlabels = 0; + nbatch = 0; + MPIsize = 0; + MPIrank = 0; + navail = 0; + + examples = NULL; + labels = NULL; + batchIDs = NULL; + availIDs = NULL; } -void DataSet::initialize(int nElements, - int nFeatures, - int nLabels, - int nBatch, - MPI_Comm comm) -{ - - - nelements = nElements; - nfeatures = nFeatures; - nlabels = nLabels; - nbatch = nBatch; - navail = nelements; - - MPI_Comm_rank(comm, &MPIrank); - MPI_Comm_size(comm, &MPIsize); - - /* Sanity check */ - if (nbatch > nelements) nbatch = nelements; - - /* Allocate feature vectors on first processor */ - if (MPIrank == 0) - { - examples = new MyReal*[nelements]; - for (int ielem = 0; ielem < nelements; ielem++) - { - examples[ielem] = new MyReal[nfeatures]; - } - } - /* Allocate label vectors on last processor */ - if (MPIrank == MPIsize - 1) - { - labels = new MyReal*[nelements]; - for (int ielem = 0; ielem < nelements; ielem++) - { - labels[ielem] = new MyReal[nlabels]; - } - } - - /* Allocate and initialize availIDs and batchIDs on first and last processor */ - if (MPIrank == 0 || MPIrank == MPIsize - 1) - { - availIDs = new int[nelements]; // all elements - batchIDs = new int[nbatch]; - - /* Initialize available ID with identity */ - for (int idx = 0; idx < nelements; idx++) - { - availIDs[idx] = idx; - } - - /* Initialize the batch with identity */ - for (int idx = 0; idx < nbatch; idx++) - { - batchIDs[idx] = idx; - } - } +void DataSet::initialize(int nElements, int nFeatures, int nLabels, int nBatch, + MPI_Comm comm) { + + nelements = nElements; + nfeatures = nFeatures; + nlabels = nLabels; + nbatch = nBatch; + navail = nelements; + + MPI_Comm_rank(comm, &MPIrank); + MPI_Comm_size(comm, &MPIsize); + + /* Sanity check */ + if (nbatch > nelements) + nbatch = nelements; + + /* Allocate feature vectors on first processor */ + if (MPIrank == 0) { + examples = new MyReal *[nelements]; + for (int ielem = 0; ielem < nelements; ielem++) { + examples[ielem] = new MyReal[nfeatures]; + } + } + /* Allocate label vectors on last processor */ + if (MPIrank == MPIsize - 1) { + labels = new MyReal *[nelements]; + for (int ielem = 0; ielem < nelements; ielem++) { + labels[ielem] = new MyReal[nlabels]; + } + } + + /* Allocate and initialize availIDs and batchIDs on first and last processor + */ + if (MPIrank == 0 || MPIrank == MPIsize - 1) { + availIDs = new int[nelements]; // all elements + batchIDs = new int[nbatch]; + + /* Initialize available ID with identity */ + for (int idx = 0; idx < nelements; idx++) { + availIDs[idx] = idx; + } + + /* Initialize the batch with identity */ + for (int idx = 0; idx < nbatch; idx++) { + batchIDs[idx] = idx; + } + } } - -DataSet::~DataSet() -{ - /* Deallocate feature vectors on first processor */ - if (examples != NULL) - { - for (int ielem = 0; ielem < nelements; ielem++) - { - delete [] examples[ielem]; - } - delete [] examples; - } - - /* Deallocate label vectors on last processor */ - if (labels != NULL) - { - for (int ielem = 0; ielem < nelements; ielem++) - { - delete [] labels[ielem]; - } - delete [] labels; - } - - if (availIDs != NULL) delete [] availIDs; - if (batchIDs != NULL) delete [] batchIDs; +DataSet::~DataSet() { + /* Deallocate feature vectors on first processor */ + if (examples != NULL) { + for (int ielem = 0; ielem < nelements; ielem++) { + delete[] examples[ielem]; + } + delete[] examples; + } + + /* Deallocate label vectors on last processor */ + if (labels != NULL) { + for (int ielem = 0; ielem < nelements; ielem++) { + delete[] labels[ielem]; + } + delete[] labels; + } + + if (availIDs != NULL) + delete[] availIDs; + if (batchIDs != NULL) + delete[] batchIDs; } - int DataSet::getnBatch() { return nbatch; } -MyReal* DataSet::getExample(int id) -{ - if (examples == NULL) return NULL; +MyReal *DataSet::getExample(int id) { + if (examples == NULL) + return NULL; - return examples[batchIDs[id]]; + return examples[batchIDs[id]]; } -MyReal* DataSet::getLabel(int id) -{ - if (labels == NULL) return NULL; - - return labels[batchIDs[id]]; +MyReal *DataSet::getLabel(int id) { + if (labels == NULL) + return NULL; + + return labels[batchIDs[id]]; } -void DataSet::readData(const char* datafolder, - const char* examplefile, - const char* labelfile) -{ - char examplefilename[255], labelfilename[255]; +void DataSet::readData(const char *datafolder, const char *examplefile, + const char *labelfile) { + char examplefilename[255], labelfilename[255]; - /* Set the file names */ - sprintf(examplefilename, "%s/%s", datafolder, examplefile); - sprintf(labelfilename, "%s/%s", datafolder, labelfile); + /* Set the file names */ + sprintf(examplefilename, "%s/%s", datafolder, examplefile); + sprintf(labelfilename, "%s/%s", datafolder, labelfile); - /* Read feature vectors on first processor */ - if (MPIrank == 0) read_matrix(examplefilename, examples, nelements, nfeatures); + /* Read feature vectors on first processor */ + if (MPIrank == 0) + read_matrix(examplefilename, examples, nelements, nfeatures); - /* Read label vectors on last processor) */ - if (MPIrank == MPIsize - 1) read_matrix(labelfilename, labels, nelements, nlabels); + /* Read label vectors on last processor) */ + if (MPIrank == MPIsize - 1) + read_matrix(labelfilename, labels, nelements, nlabels); } +void DataSet::selectBatch(int batch_type, MPI_Comm comm) { + int irand, rand_range; + int tmp; + MPI_Request sendreq, recvreq; + MPI_Status status; + + switch (batch_type) { + case DETERMINISTIC: + /* Do nothing, keep the batch fixed. */ + break; + + case STOCHASTIC: + + /* Randomly choose a batch on first processor, send to last processor */ + if (MPIrank == 0) { + /* Fill the batchID vector with randomly generated integer */ + rand_range = navail - 1; + for (int ibatch = 0; ibatch < nbatch; ibatch++) { + /* Generate a new random index in [0,range] */ + irand = (int)((((double)rand()) / (double)RAND_MAX) * rand_range); + + /* Set the batchID */ + batchIDs[ibatch] = availIDs[irand]; + + /* Remove the ID from available IDs (by swapping it with the last + * available id and reducing the range) */ + tmp = availIDs[irand]; + availIDs[irand] = availIDs[rand_range]; + availIDs[rand_range] = tmp; + rand_range--; + } - -void DataSet::selectBatch(int batch_type, - MPI_Comm comm) -{ - int irand, rand_range; - int tmp; - MPI_Request sendreq, recvreq; - MPI_Status status; - - switch (batch_type) - { - case DETERMINISTIC: - /* Do nothing, keep the batch fixed. */ - break; - - case STOCHASTIC: - - /* Randomly choose a batch on first processor, send to last processor */ - if (MPIrank == 0) - { - /* Fill the batchID vector with randomly generated integer */ - rand_range = navail - 1; - for (int ibatch = 0; ibatch < nbatch; ibatch++) - { - /* Generate a new random index in [0,range] */ - irand = (int) ( ( ((double) rand()) / (double) RAND_MAX ) * rand_range ); - - /* Set the batchID */ - batchIDs[ibatch] = availIDs[irand]; - - /* Remove the ID from available IDs (by swapping it with the last available id and reducing the range) */ - tmp = availIDs[irand]; - availIDs[irand] = availIDs[rand_range]; - availIDs[rand_range] = tmp; - rand_range--; - } - - /* Send to the last processor */ - int receiver = MPIsize - 1; - MPI_Isend(batchIDs, nbatch, MPI_INT, receiver, 0, comm, &sendreq); - } - - /* Receive the batch IDs on last processor */ - if (MPIrank == MPIsize - 1) - { - int source = 0; - MPI_Irecv(batchIDs, nbatch, MPI_INT, source, 0, comm, &recvreq); - } - - /* Wait to finish communication */ - if (MPIrank == 0) MPI_Wait(&sendreq, &status); - if (MPIrank == MPIsize-1) MPI_Wait(&recvreq, &status); - - - break; // break switch statement - } + /* Send to the last processor */ + int receiver = MPIsize - 1; + MPI_Isend(batchIDs, nbatch, MPI_INT, receiver, 0, comm, &sendreq); + } + + /* Receive the batch IDs on last processor */ + if (MPIrank == MPIsize - 1) { + int source = 0; + MPI_Irecv(batchIDs, nbatch, MPI_INT, source, 0, comm, &recvreq); + } + + /* Wait to finish communication */ + if (MPIrank == 0) + MPI_Wait(&sendreq, &status); + if (MPIrank == MPIsize - 1) + MPI_Wait(&recvreq, &status); + + break; // break switch statement + } } - -void DataSet::printBatch() -{ - if (batchIDs != NULL) // only first and last processor - { - printf("%d:\n", MPIrank); - for (int ibatch = 0; ibatch < nbatch; ibatch++) - { - printf("%d, %04d\n", ibatch, batchIDs[ibatch]); - } - } +void DataSet::printBatch() { + if (batchIDs != NULL) // only first and last processor + { + printf("%d:\n", MPIrank); + for (int ibatch = 0; ibatch < nbatch; ibatch++) { + printf("%d, %04d\n", ibatch, batchIDs[ibatch]); + } + } } diff --git a/src/hessianApprox.cpp b/src/hessianApprox.cpp index 97ab982..2c8cc9f 100644 --- a/src/hessianApprox.cpp +++ b/src/hessianApprox.cpp @@ -1,326 +1,258 @@ #include "hessianApprox.hpp" -HessianApprox::HessianApprox(MPI_Comm comm) -{ - dimN = 0; +HessianApprox::HessianApprox(MPI_Comm comm) { + dimN = 0; MPIcomm = comm; } -HessianApprox::~HessianApprox(){} - - -L_BFGS::L_BFGS(MPI_Comm comm, int N, int stages) : HessianApprox(comm) -{ - dimN = N; - M = stages; - H0 = 1.0; - - /* Allocate memory for sk and yk for all stages */ - s = new MyReal*[M]; - y = new MyReal*[M]; - for (int imem = 0; imem < M; imem++) - { - s[imem] = new MyReal[dimN]; - y[imem] = new MyReal[dimN]; - for (int i = 0; i < dimN; i++) - { - s[imem][i] = 0.0; - y[imem][i] = 0.0; - } - } - - /* Allocate memory for rho's values */ - rho = new MyReal[M]; - for (int i = 0; i < M; i++) - { - rho[i] = 0.0; - } - - /* Allocate memory for storing design at previous iteration */ - design_old = new MyReal[dimN]; - gradient_old = new MyReal[dimN]; +HessianApprox::~HessianApprox() {} + +L_BFGS::L_BFGS(MPI_Comm comm, int N, int stages) : HessianApprox(comm) { + dimN = N; + M = stages; + H0 = 1.0; + + /* Allocate memory for sk and yk for all stages */ + s = new MyReal *[M]; + y = new MyReal *[M]; + for (int imem = 0; imem < M; imem++) { + s[imem] = new MyReal[dimN]; + y[imem] = new MyReal[dimN]; + for (int i = 0; i < dimN; i++) { + s[imem][i] = 0.0; + y[imem][i] = 0.0; + } + } + + /* Allocate memory for rho's values */ + rho = new MyReal[M]; + for (int i = 0; i < M; i++) { + rho[i] = 0.0; + } + + /* Allocate memory for storing design at previous iteration */ + design_old = new MyReal[dimN]; + gradient_old = new MyReal[dimN]; } +L_BFGS::~L_BFGS() { + /* Deallocate memory */ + delete[] rho; + for (int imem = 0; imem < M; imem++) { + delete[] s[imem]; + delete[] y[imem]; + } + delete[] s; + delete[] y; -L_BFGS::~L_BFGS() -{ - /* Deallocate memory */ - delete [] rho; - for (int imem = 0; imem < M; imem++) - { - delete [] s[imem]; - delete [] y[imem]; - } - delete [] s; - delete [] y; - - delete [] design_old; - delete [] gradient_old; + delete[] design_old; + delete[] gradient_old; } +void L_BFGS::computeAscentDir(int iter, MyReal *gradient, MyReal *ascentdir) { + int imemory; + MyReal beta; + MyReal *alpha = new MyReal[M]; + int imax, imin; + /* Initialize the ascentdir with steepest descent */ + for (int idir = 0; idir < dimN; idir++) { + ascentdir[idir] = gradient[idir]; + } + /* Set range of the two-loop recursion */ + imax = iter - 1; + if (iter < M) { + imin = 0; + } else { + imin = iter - M; + } -void L_BFGS::computeAscentDir(int iter, - MyReal* gradient, - MyReal* ascentdir) -{ - int imemory; - MyReal beta; - MyReal* alpha = new MyReal[M]; - int imax, imin; - - - /* Initialize the ascentdir with steepest descent */ - for (int idir = 0; idir < dimN; idir++) - { - ascentdir[idir] = gradient[idir]; - } - - - /* Set range of the two-loop recursion */ - imax = iter-1; - if (iter < M) - { - imin = 0; - } - else - { - imin = iter - M; - } - - /* Loop backwards through lbfgs memory */ - for (int i = imax; i >= imin; i--) - { - imemory = i % M; - /* Compute alpha */ - alpha[imemory] = rho[imemory] * vecdot_par(dimN, s[imemory], ascentdir, MPIcomm); - /* Update the ascentdir */ - for (int idir = 0; idir < dimN; idir++) - { - ascentdir[idir] -= alpha[imemory] * y[imemory][idir]; - } - } + /* Loop backwards through lbfgs memory */ + for (int i = imax; i >= imin; i--) { + imemory = i % M; + /* Compute alpha */ + alpha[imemory] = + rho[imemory] * vecdot_par(dimN, s[imemory], ascentdir, MPIcomm); + /* Update the ascentdir */ + for (int idir = 0; idir < dimN; idir++) { + ascentdir[idir] -= alpha[imemory] * y[imemory][idir]; + } + } - /* scale the ascentdir by H0 */ - for (int idir = 0; idir < dimN; idir++) - { - ascentdir[idir] *= H0; - } + /* scale the ascentdir by H0 */ + for (int idir = 0; idir < dimN; idir++) { + ascentdir[idir] *= H0; + } /* loop forwards through the l-bfgs memory */ - for (int i = imin; i <= imax; i++) - { + for (int i = imin; i <= imax; i++) { imemory = i % M; /* Compute beta */ beta = rho[imemory] * vecdot_par(dimN, y[imemory], ascentdir, MPIcomm); /* Update the ascentdir */ - for (int idir = 0; idir < dimN; idir++) - { + for (int idir = 0; idir < dimN; idir++) { ascentdir[idir] += s[imemory][idir] * (alpha[imemory] - beta); } } - delete [] alpha; - + delete[] alpha; } +void L_BFGS::updateMemory(int iter, MyReal *design, MyReal *gradient) { + /* Update lbfgs memory only if iter > 0 */ + if (iter > 0) { + MyReal yTy, yTs; -void L_BFGS::updateMemory(int iter, - MyReal* design, - MyReal* gradient) -{ + /* Get storing state */ + int imemory = (iter - 1) % M; - /* Update lbfgs memory only if iter > 0 */ - if (iter > 0) - { - MyReal yTy, yTs; - - /* Get storing state */ - int imemory = (iter-1) % M ; - - /* Update BFGS memory for s, y */ - for (int idir = 0; idir < dimN; idir++) - { - y[imemory][idir] = gradient[idir] - gradient_old[idir]; - s[imemory][idir] = design[idir] - design_old[idir]; - } - - /* Update rho and H0 */ - yTs = vecdot_par(dimN, y[imemory], s[imemory], MPIcomm); - yTy = vecdot_par(dimN, y[imemory], y[imemory], MPIcomm); - if (yTs == 0.0) - { - printf(" Warning: resetting yTs to 1.\n"); - yTs = 1.0; - } - if (yTy == 0.0) - { - printf(" Warning: resetting yTy to 1.\n"); - yTy = 1.; - } - rho[imemory] = 1. / yTs; - H0 = yTs / yTy; + /* Update BFGS memory for s, y */ + for (int idir = 0; idir < dimN; idir++) { + y[imemory][idir] = gradient[idir] - gradient_old[idir]; + s[imemory][idir] = design[idir] - design_old[idir]; + } + /* Update rho and H0 */ + yTs = vecdot_par(dimN, y[imemory], s[imemory], MPIcomm); + yTy = vecdot_par(dimN, y[imemory], y[imemory], MPIcomm); + if (yTs == 0.0) { + printf(" Warning: resetting yTs to 1.\n"); + yTs = 1.0; + } + if (yTy == 0.0) { + printf(" Warning: resetting yTy to 1.\n"); + yTy = 1.; + } + rho[imemory] = 1. / yTs; + H0 = yTs / yTy; } - /* Update old design and gradient */ - vec_copy(dimN, design, design_old); - vec_copy(dimN, gradient, gradient_old); + /* Update old design and gradient */ + vec_copy(dimN, design, design_old); + vec_copy(dimN, gradient, gradient_old); } +BFGS::BFGS(MPI_Comm comm, int N) : HessianApprox(comm) { + dimN = N; + Hessian = new MyReal[N * N]; + setIdentity(); -BFGS::BFGS(MPI_Comm comm, int N) : HessianApprox(comm) -{ - dimN = N; - - Hessian = new MyReal[N*N]; - setIdentity(); + y = new MyReal[N]; + s = new MyReal[N]; - y = new MyReal[N]; - s = new MyReal[N]; + Hy = new MyReal[N]; + A = new MyReal[N * N]; + B = new MyReal[N * N]; - Hy = new MyReal[N]; - A = new MyReal[N*N]; - B = new MyReal[N*N]; + /* Allocate memory for storing design at previous iteration */ + design_old = new MyReal[dimN]; + gradient_old = new MyReal[dimN]; - /* Allocate memory for storing design at previous iteration */ - design_old = new MyReal[dimN]; - gradient_old = new MyReal[dimN]; - - /* Sanity check */ - int size; - MPI_Comm_size(MPIcomm, &size); - if (size > 1) printf("\n\n WARNING: Parallel BFGS not implemented.\n BFGS updates will be LOCAL to each processor -> block-BFGS. \n\n"); + /* Sanity check */ + int size; + MPI_Comm_size(MPIcomm, &size); + if (size > 1) + printf("\n\n WARNING: Parallel BFGS not implemented.\n BFGS updates will " + "be LOCAL to each processor -> block-BFGS. \n\n"); } -void BFGS::setIdentity() -{ - for (int i = 0; i -#include #include "layer.hpp" +#include +#include #include -Layer::Layer() -{ - dim_In = 0; - dim_Out = 0; - dim_Bias = 0; - ndesign = 0; - nweights = 0; - nconv = 0; - csize = 0; - - index = 0; - dt = 0.0; - activ = -1; - weights = NULL; - weights_bar = NULL; - bias = NULL; - bias_bar = NULL; - gamma_tik = 0.0; - gamma_ddt = 0.0; - update = NULL; - update_bar = NULL; +Layer::Layer() { + dim_In = 0; + dim_Out = 0; + dim_Bias = 0; + ndesign = 0; + nweights = 0; + nconv = 0; + csize = 0; + + index = 0; + dt = 0.0; + activ = -1; + weights = NULL; + weights_bar = NULL; + bias = NULL; + bias_bar = NULL; + gamma_tik = 0.0; + gamma_ddt = 0.0; + update = NULL; + update_bar = NULL; } -Layer::Layer(int idx, - int Type, - int dimI, - int dimO, - int dimB, - int dimW, - MyReal deltaT, - int Activ, - MyReal gammatik, - MyReal gammaddt) : Layer() -{ - index = idx; - type = Type; - dim_In = dimI; - dim_Out = dimO; - dim_Bias = dimB; - ndesign = dimW + dimB; - nweights = dimW; - dt = deltaT; - activ = Activ; - gamma_tik = gammatik; - gamma_ddt = gammaddt; - - update = new MyReal[dimO]; - update_bar = new MyReal[dimO]; -} - -Layer::~Layer() -{ - delete [] update; - delete [] update_bar; +Layer::Layer(int idx, int Type, int dimI, int dimO, int dimB, int dimW, + MyReal deltaT, int Activ, MyReal gammatik, MyReal gammaddt) + : Layer() { + index = idx; + type = Type; + dim_In = dimI; + dim_Out = dimO; + dim_Bias = dimB; + ndesign = dimW + dimB; + nweights = dimW; + dt = deltaT; + activ = Activ; + gamma_tik = gammatik; + gamma_ddt = gammaddt; + + update = new MyReal[dimO]; + update_bar = new MyReal[dimO]; } +Layer::~Layer() { + delete[] update; + delete[] update_bar; +} void Layer::setDt(MyReal DT) { dt = DT; } MyReal Layer::getDt() { return dt; } -void Layer::setMemory(MyReal* design_memloc, - MyReal* gradient_memloc) -{ - /* Set design and gradient memory locations */ - weights = design_memloc; - weights_bar = gradient_memloc; - - /* Bias memory locations is a shift by number of weights */ - bias = design_memloc + nweights; - bias_bar = gradient_memloc + nweights; -} +void Layer::setMemory(MyReal *design_memloc, MyReal *gradient_memloc) { + /* Set design and gradient memory locations */ + weights = design_memloc; + weights_bar = gradient_memloc; + /* Bias memory locations is a shift by number of weights */ + bias = design_memloc + nweights; + bias_bar = gradient_memloc + nweights; +} MyReal Layer::getGammaTik() { return gamma_tik; } @@ -86,14 +72,14 @@ int Layer::getActivation() { return activ; } int Layer::getType() { return type; } -MyReal* Layer::getWeights() { return weights; } -MyReal* Layer::getBias() { return bias; } +MyReal *Layer::getWeights() { return weights; } +MyReal *Layer::getBias() { return bias; } -MyReal* Layer::getWeightsBar() { return weights_bar; } -MyReal* Layer::getBiasBar() { return bias_bar; } +MyReal *Layer::getWeightsBar() { return weights_bar; } +MyReal *Layer::getBiasBar() { return bias_bar; } -int Layer::getDimIn() { return dim_In; } -int Layer::getDimOut() { return dim_Out; } +int Layer::getDimIn() { return dim_In; } +int Layer::getDimOut() { return dim_Out; } int Layer::getDimBias() { return dim_Bias; } int Layer::getnWeights() { return nweights; } int Layer::getnDesign() { return ndesign; } @@ -103,839 +89,666 @@ int Layer::getCSize() { return csize; } int Layer::getIndex() { return index; } -void Layer::print_data(MyReal* data) -{ - printf("DATA: "); - for (int io = 0; io < dim_Out; io++) - { - printf("%1.14e ", data[io]); - } - printf("\n"); +void Layer::print_data(MyReal *data) { + printf("DATA: "); + for (int io = 0; io < dim_Out; io++) { + printf("%1.14e ", data[io]); + } + printf("\n"); } - -MyReal Layer::activation(MyReal x) -{ - MyReal y; - switch ( activ ) - { - case TANH: - y = Layer::tanh_act(x); - break; - case RELU: - y = Layer::ReLu_act(x); - break; - case SMRELU: - y = Layer::SmoothReLu_act(x); - break; - default: - y = -1000000.0; - printf("ERROR: You should specify an activation function!\n"); - printf("GO HOME AND GET SOME SLEEP!"); - break; - } - return y; +MyReal Layer::activation(MyReal x) { + MyReal y; + switch (activ) { + case TANH: + y = Layer::tanh_act(x); + break; + case RELU: + y = Layer::ReLu_act(x); + break; + case SMRELU: + y = Layer::SmoothReLu_act(x); + break; + default: + y = -1000000.0; + printf("ERROR: You should specify an activation function!\n"); + printf("GO HOME AND GET SOME SLEEP!"); + break; + } + return y; } -MyReal Layer::dactivation(MyReal x) -{ - MyReal y; - switch ( activ) - { - case TANH: - y = Layer::dtanh_act(x); - break; - case RELU: - y = Layer::dReLu_act(x); - break; - case SMRELU: - y = Layer::dSmoothReLu_act(x); - break; - default: - y = -1000000.0; - printf("ERROR: You should specify an activation function!\n"); - printf("GO HOME AND GET SOME SLEEP!"); - break; - } - return y; +MyReal Layer::dactivation(MyReal x) { + MyReal y; + switch (activ) { + case TANH: + y = Layer::dtanh_act(x); + break; + case RELU: + y = Layer::dReLu_act(x); + break; + case SMRELU: + y = Layer::dSmoothReLu_act(x); + break; + default: + y = -1000000.0; + printf("ERROR: You should specify an activation function!\n"); + printf("GO HOME AND GET SOME SLEEP!"); + break; + } + return y; +} +void Layer::packDesign(MyReal *buffer, int size) { + int nweights = getnWeights(); + int nbias = getDimBias(); + int idx = 0; + for (int i = 0; i < nweights; i++) { + buffer[idx] = getWeights()[i]; + idx++; + } + for (int i = 0; i < nbias; i++) { + buffer[idx] = getBias()[i]; + idx++; + } + /* Set the rest to zero */ + for (int i = idx; i < size; i++) { + buffer[idx] = 0.0; + idx++; + } } +void Layer::unpackDesign(MyReal *buffer) { + int nweights = getnWeights(); + int nbias = getDimBias(); -void Layer::packDesign(MyReal* buffer, - int size) -{ - int nweights = getnWeights(); - int nbias = getDimBias(); - int idx = 0; - for (int i = 0; i < nweights; i++) - { - buffer[idx] = getWeights()[i]; idx++; - } - for (int i = 0; i < nbias; i++) - { - buffer[idx] = getBias()[i]; idx++; - } - /* Set the rest to zero */ - for (int i = idx; i < size; i++) - { - buffer[idx] = 0.0; idx++; - } + int idx = 0; + for (int i = 0; i < nweights; i++) { + getWeights()[i] = buffer[idx]; + idx++; + } + for (int i = 0; i < nbias; i++) { + getBias()[i] = buffer[idx]; + idx++; + } } -void Layer::unpackDesign(MyReal* buffer) -{ - int nweights = getnWeights(); - int nbias = getDimBias(); +void Layer::scaleDesign(MyReal factor) { + /* Scale design by a factor */ + for (int i = 0; i < nweights; i++) { + weights[i] = factor * weights[i]; + } + for (int i = 0; i < dim_Bias; i++) { + bias[i] = factor * bias[i]; + } - int idx = 0; - for (int i = 0; i < nweights; i++) - { - getWeights()[i] = buffer[idx]; idx++; - } - for (int i = 0; i < nbias; i++) - { - getBias()[i] = buffer[idx]; idx++; - } + /* Reset the gradient */ + resetBar(); } -void Layer::scaleDesign(MyReal factor) -{ - /* Scale design by a factor */ - for (int i = 0; i < nweights; i++) - { - weights[i] = factor * weights[i]; - } - for (int i = 0; i < dim_Bias; i++) - { - bias[i] = factor * bias[i]; - } +void Layer::resetBar() { + for (int i = 0; i < nweights; i++) { + weights_bar[i] = 0.0; + } + for (int i = 0; i < dim_Bias; i++) { + bias_bar[i] = 0.0; + } +} - /* Reset the gradient */ - resetBar(); -} +MyReal Layer::evalTikh() { + MyReal tik = 0.0; + for (int i = 0; i < nweights; i++) { + tik += pow(weights[i], 2); + } + for (int i = 0; i < dim_Bias; i++) { + tik += pow(bias[i], 2); + } -void Layer::resetBar() -{ - for (int i = 0; i < nweights; i++) - { - weights_bar[i] = 0.0; - } - for (int i = 0; i < dim_Bias; i++) - { - bias_bar[i] = 0.0; - } + return gamma_tik / 2.0 * tik; } +void Layer::evalTikh_diff(MyReal regul_bar) { + regul_bar = gamma_tik * regul_bar; -MyReal Layer::evalTikh() -{ - MyReal tik = 0.0; - for (int i = 0; i < nweights; i++) - { - tik += pow(weights[i],2); + /* Derivative bias term */ + for (int i = 0; i < dim_Bias; i++) { + bias_bar[i] += bias[i] * regul_bar; + } + for (int i = 0; i < nweights; i++) { + weights_bar[i] += weights[i] * regul_bar; + } +} + +MyReal Layer::evalRegulDDT(Layer *layer_prev, MyReal deltat) { + if (layer_prev == NULL) + return 0.0; // this holds for opening layer + + MyReal diff; + MyReal regul_ddt = 0.0; + + /* Compute ddt-regularization only if dimensions match */ + /* this excludes first intermediate layer and classification layer. */ + if (layer_prev->getnDesign() == ndesign && layer_prev->getDimIn() == dim_In && + layer_prev->getDimOut() == dim_Out && + layer_prev->getDimBias() == dim_Bias && + layer_prev->getnWeights() == nweights) { + for (int iw = 0; iw < nweights; iw++) { + diff = (getWeights()[iw] - layer_prev->getWeights()[iw]) / deltat; + regul_ddt += pow(diff, 2); } - for (int i = 0; i < dim_Bias; i++) - { - tik += pow(bias[i],2); + for (int ib = 0; ib < dim_Bias; ib++) { + diff = (getBias()[ib] - layer_prev->getBias()[ib]) / deltat; + regul_ddt += pow(diff, 2); } + regul_ddt = gamma_ddt / 2.0 * regul_ddt; + } - return gamma_tik / 2.0 * tik; + return regul_ddt; } -void Layer::evalTikh_diff(MyReal regul_bar) -{ - regul_bar = gamma_tik * regul_bar; +void Layer::evalRegulDDT_diff(Layer *layer_prev, Layer *layer_next, + MyReal deltat) { + + if (layer_prev == NULL) + return; + if (layer_next == NULL) + return; + + MyReal diff; + int regul_bar = gamma_ddt / (deltat * deltat); + + /* Left sided derivative term */ + if (layer_prev->getnDesign() == ndesign && layer_prev->getDimIn() == dim_In && + layer_prev->getDimOut() == dim_Out && + layer_prev->getDimBias() == dim_Bias && + layer_prev->getnWeights() == nweights) { + for (int ib = 0; ib < dim_Bias; ib++) { + diff = getBias()[ib] - layer_prev->getBias()[ib]; + getBiasBar()[ib] += diff * regul_bar; + } - /* Derivative bias term */ - for (int i = 0; i < dim_Bias; i++) - { - bias_bar[i] += bias[i] * regul_bar; + for (int iw = 0; iw < nweights; iw++) { + diff = getWeights()[iw] - layer_prev->getWeights()[iw]; + getWeightsBar()[iw] += diff * regul_bar; } - for (int i = 0; i < nweights; i++) - { - weights_bar[i] += weights[i] * regul_bar; + } + + /* Right sided derivative term */ + if (layer_next->getnDesign() == ndesign && layer_next->getDimIn() == dim_In && + layer_next->getDimOut() == dim_Out && + layer_next->getDimBias() == dim_Bias && + layer_next->getnWeights() == nweights) { + for (int ib = 0; ib < dim_Bias; ib++) { + diff = getBias()[ib] - layer_next->getBias()[ib]; + getBiasBar()[ib] += diff * regul_bar; } + + for (int iw = 0; iw < nweights; iw++) { + diff = getWeights()[iw] - layer_next->getWeights()[iw]; + getWeightsBar()[iw] += diff * regul_bar; + } + } } +void Layer::setExample(MyReal *example_ptr) {} -MyReal Layer::evalRegulDDT(Layer* layer_prev, - MyReal deltat) -{ - if (layer_prev == NULL) return 0.0; // this holds for opening layer - - MyReal diff; - MyReal regul_ddt = 0.0; - - /* Compute ddt-regularization only if dimensions match */ - /* this excludes first intermediate layer and classification layer. */ - if (layer_prev->getnDesign() == ndesign && - layer_prev->getDimIn() == dim_In && - layer_prev->getDimOut() == dim_Out && - layer_prev->getDimBias() == dim_Bias && - layer_prev->getnWeights() == nweights ) - { - for (int iw = 0; iw < nweights; iw++) - { - diff = (getWeights()[iw] - layer_prev->getWeights()[iw]) / deltat; - regul_ddt += pow(diff,2); - } - for (int ib = 0; ib < dim_Bias; ib++) - { - diff = (getBias()[ib] - layer_prev->getBias()[ib]) / deltat; - regul_ddt += pow(diff,2); - } - regul_ddt = gamma_ddt / 2.0 * regul_ddt; - } +void Layer::setLabel(MyReal *example_ptr) {} - return regul_ddt; -} +DenseLayer::DenseLayer(int idx, int dimI, int dimO, MyReal deltaT, int Activ, + MyReal gammatik, MyReal gammaddt) + : Layer(idx, DENSE, dimI, dimO, 1, dimI * dimO, deltaT, Activ, gammatik, + gammaddt) {} -void Layer::evalRegulDDT_diff(Layer* layer_prev, - Layer* layer_next, - MyReal deltat) -{ +DenseLayer::~DenseLayer() {} - if (layer_prev == NULL) return; - if (layer_next == NULL) return; - - MyReal diff; - int regul_bar = gamma_ddt / (deltat*deltat); - - /* Left sided derivative term */ - if (layer_prev->getnDesign() == ndesign && - layer_prev->getDimIn() == dim_In && - layer_prev->getDimOut() == dim_Out && - layer_prev->getDimBias() == dim_Bias && - layer_prev->getnWeights() == nweights ) - { - for (int ib = 0; ib < dim_Bias ; ib++) - { - diff = getBias()[ib] - layer_prev->getBias()[ib]; - getBiasBar()[ib] += diff * regul_bar; - } +void DenseLayer::applyFWD(MyReal *state) { + /* Affine transformation */ + for (int io = 0; io < dim_Out; io++) { + /* Apply weights */ + update[io] = vecdot(dim_In, &(weights[io * dim_In]), state); - for (int iw = 0; iw < nweights; iw++) - { - diff = getWeights()[iw] - layer_prev->getWeights()[iw]; - getWeightsBar()[iw] += diff * regul_bar; - } - } + /* Add bias */ + update[io] += bias[0]; + } - /* Right sided derivative term */ - if (layer_next->getnDesign() == ndesign && - layer_next->getDimIn() == dim_In && - layer_next->getDimOut() == dim_Out && - layer_next->getDimBias() == dim_Bias && - layer_next->getnWeights() == nweights ) - { - for (int ib = 0; ib < dim_Bias; ib++) - { - diff = getBias()[ib] - layer_next->getBias()[ib]; - getBiasBar()[ib] += diff * regul_bar; - } + /* Apply step */ + for (int io = 0; io < dim_Out; io++) { + state[io] = state[io] + dt * activation(update[io]); + } +} - for (int iw = 0; iw < nweights; iw++) - { - diff = getWeights()[iw] - layer_next->getWeights()[iw]; - getWeightsBar()[iw] += diff * regul_bar; - } - } -} +void DenseLayer::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + /* state_bar is the adjoint of the state variable, it contains the + old time adjoint informationk, and is modified on the way out to + contain the update. */ + /* Derivative of the step */ + for (int io = 0; io < dim_Out; io++) { + /* Recompute affine transformation */ + update[io] = vecdot(dim_In, &(weights[io * dim_In]), state); + update[io] += bias[0]; + /* Derivative: This is the update from old time */ + update_bar[io] = dt * dactivation(update[io]) * state_bar[io]; + } -void Layer::setExample(MyReal* example_ptr) {} + /* Derivative of linear transformation */ + for (int io = 0; io < dim_Out; io++) { + /* Derivative of bias addition */ + if (compute_gradient) + bias_bar[0] += update_bar[io]; + + /* Derivative of weight application */ + for (int ii = 0; ii < dim_In; ii++) { + if (compute_gradient) + weights_bar[io * dim_In + ii] += state[ii] * update_bar[io]; + state_bar[ii] += weights[io * dim_In + ii] * update_bar[io]; + } + } +} -void Layer::setLabel(MyReal* example_ptr) {} +OpenDenseLayer::OpenDenseLayer(int dimI, int dimO, int Activ, MyReal gammatik) + : DenseLayer(-1, dimI, dimO, 1.0, Activ, gammatik, 0.0) { + type = OPENDENSE; + example = NULL; +} +OpenDenseLayer::~OpenDenseLayer() {} -DenseLayer::DenseLayer(int idx, - int dimI, - int dimO, - MyReal deltaT, - int Activ, - MyReal gammatik, - MyReal gammaddt) : Layer(idx, DENSE, dimI, dimO, 1, dimI*dimO, deltaT, Activ, gammatik, gammaddt) -{} - -DenseLayer::~DenseLayer() {} +void OpenDenseLayer::setExample(MyReal *example_ptr) { example = example_ptr; } +void OpenDenseLayer::applyFWD(MyReal *state) { + /* affine transformation */ + for (int io = 0; io < dim_Out; io++) { + /* Apply weights */ + update[io] = vecdot(dim_In, &(weights[io * dim_In]), example); -void DenseLayer::applyFWD(MyReal* state) -{ - /* Affine transformation */ - for (int io = 0; io < dim_Out; io++) - { - /* Apply weights */ - update[io] = vecdot(dim_In, &(weights[io*dim_In]), state); - - /* Add bias */ - update[io] += bias[0]; - } - - /* Apply step */ - for (int io = 0; io < dim_Out; io++) - { - state[io] = state[io] + dt * activation(update[io]); - } + /* Add bias */ + update[io] += bias[0]; + } + + /* Step */ + for (int io = 0; io < dim_Out; io++) { + state[io] = activation(update[io]); + } } +void OpenDenseLayer::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + /* Derivative of step */ + for (int io = 0; io < dim_Out; io++) { + /* Recompute affine transformation */ + update[io] = vecdot(dim_In, &(weights[io * dim_In]), example); + update[io] += bias[0]; -void DenseLayer::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ + /* Derivative */ + update_bar[io] = dactivation(update[io]) * state_bar[io]; + state_bar[io] = 0.0; + } - /* state_bar is the adjoint of the state variable, it contains the - old time adjoint informationk, and is modified on the way out to - contain the update. */ - - /* Derivative of the step */ - for (int io = 0; io < dim_Out; io++) - { - /* Recompute affine transformation */ - update[io] = vecdot(dim_In, &(weights[io*dim_In]), state); - update[io] += bias[0]; - - /* Derivative: This is the update from old time */ - update_bar[io] = dt * dactivation(update[io]) * state_bar[io]; - } - - /* Derivative of linear transformation */ - for (int io = 0; io < dim_Out; io++) - { + /* Derivative of affine transformation */ + if (compute_gradient) { + for (int io = 0; io < dim_Out; io++) { /* Derivative of bias addition */ - if (compute_gradient) bias_bar[0] += update_bar[io]; + bias_bar[0] += update_bar[io]; /* Derivative of weight application */ - for (int ii = 0; ii < dim_In; ii++) - { - if (compute_gradient) weights_bar[io*dim_In + ii] += state[ii] * update_bar[io]; - state_bar[ii] += weights[io*dim_In + ii] * update_bar[io]; + for (int ii = 0; ii < dim_In; ii++) { + weights_bar[io * dim_In + ii] += example[ii] * update_bar[io]; } - } + } + } } - -OpenDenseLayer::OpenDenseLayer(int dimI, - int dimO, - int Activ, - MyReal gammatik) : DenseLayer(-1, dimI, dimO, 1.0, Activ, gammatik, 0.0) -{ - type = OPENDENSE; - example = NULL; +OpenExpandZero::OpenExpandZero(int dimI, int dimO) + : Layer(-1, OPENZERO, dimI, dimO, 0, 0, 1.0, -1, 0.0, 0.0) { + /* this layer doesn't have any design variables. */ + ndesign = 0; + nweights = 0; } -OpenDenseLayer::~OpenDenseLayer(){} +OpenExpandZero::~OpenExpandZero() {} -void OpenDenseLayer::setExample(MyReal* example_ptr) -{ - example = example_ptr; -} +void OpenExpandZero::setExample(MyReal *example_ptr) { example = example_ptr; } -void OpenDenseLayer::applyFWD(MyReal* state) -{ - /* affine transformation */ - for (int io = 0; io < dim_Out; io++) - { - /* Apply weights */ - update[io] = vecdot(dim_In, &(weights[io*dim_In]), example); - - /* Add bias */ - update[io] += bias[0]; - } - - /* Step */ - for (int io = 0; io < dim_Out; io++) - { - state[io] = activation(update[io]); - } +void OpenExpandZero::applyFWD(MyReal *state) { + for (int ii = 0; ii < dim_In; ii++) { + state[ii] = example[ii]; + } + for (int io = dim_In; io < dim_Out; io++) { + state[io] = 0.0; + } } -void OpenDenseLayer::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ - /* Derivative of step */ - for (int io = 0; io < dim_Out; io++) - { - /* Recompute affine transformation */ - update[io] = vecdot(dim_In, &(weights[io*dim_In]), example); - update[io] += bias[0]; - - /* Derivative */ - update_bar[io] = dactivation(update[io]) * state_bar[io]; - state_bar[io] = 0.0; - } - - /* Derivative of affine transformation */ - if (compute_gradient) - { - for (int io = 0; io < dim_Out; io++) - { - /* Derivative of bias addition */ - bias_bar[0] += update_bar[io]; - - /* Derivative of weight application */ - for (int ii = 0; ii < dim_In; ii++) - { - weights_bar[io*dim_In + ii] += example[ii] * update_bar[io]; - } - } - } -} - - -OpenExpandZero::OpenExpandZero(int dimI, - int dimO) : Layer(-1, OPENZERO, dimI, dimO, 0, 0, 1.0, -1, 0.0, 0.0) -{ - /* this layer doesn't have any design variables. */ - ndesign = 0; - nweights = 0; +void OpenExpandZero::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + for (int ii = 0; ii < dim_Out; ii++) { + state_bar[ii] = 0.0; + } } +OpenConvLayer::OpenConvLayer(int dimI, int dimO) + : Layer(-1, OPENCONV, dimI, dimO, 0, 0, 1.0, -1, 0.0, 0.0) { + /* this layer doesn't have any design variables. */ + ndesign = 0; + nweights = 0; + dim_Bias = 0; -OpenExpandZero::~OpenExpandZero(){} + nconv = dim_Out / dim_In; - -void OpenExpandZero::setExample(MyReal* example_ptr) -{ - example = example_ptr; + assert(nconv * dim_In == dim_Out); } +OpenConvLayer::~OpenConvLayer() {} +void OpenConvLayer::setExample(MyReal *example_ptr) { example = example_ptr; } -void OpenExpandZero::applyFWD(MyReal* state) -{ - for (int ii = 0; ii < dim_In; ii++) - { - state[ii] = example[ii]; - } - for (int io = dim_In; io < dim_Out; io++) - { - state[io] = 0.0; - } -} - -void OpenExpandZero::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ - for (int ii = 0; ii < dim_Out; ii++) - { - state_bar[ii] = 0.0; - } -} - - -OpenConvLayer::OpenConvLayer(int dimI, - int dimO) : Layer(-1, OPENCONV, dimI, dimO, 0, 0, 1.0, -1, 0.0, 0.0) -{ - /* this layer doesn't have any design variables. */ - ndesign = 0; - nweights = 0; - dim_Bias = 0; - - nconv = dim_Out/dim_In; - - assert(nconv*dim_In == dim_Out); +void OpenConvLayer::applyFWD(MyReal *state) { + // replicate the image data + for (int img = 0; img < nconv; img++) { + for (int ii = 0; ii < dim_In; ii++) { + state[ii + dim_In * img] = example[ii]; + } + } } - -OpenConvLayer::~OpenConvLayer(){} - - -void OpenConvLayer::setExample(MyReal* example_ptr) -{ - example = example_ptr; +void OpenConvLayer::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + for (int ii = 0; ii < dim_Out; ii++) { + state_bar[ii] = 0.0; + } } - -void OpenConvLayer::applyFWD(MyReal* state) -{ - // replicate the image data - for(int img = 0; img < nconv; img++) - { - for (int ii = 0; ii < dim_In; ii++) - { - state[ii+dim_In*img] = example[ii]; - } - } -} - -void OpenConvLayer::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ - for (int ii = 0; ii < dim_Out; ii++) - { - state_bar[ii] = 0.0; - } -} - - -OpenConvLayerMNIST::OpenConvLayerMNIST(int dimI, int dimO) : OpenConvLayer(dimI, dimO) -{ - type = OPENCONVMNIST; +OpenConvLayerMNIST::OpenConvLayerMNIST(int dimI, int dimO) + : OpenConvLayer(dimI, dimO) { + type = OPENCONVMNIST; } +OpenConvLayerMNIST::~OpenConvLayerMNIST() {} + +void OpenConvLayerMNIST::applyFWD(MyReal *state) { + // replicate the image data + for (int img = 0; img < nconv; img++) { + for (int ii = 0; ii < dim_In; ii++) { + // The MNIST data is integer from [0, 255], so we rescale it to floats + // over the range[0,6] + // + // Also, rescale tanh so that it appropriately activates over the x-range + // of [0,6] + state[ii + dim_In * img] = tanh((6.0 * example[ii] / 255.0) - 3.0) + 1; + } + } +} -OpenConvLayerMNIST::~OpenConvLayerMNIST(){} - +void OpenConvLayerMNIST::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + // Derivative of step + for (int img = 0; img < nconv; img++) { + for (int ii = 0; ii < dim_In; ii++) { + state_bar[ii + dim_In * img] = + (1.0 - pow(tanh(example[ii]), 2)) * state_bar[ii + dim_In * img]; + // state_bar[ii + dim_In*img] = 0.0; + } + } -void OpenConvLayerMNIST::applyFWD(MyReal* state) -{ - // replicate the image data - for(int img = 0; img < nconv; img++) - { - for (int ii = 0; ii < dim_In; ii++) - { - // The MNIST data is integer from [0, 255], so we rescale it to floats - // over the range[0,6] - // - // Also, rescale tanh so that it appropriately activates over the x-range of [0,6] - state[ii+dim_In*img] = tanh( (6.0*example[ii]/255.0) - 3.0) + 1; - } - } + // Derivative of affine transformation + // This is "0" because we have no bias or weights } -void OpenConvLayerMNIST::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ - // Derivative of step - for(int img = 0; img < nconv; img++) - { - for (int ii = 0; ii < dim_In; ii++) - { - state_bar[ii + dim_In*img] = (1.0 - pow(tanh(example[ii]),2))*state_bar[ii + dim_In*img]; - // state_bar[ii + dim_In*img] = 0.0; - } - } - - // Derivative of affine transformation - // This is "0" because we have no bias or weights +ClassificationLayer::ClassificationLayer(int idx, int dimI, int dimO, + MyReal gammatik) + : Layer(idx, CLASSIFICATION, dimI, dimO, dimO, dimI * dimO, 1.0, -1, 0.0, + 0.0) { + gamma_tik = gammatik; + /* Allocate the probability vector */ + probability = new MyReal[dimO]; } +ClassificationLayer::~ClassificationLayer() { delete[] probability; } +void ClassificationLayer::setLabel(MyReal *label_ptr) { label = label_ptr; } -ClassificationLayer::ClassificationLayer(int idx, - int dimI, - int dimO, - MyReal gammatik) : Layer(idx, CLASSIFICATION, dimI, dimO, dimO, dimI*dimO, 1.0, -1, 0.0, 0.0) -{ - gamma_tik = gammatik; - /* Allocate the probability vector */ - probability = new MyReal[dimO]; -} +void ClassificationLayer::applyFWD(MyReal *state) { + /* Compute affine transformation */ + for (int io = 0; io < dim_Out; io++) { + /* Apply weights */ + update[io] = vecdot(dim_In, &(weights[io * dim_In]), state); + /* Add bias */ + update[io] += bias[io]; + } -ClassificationLayer::~ClassificationLayer() -{ - delete [] probability; -} + /* Data normalization y - max(y) (needed for stable softmax evaluation */ + normalize(update); + if (dim_In < dim_Out) { + printf("Error: nchannels < nclasses. Implementation of classification " + "layer doesn't support this setting. Change! \n"); + exit(1); + } -void ClassificationLayer::setLabel(MyReal* label_ptr) -{ - label = label_ptr; + /* Apply step */ + for (int io = 0; io < dim_Out; io++) { + state[io] = update[io]; + } + /* Set remaining to zero */ + for (int ii = dim_Out; ii < dim_In; ii++) { + state[ii] = 0.0; + } } +void ClassificationLayer::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + /* Recompute affine transformation */ + for (int io = 0; io < dim_Out; io++) { + update[io] = vecdot(dim_In, &(weights[io * dim_In]), state); + update[io] += bias[io]; + } -void ClassificationLayer::applyFWD(MyReal* state) -{ - /* Compute affine transformation */ - for (int io = 0; io < dim_Out; io++) - { - /* Apply weights */ - update[io] = vecdot(dim_In, &(weights[io*dim_In]), state); - /* Add bias */ - update[io] += bias[io]; - } - - /* Data normalization y - max(y) (needed for stable softmax evaluation */ - normalize(update); - - if (dim_In < dim_Out) - { - printf("Error: nchannels < nclasses. Implementation of classification layer doesn't support this setting. Change! \n"); - exit(1); - } + /* Derivative of step */ + for (int ii = dim_Out; ii < dim_In; ii++) { + state_bar[ii] = 0.0; + } + for (int io = 0; io < dim_Out; io++) { + update_bar[io] = state_bar[io]; + state_bar[io] = 0.0; + } - /* Apply step */ - for (int io = 0; io < dim_Out; io++) - { - state[io] = update[io]; - } - /* Set remaining to zero */ - for (int ii = dim_Out; ii < dim_In; ii++) - { - state[ii] = 0.0; - } -} - -void ClassificationLayer::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ - /* Recompute affine transformation */ - for (int io = 0; io < dim_Out; io++) - { - update[io] = vecdot(dim_In, &(weights[io*dim_In]), state); - update[io] += bias[io]; - } + /* Derivative of the normalization */ + normalize_diff(update, update_bar); + /* Derivatie of affine transformation */ + for (int io = 0; io < dim_Out; io++) { + /* Derivative of bias addition */ + if (compute_gradient) + bias_bar[io] += update_bar[io]; - /* Derivative of step */ - for (int ii = dim_Out; ii < dim_In; ii++) - { - state_bar[ii] = 0.0; + /* Derivative of weight application */ + for (int ii = 0; ii < dim_In; ii++) { + if (compute_gradient) + weights_bar[io * dim_In + ii] += state[ii] * update_bar[io]; + state_bar[ii] += weights[io * dim_In + ii] * update_bar[io]; } - for (int io = 0; io < dim_Out; io++) - { - update_bar[io] = state_bar[io]; - state_bar[io] = 0.0; - } - - /* Derivative of the normalization */ - normalize_diff(update, update_bar); - - /* Derivatie of affine transformation */ - for (int io = 0; io < dim_Out; io++) - { - /* Derivative of bias addition */ - if (compute_gradient) bias_bar[io] += update_bar[io]; - - /* Derivative of weight application */ - for (int ii = 0; ii < dim_In; ii++) - { - if (compute_gradient) weights_bar[io*dim_In + ii] += state[ii] * update_bar[io]; - state_bar[ii] += weights[io*dim_In + ii] * update_bar[io]; - } - } + } } +void ClassificationLayer::normalize(MyReal *data) { -void ClassificationLayer::normalize(MyReal* data) -{ + /* Find maximum value */ + MyReal max = vecmax(dim_Out, data); + /* Shift the data vector */ + for (int io = 0; io < dim_Out; io++) { + data[io] = data[io] - max; + } +} - /* Find maximum value */ - MyReal max = vecmax(dim_Out, data); - /* Shift the data vector */ - for (int io = 0; io < dim_Out; io++) - { - data[io] = data[io] - max; - } -} - -void ClassificationLayer::normalize_diff(MyReal* data, - MyReal* data_bar) -{ - MyReal max_b = 0.0; - /* Derivative of the shift */ - for (int io = 0; io < dim_Out; io++) - { - max_b -= data_bar[io]; - } - /* Derivative of the vecmax */ - int i_max = argvecmax(dim_Out, data); - data_bar[i_max] += max_b; -} +void ClassificationLayer::normalize_diff(MyReal *data, MyReal *data_bar) { + MyReal max_b = 0.0; + /* Derivative of the shift */ + for (int io = 0; io < dim_Out; io++) { + max_b -= data_bar[io]; + } + /* Derivative of the vecmax */ + int i_max = argvecmax(dim_Out, data); + data_bar[i_max] += max_b; +} -MyReal ClassificationLayer::crossEntropy(MyReal *data_Out) -{ - MyReal label_pr, exp_sum; - MyReal CELoss; +MyReal ClassificationLayer::crossEntropy(MyReal *data_Out) { + MyReal label_pr, exp_sum; + MyReal CELoss; - /* Label projection */ - label_pr = vecdot(dim_Out, label, data_Out); + /* Label projection */ + label_pr = vecdot(dim_Out, label, data_Out); - /* Compute sum_i (exp(x_i)) */ - exp_sum = 0.0; - for (int io = 0; io < dim_Out; io++) - { - exp_sum += exp(data_Out[io]); - } + /* Compute sum_i (exp(x_i)) */ + exp_sum = 0.0; + for (int io = 0; io < dim_Out; io++) { + exp_sum += exp(data_Out[io]); + } - /* Cross entropy loss function */ - CELoss = - label_pr + log(exp_sum); + /* Cross entropy loss function */ + CELoss = -label_pr + log(exp_sum); - return CELoss; + return CELoss; } - - -void ClassificationLayer::crossEntropy_diff(MyReal *data_Out, - MyReal *data_Out_bar, - MyReal loss_bar) -{ - MyReal exp_sum, exp_sum_bar; - MyReal label_pr_bar = - loss_bar; - - /* Recompute exp_sum */ - exp_sum = 0.0; - for (int io = 0; io < dim_Out; io++) - { - exp_sum += exp(data_Out[io]); - } - /* derivative of log(exp_sum) */ - exp_sum_bar = 1./exp_sum * loss_bar; - for (int io = 0; io < dim_Out; io++) - { - data_Out_bar[io] = exp(data_Out[io]) * exp_sum_bar; - } +void ClassificationLayer::crossEntropy_diff(MyReal *data_Out, + MyReal *data_Out_bar, + MyReal loss_bar) { + MyReal exp_sum, exp_sum_bar; + MyReal label_pr_bar = -loss_bar; + + /* Recompute exp_sum */ + exp_sum = 0.0; + for (int io = 0; io < dim_Out; io++) { + exp_sum += exp(data_Out[io]); + } - /* Derivative of vecdot */ - for (int io = 0; io < dim_Out; io++) - { - data_Out_bar[io] += label[io] * label_pr_bar; - } -} + /* derivative of log(exp_sum) */ + exp_sum_bar = 1. / exp_sum * loss_bar; + for (int io = 0; io < dim_Out; io++) { + data_Out_bar[io] = exp(data_Out[io]) * exp_sum_bar; + } + /* Derivative of vecdot */ + for (int io = 0; io < dim_Out; io++) { + data_Out_bar[io] += label[io] * label_pr_bar; + } +} -int ClassificationLayer::prediction(MyReal* data_Out, - int* class_id_ptr) -{ - MyReal exp_sum, max; - int class_id = -1; - int success = 0; - - /* Compute sum_i (exp(x_i)) */ - max = -1.0; - exp_sum = 0.0; - for (int io = 0; io < dim_Out; io++) - { - exp_sum += exp(data_Out[io]); - } - - for (int io = 0; io < dim_Out; io++) - { - /* Compute class probabilities (Softmax) */ - probability[io] = exp(data_Out[io]) / exp_sum; - - /* Predicted class is the one with maximum probability */ - if (probability[io] > max) - { - max = probability[io]; - class_id = io; - } - } +int ClassificationLayer::prediction(MyReal *data_Out, int *class_id_ptr) { + MyReal exp_sum, max; + int class_id = -1; + int success = 0; - /* Test for successful prediction */ - if ( label[class_id] > 0.99 ) - { - success = 1; + /* Compute sum_i (exp(x_i)) */ + max = -1.0; + exp_sum = 0.0; + for (int io = 0; io < dim_Out; io++) { + exp_sum += exp(data_Out[io]); } - - /* return */ - *class_id_ptr = class_id; - return success; -} - + for (int io = 0; io < dim_Out; io++) { + /* Compute class probabilities (Softmax) */ + probability[io] = exp(data_Out[io]) / exp_sum; -MyReal Layer::ReLu_act(MyReal x) -{ - MyReal max = 0.0; + /* Predicted class is the one with maximum probability */ + if (probability[io] > max) { + max = probability[io]; + class_id = io; + } + } - if ( x > 0.0 ) max = x; + /* Test for successful prediction */ + if (label[class_id] > 0.99) { + success = 1; + } - return max; + /* return */ + *class_id_ptr = class_id; + return success; } +MyReal Layer::ReLu_act(MyReal x) { + MyReal max = 0.0; -MyReal Layer::dReLu_act(MyReal x) -{ - MyReal diff; - if (x >= 0.0) diff = 1.0; - else diff = 0.0; + if (x > 0.0) + max = x; - return diff; + return max; } +MyReal Layer::dReLu_act(MyReal x) { + MyReal diff; + if (x >= 0.0) + diff = 1.0; + else + diff = 0.0; -MyReal Layer::SmoothReLu_act(MyReal x) -{ - /* range of quadratic interpolation */ - MyReal eta = 0.1; - /* Coefficients of quadratic interpolation */ - MyReal a = 1./(4.*eta); - MyReal b = 1./2.; - MyReal c = eta / 4.; - - if (-eta < x && x < eta) - { - /* Quadratic Activation */ - return a*pow(x,2) + b*x + c; - } - else - { - /* ReLu Activation */ - return Layer::ReLu_act(x); - } + return diff; } -MyReal Layer::dSmoothReLu_act(MyReal x) -{ - /* range of quadratic interpolation */ - MyReal eta = 0.1; - /* Coefficients of quadratic interpolation */ - MyReal a = 1./(4.*eta); - MyReal b = 1./2.; - - if (-eta < x && x < eta) - { - return 2.*a*x + b; - } - else - { - return Layer::dReLu_act(x); - } - +MyReal Layer::SmoothReLu_act(MyReal x) { + /* range of quadratic interpolation */ + MyReal eta = 0.1; + /* Coefficients of quadratic interpolation */ + MyReal a = 1. / (4. * eta); + MyReal b = 1. / 2.; + MyReal c = eta / 4.; + + if (-eta < x && x < eta) { + /* Quadratic Activation */ + return a * pow(x, 2) + b * x + c; + } else { + /* ReLu Activation */ + return Layer::ReLu_act(x); + } } - -MyReal Layer::tanh_act(MyReal x) -{ - return tanh(x); +MyReal Layer::dSmoothReLu_act(MyReal x) { + /* range of quadratic interpolation */ + MyReal eta = 0.1; + /* Coefficients of quadratic interpolation */ + MyReal a = 1. / (4. * eta); + MyReal b = 1. / 2.; + + if (-eta < x && x < eta) { + return 2. * a * x + b; + } else { + return Layer::dReLu_act(x); + } } -MyReal Layer::dtanh_act(MyReal x) -{ - MyReal diff = 1.0 - pow(tanh(x),2); +MyReal Layer::tanh_act(MyReal x) { return tanh(x); } + +MyReal Layer::dtanh_act(MyReal x) { + MyReal diff = 1.0 - pow(tanh(x), 2); - return diff; + return diff; } -ConvLayer::ConvLayer(int idx, - int dimI, - int dimO, - int csize_in, - int nconv_in, - MyReal deltaT, - int Activ, - MyReal Gammatik, - MyReal Gammaddt) : Layer(idx, CONVOLUTION, - dimI, dimO, dimI/nconv_in, csize_in*csize_in*nconv_in*nconv_in, - deltaT, Activ, Gammatik, Gammaddt) -{ - csize = csize_in; - nconv = nconv_in; +ConvLayer::ConvLayer(int idx, int dimI, int dimO, int csize_in, int nconv_in, + MyReal deltaT, int Activ, MyReal Gammatik, MyReal Gammaddt) + : Layer(idx, CONVOLUTION, dimI, dimO, dimI / nconv_in, + csize_in * csize_in * nconv_in * nconv_in, deltaT, Activ, Gammatik, + Gammaddt) { + csize = csize_in; + nconv = nconv_in; - fcsize = floor(csize/2.0); - csize2 = csize*csize; + fcsize = floor(csize / 2.0); + csize2 = csize * csize; - img_size = dim_In / nconv; - img_size_sqrt = round(sqrt(img_size)); + img_size = dim_In / nconv; + img_size_sqrt = round(sqrt(img_size)); - // nweights = csize*csize*nconv*nconv; - // ndesign = nweights + dimI/nconv; // must add to account for the bias + // nweights = csize*csize*nconv*nconv; + // ndesign = nweights + dimI/nconv; // must add to account for the bias } - + ConvLayer::~ConvLayer() {} -/** +/** * This method is designed to be used only in the applyBWD. It computes the * derivative of the objective with respect to the weights. In particular * if you objective is $g$ and your kernel operator has value tau at index @@ -943,316 +756,297 @@ ConvLayer::~ConvLayer() {} * * d_tau [ g] = \sum_{image j,k} tau state_{j+a,k+b} * update_bar_{j,k} * - * Note that we assume that update_bar is + * Note that we assume that update_bar is * * update_bar = dt * dactivation * state_bar * * Where state_bar _must_ be at the old time. Note that the adjoint variable * state_bar carries withit all the information of the objective derivative. */ -MyReal ConvLayer:: -updateWeightDerivative(MyReal* state, - MyReal* update_bar, - int output_conv, /* output convolution */ - int j, /* pixel index */ - int k) /* pixel index */ +MyReal +ConvLayer::updateWeightDerivative(MyReal *state, MyReal *update_bar, + int output_conv, /* output convolution */ + int j, /* pixel index */ + int k) /* pixel index */ { - MyReal val = 0; - - int fcsize_s_l = -fcsize; - int fcsize_s_u = fcsize; - int fcsize_t_l = -fcsize; - int fcsize_t_u = fcsize; - int fcsize_s_l_adj = -fcsize; - int fcsize_t_l_adj = -fcsize; - - if((j+fcsize_s_l) < 0) fcsize_s_l = -j; - if((k+fcsize_t_l) < 0) fcsize_t_l = -k; - if((j+fcsize_s_u) >= img_size_sqrt) fcsize_s_u = img_size_sqrt-j-1; - if((k+fcsize_t_u) >= img_size_sqrt) fcsize_t_u = img_size_sqrt-k-1; - - if((j-fcsize_s_l_adj) >= img_size_sqrt) fcsize_s_l_adj = -(img_size_sqrt-j-1); - if((k-fcsize_t_l_adj) >= img_size_sqrt) fcsize_t_l_adj = -(img_size_sqrt-k-1); - - const int fcsize_s = fcsize_s_u-fcsize_s_l; - const int fcsize_t = fcsize_t_u-fcsize_t_l; - - int center_index = j*img_size_sqrt+k; - int input_wght_idx = output_conv*csize2*nconv + fcsize*(csize+1); - - int offset = fcsize_t_l + img_size_sqrt*fcsize_s_l; - int wght_idx = fcsize_t_l+ csize*fcsize_s_l; - - int offset_adj = - fcsize_t_l_adj - img_size_sqrt*fcsize_s_l_adj; - int wght_idx_adj = fcsize_t_l_adj + csize*fcsize_s_l_adj; - - for(int input_image = 0; input_image < nconv; input_image++, - center_index+= img_size, - input_wght_idx+=csize2) - { - MyReal update_val = update_bar[center_index]; - - MyReal * state_base = state + center_index+ offset; - MyReal * weights_bar_base = weights_bar + input_wght_idx + wght_idx; - - MyReal * update_base = update_bar + center_index + offset_adj; - MyReal * weights_base = weights + input_wght_idx + wght_idx_adj; - - // weight derivative - for(int s = 0; s <= fcsize_s; s++, - state_base+=img_size_sqrt, - weights_bar_base+=csize, - update_base-=img_size_sqrt, - weights_base+=csize) - { - MyReal * state_local = state_base; - MyReal * weights_bar_local = weights_bar_base; - - MyReal * update_local = update_base; - MyReal * weights_local = weights_base; - - for(int t = 0; t <= fcsize_t; t++, - state_local++, - weights_bar_local++, - update_local--, - weights_local++) - { - (*weights_bar_local) += update_val*(*state_local); - val += (*update_local)*(*weights_local); - } + MyReal val = 0; + + int fcsize_s_l = -fcsize; + int fcsize_s_u = fcsize; + int fcsize_t_l = -fcsize; + int fcsize_t_u = fcsize; + int fcsize_s_l_adj = -fcsize; + int fcsize_t_l_adj = -fcsize; + + if ((j + fcsize_s_l) < 0) + fcsize_s_l = -j; + if ((k + fcsize_t_l) < 0) + fcsize_t_l = -k; + if ((j + fcsize_s_u) >= img_size_sqrt) + fcsize_s_u = img_size_sqrt - j - 1; + if ((k + fcsize_t_u) >= img_size_sqrt) + fcsize_t_u = img_size_sqrt - k - 1; + + if ((j - fcsize_s_l_adj) >= img_size_sqrt) + fcsize_s_l_adj = -(img_size_sqrt - j - 1); + if ((k - fcsize_t_l_adj) >= img_size_sqrt) + fcsize_t_l_adj = -(img_size_sqrt - k - 1); + + const int fcsize_s = fcsize_s_u - fcsize_s_l; + const int fcsize_t = fcsize_t_u - fcsize_t_l; + + int center_index = j * img_size_sqrt + k; + int input_wght_idx = output_conv * csize2 * nconv + fcsize * (csize + 1); + + int offset = fcsize_t_l + img_size_sqrt * fcsize_s_l; + int wght_idx = fcsize_t_l + csize * fcsize_s_l; + + int offset_adj = -fcsize_t_l_adj - img_size_sqrt * fcsize_s_l_adj; + int wght_idx_adj = fcsize_t_l_adj + csize * fcsize_s_l_adj; + + for (int input_image = 0; input_image < nconv; + input_image++, center_index += img_size, input_wght_idx += csize2) { + MyReal update_val = update_bar[center_index]; + + MyReal *state_base = state + center_index + offset; + MyReal *weights_bar_base = weights_bar + input_wght_idx + wght_idx; + + MyReal *update_base = update_bar + center_index + offset_adj; + MyReal *weights_base = weights + input_wght_idx + wght_idx_adj; + + // weight derivative + for (int s = 0; s <= fcsize_s; s++, state_base += img_size_sqrt, + weights_bar_base += csize, update_base -= img_size_sqrt, + weights_base += csize) { + MyReal *state_local = state_base; + MyReal *weights_bar_local = weights_bar_base; + + MyReal *update_local = update_base; + MyReal *weights_local = weights_base; + + for (int t = 0; t <= fcsize_t; t++, state_local++, weights_bar_local++, + update_local--, weights_local++) { + (*weights_bar_local) += update_val * (*state_local); + val += (*update_local) * (*weights_local); } - } + } + } - return val; + return val; } -MyReal ConvLayer::apply_conv(MyReal* state, - int output_conv, /* output convolution */ - int j, /* pixel index */ - int k) /* pixel index */ +MyReal ConvLayer::apply_conv(MyReal *state, + int output_conv, /* output convolution */ + int j, /* pixel index */ + int k) /* pixel index */ { - MyReal val = 0.0; - - int fcsize_s_l = -fcsize; - int fcsize_s_u = fcsize; - int fcsize_t_l = -fcsize; - int fcsize_t_u = fcsize; - - // protect indexing at image boundaries - if((j+fcsize_s_l) < 0) fcsize_s_l = -j; - if((k+fcsize_t_l) < 0) fcsize_t_l = -k; - if((j+fcsize_s_u) >= img_size_sqrt) fcsize_s_u = img_size_sqrt-j-1; - if((k+fcsize_t_u) >= img_size_sqrt) fcsize_t_u = img_size_sqrt-k-1; - - const int fcsize_s = fcsize_s_u-fcsize_s_l; - const int fcsize_t = fcsize_t_u-fcsize_t_l; - - int center_index = j*img_size_sqrt+k+fcsize_t_l + img_size_sqrt*fcsize_s_l; - int input_wght_idx = output_conv*csize2*nconv +fcsize*(csize+1) + fcsize_t_l+csize*fcsize_s_l; - - /* loop over all the images */ - for(int input_image = 0; input_image < nconv; input_image++, - center_index+= img_size, - input_wght_idx+=csize2) - { - MyReal * state_base = state + center_index; - MyReal * weights_base = weights + input_wght_idx; - - for(int s = 0; s <= fcsize_s; s++, state_base+=img_size_sqrt, - weights_base+=csize) - { - MyReal * state_local = state_base; - MyReal * weights_local = weights_base; - - for(int t = 0; t <= fcsize_t; t++,state_local++,weights_local++) - { - val += (*state_local)*(*weights_local); - } + MyReal val = 0.0; + + int fcsize_s_l = -fcsize; + int fcsize_s_u = fcsize; + int fcsize_t_l = -fcsize; + int fcsize_t_u = fcsize; + + // protect indexing at image boundaries + if ((j + fcsize_s_l) < 0) + fcsize_s_l = -j; + if ((k + fcsize_t_l) < 0) + fcsize_t_l = -k; + if ((j + fcsize_s_u) >= img_size_sqrt) + fcsize_s_u = img_size_sqrt - j - 1; + if ((k + fcsize_t_u) >= img_size_sqrt) + fcsize_t_u = img_size_sqrt - k - 1; + + const int fcsize_s = fcsize_s_u - fcsize_s_l; + const int fcsize_t = fcsize_t_u - fcsize_t_l; + + int center_index = + j * img_size_sqrt + k + fcsize_t_l + img_size_sqrt * fcsize_s_l; + int input_wght_idx = output_conv * csize2 * nconv + fcsize * (csize + 1) + + fcsize_t_l + csize * fcsize_s_l; + + /* loop over all the images */ + for (int input_image = 0; input_image < nconv; + input_image++, center_index += img_size, input_wght_idx += csize2) { + MyReal *state_base = state + center_index; + MyReal *weights_base = weights + input_wght_idx; + + for (int s = 0; s <= fcsize_s; + s++, state_base += img_size_sqrt, weights_base += csize) { + MyReal *state_local = state_base; + MyReal *weights_local = weights_base; + + for (int t = 0; t <= fcsize_t; t++, state_local++, weights_local++) { + val += (*state_local) * (*weights_local); } - } + } + } - return val; + return val; } -MyReal ConvLayer::apply_conv_trans(MyReal* state, - int output_conv, /* output convolution */ - int j, /* pixel index */ - int k) /* pixel index */ +MyReal ConvLayer::apply_conv_trans(MyReal *state, + int output_conv, /* output convolution */ + int j, /* pixel index */ + int k) /* pixel index */ { - MyReal val = 0.0; - - int fcsize_s_l = -fcsize; - int fcsize_s_u = fcsize; - int fcsize_t_l = -fcsize; - int fcsize_t_u = fcsize; - - if((j-fcsize_s_u) < 0) fcsize_s_u = j; - if((k-fcsize_t_u) < 0) fcsize_t_u = k; - if((j-fcsize_s_l) >= img_size_sqrt) fcsize_s_l = -(img_size_sqrt-j-1); - if((k-fcsize_t_l) >= img_size_sqrt) fcsize_t_l = -(img_size_sqrt-k-1); - - const int fcsize_s = fcsize_s_u-fcsize_s_l; - const int fcsize_t = fcsize_t_u-fcsize_t_l; - - /* loop over all the images */ - int center_index = j*img_size_sqrt+k; - int input_wght_idx = output_conv*csize2*nconv; - for(int input_image = 0; input_image < nconv; input_image++, - center_index+=img_size, - input_wght_idx+=csize2) - { - int offset = center_index - fcsize_t_l; - int wght_idx = input_wght_idx + fcsize*(csize+1) + fcsize_t_l; - - MyReal * state_base = state + offset - img_size_sqrt*fcsize_s_l; - MyReal * weights_base = weights + wght_idx + csize*fcsize_s_l; - - for(int s = 0; s <= fcsize_s; s++, state_base-=img_size_sqrt, - weights_base+=csize) - { - MyReal * state_local = state_base; - MyReal * weights_local = weights_base; - - for(int t = 0; t <= fcsize_t; t++,state_local--,weights_local++) - { - val += (*state_local)*(*weights_local); - } + MyReal val = 0.0; + + int fcsize_s_l = -fcsize; + int fcsize_s_u = fcsize; + int fcsize_t_l = -fcsize; + int fcsize_t_u = fcsize; + + if ((j - fcsize_s_u) < 0) + fcsize_s_u = j; + if ((k - fcsize_t_u) < 0) + fcsize_t_u = k; + if ((j - fcsize_s_l) >= img_size_sqrt) + fcsize_s_l = -(img_size_sqrt - j - 1); + if ((k - fcsize_t_l) >= img_size_sqrt) + fcsize_t_l = -(img_size_sqrt - k - 1); + + const int fcsize_s = fcsize_s_u - fcsize_s_l; + const int fcsize_t = fcsize_t_u - fcsize_t_l; + + /* loop over all the images */ + int center_index = j * img_size_sqrt + k; + int input_wght_idx = output_conv * csize2 * nconv; + for (int input_image = 0; input_image < nconv; + input_image++, center_index += img_size, input_wght_idx += csize2) { + int offset = center_index - fcsize_t_l; + int wght_idx = input_wght_idx + fcsize * (csize + 1) + fcsize_t_l; + + MyReal *state_base = state + offset - img_size_sqrt * fcsize_s_l; + MyReal *weights_base = weights + wght_idx + csize * fcsize_s_l; + + for (int s = 0; s <= fcsize_s; + s++, state_base -= img_size_sqrt, weights_base += csize) { + MyReal *state_local = state_base; + MyReal *weights_local = weights_base; + + for (int t = 0; t <= fcsize_t; t++, state_local--, weights_local++) { + val += (*state_local) * (*weights_local); } - } + } + } - return val; + return val; } -void ConvLayer::applyFWD(MyReal* state) -{ - /* Apply step */ - for (int io = 0; io < dim_Out; io++) - update[io] = state[io]; - - /* Affine transformation */ - for(int i = 0; i < nconv; i++) - { - for(int j = 0; j < img_size_sqrt; j++) - { - int state_index = i*img_size + j*img_size_sqrt; - MyReal * update_local = state + state_index; - MyReal * bias_local = bias+j*img_size_sqrt; - - for(int k = 0; k < img_size_sqrt; k++, - update_local++, - bias_local++) - { - // (*update_local) += dt*tanh(apply_conv(update, i, j, k) + (*bias_local)); - (*update_local) += dt*ReLu_act(apply_conv(update, i, j, k) + (*bias_local)); - } +void ConvLayer::applyFWD(MyReal *state) { + /* Apply step */ + for (int io = 0; io < dim_Out; io++) + update[io] = state[io]; + + /* Affine transformation */ + for (int i = 0; i < nconv; i++) { + for (int j = 0; j < img_size_sqrt; j++) { + int state_index = i * img_size + j * img_size_sqrt; + MyReal *update_local = state + state_index; + MyReal *bias_local = bias + j * img_size_sqrt; + + for (int k = 0; k < img_size_sqrt; k++, update_local++, bias_local++) { + // (*update_local) += dt*tanh(apply_conv(update, i, j, k) + + // (*bias_local)); + (*update_local) += + dt * ReLu_act(apply_conv(update, i, j, k) + (*bias_local)); } - } + } + } } +void ConvLayer::applyBWD(MyReal *state, MyReal *state_bar, + int compute_gradient) { + /* state_bar is the adjoint of the state variable, it contains the + old time adjoint information, and is modified on the way out to + contain the update. */ -void ConvLayer::applyBWD(MyReal* state, - MyReal* state_bar, - int compute_gradient) -{ - /* state_bar is the adjoint of the state variable, it contains the - old time adjoint information, and is modified on the way out to - contain the update. */ - - /* Okay, for my own clarity: - state = forward state solution - state_bar = backward adjoint solution (in - new time, out - current time) - update_bar = update to the bacward solution, this is "MyReal dipped" in that - it is used to compute the weight and bias derivative. - Note that because this is written as a forward update (the - residual is F = u_{n+1} - u_n - dt * sigma(W_n * u_n + b_n) - the adjoint variable is also the derivative of the objective - with respect to the solution. - weights_bar = Derivative of the objective with respect to the weights - bias_bar = Derivative of the objective with respect to the bias - - - More details: Assume that the objective is 'g', and the constraint in - residual form is F(u,W). Then - - d_{W_n} g = \partial_{u} g * \partial_{W_n} u - - Note that $\partial_{u} g$ only depends on the final layer. Expanding - around the constraint then gives - - d_{W_n} g = \partial_{u} g * (\partial_{u} F)^{-1} * \partial_{W_n} F - - and now doing the standard adjoint thing we get - - d_{W_n} g = (\partial_{u} F)^{-T} * \partial_{u} g ) * \partial_{W_n} F - - yielding - - d_{W_n} g = state_bar * \partial_{W_n} F - - This is directly - - weights_bar = state_bar * \partial_{W_n} F - - computed below. Similar for the bias. - */ - - /* Affine transformation, and derivative of time step */ - - /* loop over number convolutions */ - for(int i = 0; i < nconv; i++) - { - /* loop over full image */ - for(int j = 0; j < img_size_sqrt; j++) - { - int state_index = i*img_size + j*img_size_sqrt; - MyReal * state_bar_local = state_bar + state_index; - MyReal * update_bar_local = update_bar + state_index; - MyReal * bias_local = bias+j*img_size_sqrt; - - for(int k = 0; k < img_size_sqrt; k++, - state_bar_local++, - update_bar_local++, - bias_local++) - { - /* compute the affine transformation */ - MyReal local_update = apply_conv(state, i, j, k) + (*bias_local); - - /* derivative of the update, this is the contribution from old time */ - // (*update_bar_local) = dt * dactivation(local_update) * (*state_bar_local); - // (*update_bar_local) = dt * (1.0-pow(tanh(local_update),2)) * (*state_bar_local); - (*update_bar_local) = dt * dReLu_act(local_update) * (*state_bar_local); - } + /* Okay, for my own clarity: + state = forward state solution + state_bar = backward adjoint solution (in - new time, out - current time) + update_bar = update to the bacward solution, this is "MyReal dipped" in + that it is used to compute the weight and bias derivative. Note that + because this is written as a forward update (the residual is F = u_{n+1} - + u_n - dt * sigma(W_n * u_n + b_n) the adjoint variable is also the + derivative of the objective with respect to the solution. weights_bar = + Derivative of the objective with respect to the weights bias_bar = + Derivative of the objective with respect to the bias + + + More details: Assume that the objective is 'g', and the constraint in + residual form is F(u,W). Then + + d_{W_n} g = \partial_{u} g * \partial_{W_n} u + + Note that $\partial_{u} g$ only depends on the final layer. Expanding + around the constraint then gives + + d_{W_n} g = \partial_{u} g * (\partial_{u} F)^{-1} * \partial_{W_n} F + + and now doing the standard adjoint thing we get + + d_{W_n} g = (\partial_{u} F)^{-T} * \partial_{u} g ) * \partial_{W_n} F + + yielding + + d_{W_n} g = state_bar * \partial_{W_n} F + + This is directly + + weights_bar = state_bar * \partial_{W_n} F + + computed below. Similar for the bias. + */ + + /* Affine transformation, and derivative of time step */ + + /* loop over number convolutions */ + for (int i = 0; i < nconv; i++) { + /* loop over full image */ + for (int j = 0; j < img_size_sqrt; j++) { + int state_index = i * img_size + j * img_size_sqrt; + MyReal *state_bar_local = state_bar + state_index; + MyReal *update_bar_local = update_bar + state_index; + MyReal *bias_local = bias + j * img_size_sqrt; + + for (int k = 0; k < img_size_sqrt; + k++, state_bar_local++, update_bar_local++, bias_local++) { + /* compute the affine transformation */ + MyReal local_update = apply_conv(state, i, j, k) + (*bias_local); + + /* derivative of the update, this is the contribution from old time */ + // (*update_bar_local) = dt * dactivation(local_update) * + // (*state_bar_local); + // (*update_bar_local) = dt * (1.0-pow(tanh(local_update),2)) * + // (*state_bar_local); + (*update_bar_local) = dt * dReLu_act(local_update) * (*state_bar_local); } - } - - /* Loop over the output dimensions */ - for(int i = 0; i < nconv; i++) - { - /* loop over full image */ - for(int j = 0; j < img_size_sqrt; j++) - { - int state_index = i*img_size + j*img_size_sqrt; - - MyReal * state_bar_local = state_bar + state_index; - MyReal * update_bar_local = update_bar + state_index; - MyReal * bias_bar_local = bias_bar+j*img_size_sqrt; - - for(int k = 0; k < img_size_sqrt; k++, - state_bar_local++, - update_bar_local++, - bias_bar_local++) - { - if (compute_gradient) - { - (*bias_bar_local) += (*update_bar_local); - - (*state_bar_local) += updateWeightDerivative(state,update_bar,i,j,k); - } - else { - (*state_bar_local) += apply_conv_trans(update_bar, i, j, k); - } - } + } + } + + /* Loop over the output dimensions */ + for (int i = 0; i < nconv; i++) { + /* loop over full image */ + for (int j = 0; j < img_size_sqrt; j++) { + int state_index = i * img_size + j * img_size_sqrt; + + MyReal *state_bar_local = state_bar + state_index; + MyReal *update_bar_local = update_bar + state_index; + MyReal *bias_bar_local = bias_bar + j * img_size_sqrt; + + for (int k = 0; k < img_size_sqrt; + k++, state_bar_local++, update_bar_local++, bias_bar_local++) { + if (compute_gradient) { + (*bias_bar_local) += (*update_bar_local); + + (*state_bar_local) += + updateWeightDerivative(state, update_bar, i, j, k); + } else { + (*state_bar_local) += apply_conv_trans(update_bar, i, j, k); + } } + } - } // end for i + } // end for i } diff --git a/src/linalg.cpp b/src/linalg.cpp index 5fa3b90..c51b6f5 100644 --- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -1,131 +1,88 @@ #include "linalg.hpp" +MyReal vecdot_par(int dimN, MyReal *x, MyReal *y, MPI_Comm comm) { -MyReal vecdot_par(int dimN, - MyReal* x, - MyReal* y, - MPI_Comm comm) -{ + MyReal localdot, globaldot; - MyReal localdot, globaldot; + localdot = vecdot(dimN, x, y); + MPI_Allreduce(&localdot, &globaldot, 1, MPI_MyReal, MPI_SUM, comm); - localdot = vecdot(dimN, x,y); - MPI_Allreduce(&localdot, &globaldot, 1, MPI_MyReal, MPI_SUM, comm); - - return globaldot; -} - - -MyReal vecdot(int dimN, - MyReal* x, - MyReal* y) -{ - MyReal dotprod = 0.0; - for (int i = 0; i < dimN; i++) - { - dotprod += x[i] * y[i]; - } - return dotprod; + return globaldot; } - -MyReal vecmax(int dimN, - MyReal* x) -{ - MyReal max = - 1e+12; - - for (int i = 0; i < dimN; i++) - { - if (x[i] > max) - { - max = x[i]; - } - } - return max; +MyReal vecdot(int dimN, MyReal *x, MyReal *y) { + MyReal dotprod = 0.0; + for (int i = 0; i < dimN; i++) { + dotprod += x[i] * y[i]; + } + return dotprod; } +MyReal vecmax(int dimN, MyReal *x) { + MyReal max = -1e+12; -int argvecmax(int dimN, - MyReal* x) -{ - MyReal max = - 1e+12; - int i_max; - for (int i = 0; i < dimN; i++) - { - if (x[i] > max) - { - max = x[i]; - i_max = i; - } + for (int i = 0; i < dimN; i++) { + if (x[i] > max) { + max = x[i]; } - return i_max; + } + return max; } -MyReal vecnormsq(int dimN, - MyReal *x) -{ - MyReal normsq = 0.0; - for (int i = 0; i max) { + max = x[i]; + i_max = i; } - return normsq; -} + } + return i_max; +} -MyReal vecnorm_par(int dimN, - MyReal *x, - MPI_Comm comm) -{ - MyReal localnorm, globalnorm; +MyReal vecnormsq(int dimN, MyReal *x) { + MyReal normsq = 0.0; + for (int i = 0; i < dimN; i++) { + normsq += pow(x[i], 2); + } + return normsq; +} - localnorm = vecnormsq(dimN, x); - MPI_Allreduce(&localnorm, &globalnorm, 1, MPI_MyReal, MPI_SUM, comm); - globalnorm = sqrt(globalnorm); +MyReal vecnorm_par(int dimN, MyReal *x, MPI_Comm comm) { + MyReal localnorm, globalnorm; - return globalnorm; + localnorm = vecnormsq(dimN, x); + MPI_Allreduce(&localnorm, &globalnorm, 1, MPI_MyReal, MPI_SUM, comm); + globalnorm = sqrt(globalnorm); + + return globalnorm; } -int vec_copy(int N, - MyReal* u, - MyReal* u_copy) -{ - for (int i=0; i -#include +#include #include +#include #include -#include +#include +#include "braid_wrapper.hpp" +#include "config.hpp" +#include "dataset.hpp" #include "defs.hpp" #include "hessianApprox.hpp" -#include "util.hpp" #include "layer.hpp" -#include "braid_wrapper.hpp" -#include "config.hpp" #include "network.hpp" -#include "dataset.hpp" +#include "util.hpp" #define MASTER_NODE 0 -int main (int argc, char *argv[]) -{ - /* --- Data --- */ - Config* config; /**< Storing configurations */ - DataSet* trainingdata; /**< Training dataset */ - DataSet* validationdata; /**< Validation dataset */ - - /* --- Network --- */ - Network* network; /**< DNN Network architecture */ - int ilower, iupper; /**< Index of first and last layer stored on this processor */ - MyReal accur_train = 0.0; /**< Accuracy on training data */ - MyReal accur_val = 0.0; /**< Accuracy on validation data */ - MyReal loss_train = 0.0; /**< Loss function on training data */ - MyReal loss_val = 0.0; /**< Loss function on validation data */ - MyReal losstrain_out = 0.0; - MyReal lossval_out = 0.0; - MyReal accurtrain_out = 0.0; - MyReal accurval_out = 0.0; - - /* --- XBraid --- */ - myBraidApp *primaltrainapp; /**< Braid App for training data */ - myAdjointBraidApp *adjointtrainapp; /**< Adjoint Braid for training data */ - myBraidApp *primalvalapp; /**< Braid App for validation data */ - - /* --- Optimization --- */ - int ndesign_local; /**< Number of local design variables on this processor */ - int ndesign_global; /**< Number of global design variables (sum of local)*/ - MyReal* ascentdir=0; /**< Direction for design updates */ - MyReal objective; /**< Optimization objective */ - MyReal wolfe; /**< Holding the wolfe condition value */ - MyReal rnorm; /**< Space-time Norm of the state variables */ - MyReal rnorm_adj; /**< Space-time norm of the adjoint variables */ - MyReal gnorm; /**< Norm of the gradient */ - MyReal ls_param; /**< Parameter in wolfe condition test */ - MyReal stepsize; /**< Stepsize used for design update */ - char optimfilename[255]; - FILE *optimfile = 0; - MyReal ls_stepsize; - MyReal ls_objective, test_obj; - int ls_iter; - - - /* --- other --- */ - int myid; - int size; - struct rusage r_usage; - MyReal StartTime, StopTime, myMB, globalMB; - MyReal UsedTime = 0.0; - - /* Initialize MPI */ - MPI_Init(&argc, &argv); - MPI_Comm_rank(MPI_COMM_WORLD, &myid); - MPI_Comm_size(MPI_COMM_WORLD, &size); - - - /*--- INITIALIZATION ---*/ - - /* Instantiate objects */ - config = new Config(); - trainingdata = new DataSet(); - validationdata = new DataSet(); - network = new Network(); - - - /* Read config file */ - if (argc != 2) - { - if ( myid == MASTER_NODE ) - { - printf("\n"); - printf("USAGE: ./main \n"); - } - MPI_Finalize(); - return (0); - } - int err = config->readFromFile(argv[1]); - if (err) - { - printf("\nError while reading config file!\n"); - MPI_Finalize(); - return (0); +int main(int argc, char *argv[]) { + /* --- Data --- */ + Config *config; /**< Storing configurations */ + DataSet *trainingdata; /**< Training dataset */ + DataSet *validationdata; /**< Validation dataset */ + + /* --- Network --- */ + Network *network; /**< DNN Network architecture */ + int ilower, + iupper; /**< Index of first and last layer stored on this processor */ + MyReal accur_train = 0.0; /**< Accuracy on training data */ + MyReal accur_val = 0.0; /**< Accuracy on validation data */ + MyReal loss_train = 0.0; /**< Loss function on training data */ + MyReal loss_val = 0.0; /**< Loss function on validation data */ + MyReal losstrain_out = 0.0; + MyReal lossval_out = 0.0; + MyReal accurtrain_out = 0.0; + MyReal accurval_out = 0.0; + + /* --- XBraid --- */ + myBraidApp *primaltrainapp; /**< Braid App for training data */ + myAdjointBraidApp *adjointtrainapp; /**< Adjoint Braid for training data */ + myBraidApp *primalvalapp; /**< Braid App for validation data */ + + /* --- Optimization --- */ + int ndesign_local; /**< Number of local design variables on this processor */ + int ndesign_global; /**< Number of global design variables (sum of local)*/ + MyReal *ascentdir = 0; /**< Direction for design updates */ + MyReal objective; /**< Optimization objective */ + MyReal wolfe; /**< Holding the wolfe condition value */ + MyReal rnorm; /**< Space-time Norm of the state variables */ + MyReal rnorm_adj; /**< Space-time norm of the adjoint variables */ + MyReal gnorm; /**< Norm of the gradient */ + MyReal ls_param; /**< Parameter in wolfe condition test */ + MyReal stepsize; /**< Stepsize used for design update */ + char optimfilename[255]; + FILE *optimfile = 0; + MyReal ls_stepsize; + MyReal ls_objective, test_obj; + int ls_iter; + + /* --- other --- */ + int myid; + int size; + struct rusage r_usage; + MyReal StartTime, StopTime, myMB, globalMB; + MyReal UsedTime = 0.0; + + /* Initialize MPI */ + MPI_Init(&argc, &argv); + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + MPI_Comm_size(MPI_COMM_WORLD, &size); + + /*--- INITIALIZATION ---*/ + + /* Instantiate objects */ + config = new Config(); + trainingdata = new DataSet(); + validationdata = new DataSet(); + network = new Network(); + + /* Read config file */ + if (argc != 2) { + if (myid == MASTER_NODE) { + printf("\n"); + printf("USAGE: ./main \n"); } + MPI_Finalize(); + return (0); + } + int err = config->readFromFile(argv[1]); + if (err) { + printf("\nError while reading config file!\n"); + MPI_Finalize(); + return (0); + } + + /* Initialize training and validation data */ + trainingdata->initialize(config->ntraining, config->nfeatures, + config->nclasses, config->nbatch, MPI_COMM_WORLD); + trainingdata->readData(config->datafolder, config->ftrain_ex, + config->ftrain_labels); + + validationdata->initialize(config->nvalidation, config->nfeatures, + config->nclasses, config->nvalidation, + MPI_COMM_WORLD); // full validation set! + validationdata->readData(config->datafolder, config->fval_ex, + config->fval_labels); + + /* Initialize XBraid */ + primaltrainapp = + new myBraidApp(trainingdata, network, config, MPI_COMM_WORLD); + adjointtrainapp = new myAdjointBraidApp( + trainingdata, network, config, primaltrainapp->getCore(), MPI_COMM_WORLD); + primalvalapp = + new myBraidApp(validationdata, network, config, MPI_COMM_WORLD); + + /* Initialize the network */ + primaltrainapp->GetGridDistribution(&ilower, &iupper); + network->createNetworkBlock(ilower, iupper, config, MPI_COMM_WORLD); + network->setInitialDesign(config); + ndesign_local = network->getnDesignLocal(); + ndesign_global = network->getnDesignGlobal(); + + /* Print some network information */ + int startid = ilower; + if (ilower == 0) + startid = -1; + printf("%d: Layer range: [%d, %d] / %d\n", myid, startid, iupper, + config->nlayers); + printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, + ndesign_global); + + /* Initialize hessian approximation */ + HessianApprox *hessian = 0; + switch (config->hessianapprox_type) { + case BFGS_SERIAL: + hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); + break; + case LBFGS: + hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); + break; + case IDENTITY: + hessian = new Identity(MPI_COMM_WORLD, ndesign_local); + } + + /* Allocate ascent direction for design updates */ + + /* Initialize optimization parameters */ + ascentdir = new MyReal[ndesign_local]; + stepsize = config->getStepsize(0); + gnorm = 0.0; + objective = 0.0; + rnorm = 0.0; + rnorm_adj = 0.0; + ls_param = 1e-4; + ls_iter = 0; + ls_stepsize = stepsize; + + /* Open and prepare optimization output file*/ + if (myid == MASTER_NODE) { + sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); + optimfile = fopen(optimfilename, "w"); + config->writeToFile(optimfile); + + fprintf(optimfile, + "# || r || || r_adj || Objective Loss " + " || grad || Stepsize ls_iter " + "Accur_train Accur_val Time(sec)\n"); + + /* Screen output */ + printf("\n# || r || || r_adj || Objective " + "Loss || grad || Stepsize ls_iter " + "Accur_train Accur_val Time(sec)\n"); + } +#if 1 + /* --- OPTIMIZATION --- */ + StartTime = MPI_Wtime(); + StopTime = 0.0; + UsedTime = 0.0; + for (int iter = 0; iter < config->maxoptimiter; iter++) { - /* Initialize training and validation data */ - trainingdata->initialize(config->ntraining, config->nfeatures, config->nclasses, config->nbatch, MPI_COMM_WORLD); - trainingdata->readData(config->datafolder, config->ftrain_ex, config->ftrain_labels); - - validationdata->initialize(config->nvalidation, config->nfeatures, config->nclasses, config->nvalidation, MPI_COMM_WORLD); // full validation set! - validationdata->readData(config->datafolder, config->fval_ex, config->fval_labels); - - - /* Initialize XBraid */ - primaltrainapp = new myBraidApp(trainingdata, network, config, MPI_COMM_WORLD); - adjointtrainapp = new myAdjointBraidApp(trainingdata, network, config, primaltrainapp->getCore(), MPI_COMM_WORLD); - primalvalapp = new myBraidApp(validationdata, network, config, MPI_COMM_WORLD); + /* --- Training data: Get objective and gradient ---*/ + /* Set up the current batch */ + trainingdata->selectBatch(config->batch_type, MPI_COMM_WORLD); - /* Initialize the network */ - primaltrainapp->GetGridDistribution(&ilower, &iupper); - network->createNetworkBlock(ilower, iupper, config, MPI_COMM_WORLD); - network->setInitialDesign(config); - ndesign_local = network->getnDesignLocal(); - ndesign_global = network->getnDesignGlobal(); + /* Solve state and adjoint equation */ + rnorm = primaltrainapp->run(); + rnorm_adj = adjointtrainapp->run(); - /* Print some network information */ - int startid = ilower; - if (ilower == 0) startid = -1; - printf("%d: Layer range: [%d, %d] / %d\n", myid, startid, iupper, config->nlayers); - printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, ndesign_global); + /* Get output */ + objective = primaltrainapp->getObjective(); + loss_train = network->getLoss(); + accur_train = network->getAccuracy(); + /* --- Validation data: Get accuracy --- */ - /* Initialize hessian approximation */ - HessianApprox *hessian = 0; - switch (config->hessianapprox_type) - { - case BFGS_SERIAL: - hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); - break; - case LBFGS: - hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); - break; - case IDENTITY: - hessian = new Identity(MPI_COMM_WORLD, ndesign_local); + if (config->validationlevel > 0) { + primalvalapp->run(); + loss_val = network->getLoss(); + accur_val = network->getAccuracy(); } - /* Allocate ascent direction for design updates */ - - /* Initialize optimization parameters */ - ascentdir = new MyReal[ndesign_local]; - stepsize = config->getStepsize(0); - gnorm = 0.0; - objective = 0.0; - rnorm = 0.0; - rnorm_adj = 0.0; - ls_param = 1e-4; - ls_iter = 0; - ls_stepsize = stepsize; + /* --- Optimization control and output ---*/ - /* Open and prepare optimization output file*/ - if (myid == MASTER_NODE) - { - sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); - optimfile = fopen(optimfilename, "w"); - config->writeToFile(optimfile); + /* Compute global gradient norm */ + gnorm = vecnorm_par(ndesign_local, network->getGradient(), MPI_COMM_WORLD); - fprintf(optimfile, "# || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec)\n"); + /* Communicate loss and accuracy. This is actually only needed for output. + * Remove it. */ + MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(&accur_train, &accurtrain_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(&accur_val, &accurval_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); - /* Screen output */ - printf("\n# || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec)\n"); + /* Output */ + StopTime = MPI_Wtime(); + UsedTime = StopTime - StartTime; + if (myid == MASTER_NODE) { + printf("%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " + "%2.2f%% %2.2f%% %.1f\n", + iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, + ls_iter, accurtrain_out, accurval_out, UsedTime); + fprintf(optimfile, + "%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " + "%2.2f%% %2.2f%% %.1f\n", + iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, + ls_iter, accurtrain_out, accurval_out, UsedTime); + fflush(optimfile); } + /* Check optimization convergence */ + if (gnorm < config->gtol) { + if (myid == MASTER_NODE) { + printf("Optimization has converged. \n"); + printf("Be happy and go home! \n"); + } + break; + } + if (iter == config->maxoptimiter - 1) { + if (myid == MASTER_NODE) { + printf("\nMax. optimization iterations reached.\n"); + } + break; + } -#if 1 - /* --- OPTIMIZATION --- */ - StartTime = MPI_Wtime(); - StopTime = 0.0; - UsedTime = 0.0; - for (int iter = 0; iter < config->maxoptimiter; iter++) - { - - /* --- Training data: Get objective and gradient ---*/ - - /* Set up the current batch */ - trainingdata->selectBatch(config->batch_type, MPI_COMM_WORLD); - - /* Solve state and adjoint equation */ - rnorm = primaltrainapp->run(); - rnorm_adj = adjointtrainapp->run(); + /* --- Design update --- */ - /* Get output */ - objective = primaltrainapp->getObjective(); - loss_train = network->getLoss(); - accur_train = network->getAccuracy(); + /* Compute search direction */ + hessian->updateMemory(iter, network->getDesign(), network->getGradient()); + hessian->computeAscentDir(iter, network->getGradient(), ascentdir); + /* Update the design in negative ascent direction */ + stepsize = config->getStepsize(iter); + network->updateDesign(-1.0 * stepsize, ascentdir, MPI_COMM_WORLD); - /* --- Validation data: Get accuracy --- */ + /* --- Backtracking linesearch --- */ - if ( config->validationlevel > 0 ) - { - primalvalapp->run(); - loss_val = network->getLoss(); - accur_val = network->getAccuracy(); - } + if (config->stepsize_type == BACKTRACKINGLS) { + /* Compute wolfe condition */ + wolfe = vecdot_par(ndesign_local, network->getGradient(), ascentdir, + MPI_COMM_WORLD); + /* Start linesearch iterations */ + ls_stepsize = config->getStepsize(iter); + stepsize = ls_stepsize; + for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) { - /* --- Optimization control and output ---*/ + primaltrainapp->getCore()->SetPrintLevel(0); + primaltrainapp->run(); + ls_objective = primaltrainapp->getObjective(); + primaltrainapp->getCore()->SetPrintLevel(config->braid_printlevel); - /* Compute global gradient norm */ - gnorm = vecnorm_par(ndesign_local, network->getGradient(), MPI_COMM_WORLD); - - /* Communicate loss and accuracy. This is actually only needed for output. Remove it. */ - MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&accur_train, &accurtrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&accur_val, &accurval_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - - /* Output */ - StopTime = MPI_Wtime(); - UsedTime = StopTime-StartTime; + test_obj = objective - ls_param * ls_stepsize * wolfe; if (myid == MASTER_NODE) - { - printf("%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d %2.2f%% %2.2f%% %.1f\n", iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, ls_iter, accurtrain_out, accurval_out, UsedTime); - fprintf(optimfile,"%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d %2.2f%% %2.2f%% %.1f\n", iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, ls_iter, accurtrain_out, accurval_out, UsedTime); - fflush(optimfile); - } - - /* Check optimization convergence */ - if ( gnorm < config->gtol ) - { - if (myid == MASTER_NODE) - { - printf("Optimization has converged. \n"); - printf("Be happy and go home! \n"); - } - break; - } - if ( iter == config->maxoptimiter - 1 ) - { + printf("ls_iter %d: %1.14e %1.14e\n", ls_iter, ls_objective, + test_obj); + /* Test the wolfe condition */ + if (ls_objective <= test_obj) { + /* Success, use this new design */ + break; + } else { + /* Test for line-search failure */ + if (ls_iter == config->ls_maxiter - 1) { if (myid == MASTER_NODE) - { - printf("\nMax. optimization iterations reached.\n"); - } + printf("\n\n WARNING: LINESEARCH FAILED! \n\n"); break; - } + } + /* Go back part of the step */ + network->updateDesign((1.0 - config->ls_factor) * stepsize, ascentdir, + MPI_COMM_WORLD); - /* --- Design update --- */ - - /* Compute search direction */ - hessian->updateMemory(iter, network->getDesign(), network->getGradient()); - hessian->computeAscentDir(iter, network->getGradient(), ascentdir); - - /* Update the design in negative ascent direction */ - stepsize = config->getStepsize(iter); - network->updateDesign( -1.0 * stepsize, ascentdir, MPI_COMM_WORLD); - - - /* --- Backtracking linesearch --- */ - - if (config->stepsize_type == BACKTRACKINGLS) - { - /* Compute wolfe condition */ - wolfe = vecdot_par(ndesign_local, network->getGradient(), ascentdir, MPI_COMM_WORLD); - - /* Start linesearch iterations */ - ls_stepsize = config->getStepsize(iter); - stepsize = ls_stepsize; - for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) - { - - primaltrainapp->getCore()->SetPrintLevel(0); - primaltrainapp->run(); - ls_objective = primaltrainapp->getObjective(); - primaltrainapp->getCore()->SetPrintLevel(config->braid_printlevel); - - test_obj = objective - ls_param * ls_stepsize * wolfe; - if (myid == MASTER_NODE) printf("ls_iter %d: %1.14e %1.14e\n", ls_iter, ls_objective, test_obj); - /* Test the wolfe condition */ - if (ls_objective <= test_obj) - { - /* Success, use this new design */ - break; - } - else - { - /* Test for line-search failure */ - if (ls_iter == config->ls_maxiter - 1) - { - if (myid == MASTER_NODE) printf("\n\n WARNING: LINESEARCH FAILED! \n\n"); - break; - } - - /* Go back part of the step */ - network->updateDesign((1.0 - config->ls_factor) * stepsize, ascentdir, MPI_COMM_WORLD); - - /* Decrease the stepsize */ - ls_stepsize = ls_stepsize * config->ls_factor; - stepsize = ls_stepsize; - } - } + /* Decrease the stepsize */ + ls_stepsize = ls_stepsize * config->ls_factor; + stepsize = ls_stepsize; } + } } + } - /* --- Run final validation and write prediction file --- */ - if (config->validationlevel > -1) - { - if (myid == MASTER_NODE) printf("\n --- Run final validation ---\n"); + /* --- Run final validation and write prediction file --- */ + if (config->validationlevel > -1) { + if (myid == MASTER_NODE) + printf("\n --- Run final validation ---\n"); - primalvalapp->getCore()->SetPrintLevel(0); - primalvalapp->run(); - loss_val = network->getLoss(); + primalvalapp->getCore()->SetPrintLevel(0); + primalvalapp->run(); + loss_val = network->getLoss(); - printf("Final validation accuracy: %2.2f%%\n", accur_val); - } + printf("Final validation accuracy: %2.2f%%\n", accur_val); + } - // write_vector("design.dat", design, ndesign); + // write_vector("design.dat", design, ndesign); #endif - - - -/** ================================================================================== +/** + * ================================================================================== * Adjoint dot test xbarTxdot = ybarTydot * where xbar = (dfdx)T ybar * ydot = (dfdx) xdot @@ -382,116 +383,113 @@ int main (int argc, char *argv[]) #endif -/** ======================================= - * Full finite differences - * ======================================= */ - - // MyReal* findiff = new MyReal[ndesign]; - // MyReal* relerr = new MyReal[ndesign]; - // MyReal errnorm = 0.0; - // MyReal obj0, obj1, design_store; - // MyReal EPS; - - // printf("\n--------------------------------\n"); - // printf(" FINITE DIFFERENCE TESTING\n\n"); - - // /* Compute baseline objective */ - // // read_vector("design.dat", design, ndesign); - // braid_SetObjectiveOnly(core_train, 0); - // braid_Drive(core_train); - // braid_GetObjective(core_train, &objective); - // obj0 = objective; - - // EPS = 1e-4; - // for (int i = 0; i < ndesign; i++) - // // for (int i = 0; i < 22; i++) - // // int i=21; - // { - // /* Restore design */ - // // read_vector("design.dat", design, ndesign); - - // /* Perturb design */ - // design_store = design[i]; - // design[i] += EPS; - - // /* Recompute objective */ - // _braid_CoreElt(core_train, warm_restart) = 0; - // braid_SetObjectiveOnly(core_train, 1); - // braid_SetPrintLevel(core_train, 0); - // braid_Drive(core_train); - // braid_GetObjective(core_train, &objective); - // obj1 = objective; - - // /* Findiff */ - // findiff[i] = (obj1 - obj0) / EPS; - // relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; - // errnorm += pow(relerr[i],2); - - // printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f",i, findiff[i], gradient[i], relerr[i] * 100.0); - - // /* Restore design */ - // design[i] = design_store; - // } - // errnorm = sqrt(errnorm); - // printf("\n FinDiff ErrNorm %1.14e\n", errnorm); - - // write_vector("findiff.dat", findiff, ndesign); - // write_vector("relerr.dat", relerr, ndesign); - - - /* ======================================= - * check network implementation - * ======================================= */ - // network->applyFWD(config->ntraining, train_examples, train_labels); - // MyReal accur = network->getAccuracy(); - // MyReal regul = network->evalRegularization(); - // objective = network->getLoss() + regul; - // printf("\n --- \n"); - // printf(" Network: obj %1.14e \n", objective); - // printf(" ---\n"); - - /* Print some statistics */ - StopTime = MPI_Wtime(); - UsedTime = StopTime-StartTime; - getrusage(RUSAGE_SELF,&r_usage); - myMB = (MyReal) r_usage.ru_maxrss / 1024.0; - MPI_Allreduce(&myMB, &globalMB, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - - // printf("%d; Memory Usage: %.2f MB\n",myid, myMB); - if (myid == MASTER_NODE) - { - printf("\n"); - printf(" Used Time: %.2f seconds\n",UsedTime); - printf(" Global Memory: %.2f MB\n", globalMB); - printf(" Processors used: %d\n", size); - printf("\n"); - } - - - /* Clean up XBraid */ - delete network; - - delete primaltrainapp; - delete adjointtrainapp; - delete primalvalapp; - - /* Delete optimization vars */ - delete hessian; - delete [] ascentdir; - - /* Delete training and validation examples */ - delete trainingdata; - delete validationdata; - - /* Close optim file */ - if (myid == MASTER_NODE) - { - fclose(optimfile); - printf("Optimfile: %s\n", optimfilename); - } - - delete config; - - MPI_Finalize(); - return 0; + /** ======================================= + * Full finite differences + * ======================================= */ + + // MyReal* findiff = new MyReal[ndesign]; + // MyReal* relerr = new MyReal[ndesign]; + // MyReal errnorm = 0.0; + // MyReal obj0, obj1, design_store; + // MyReal EPS; + + // printf("\n--------------------------------\n"); + // printf(" FINITE DIFFERENCE TESTING\n\n"); + + // /* Compute baseline objective */ + // // read_vector("design.dat", design, ndesign); + // braid_SetObjectiveOnly(core_train, 0); + // braid_Drive(core_train); + // braid_GetObjective(core_train, &objective); + // obj0 = objective; + + // EPS = 1e-4; + // for (int i = 0; i < ndesign; i++) + // // for (int i = 0; i < 22; i++) + // // int i=21; + // { + // /* Restore design */ + // // read_vector("design.dat", design, ndesign); + + // /* Perturb design */ + // design_store = design[i]; + // design[i] += EPS; + + // /* Recompute objective */ + // _braid_CoreElt(core_train, warm_restart) = 0; + // braid_SetObjectiveOnly(core_train, 1); + // braid_SetPrintLevel(core_train, 0); + // braid_Drive(core_train); + // braid_GetObjective(core_train, &objective); + // obj1 = objective; + + // /* Findiff */ + // findiff[i] = (obj1 - obj0) / EPS; + // relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; + // errnorm += pow(relerr[i],2); + + // printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f",i, findiff[i], + // gradient[i], relerr[i] * 100.0); + + // /* Restore design */ + // design[i] = design_store; + // } + // errnorm = sqrt(errnorm); + // printf("\n FinDiff ErrNorm %1.14e\n", errnorm); + + // write_vector("findiff.dat", findiff, ndesign); + // write_vector("relerr.dat", relerr, ndesign); + + /* ======================================= + * check network implementation + * ======================================= */ + // network->applyFWD(config->ntraining, train_examples, train_labels); + // MyReal accur = network->getAccuracy(); + // MyReal regul = network->evalRegularization(); + // objective = network->getLoss() + regul; + // printf("\n --- \n"); + // printf(" Network: obj %1.14e \n", objective); + // printf(" ---\n"); + + /* Print some statistics */ + StopTime = MPI_Wtime(); + UsedTime = StopTime - StartTime; + getrusage(RUSAGE_SELF, &r_usage); + myMB = (MyReal)r_usage.ru_maxrss / 1024.0; + MPI_Allreduce(&myMB, &globalMB, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); + + // printf("%d; Memory Usage: %.2f MB\n",myid, myMB); + if (myid == MASTER_NODE) { + printf("\n"); + printf(" Used Time: %.2f seconds\n", UsedTime); + printf(" Global Memory: %.2f MB\n", globalMB); + printf(" Processors used: %d\n", size); + printf("\n"); + } + + /* Clean up XBraid */ + delete network; + + delete primaltrainapp; + delete adjointtrainapp; + delete primalvalapp; + + /* Delete optimization vars */ + delete hessian; + delete[] ascentdir; + + /* Delete training and validation examples */ + delete trainingdata; + delete validationdata; + + /* Close optim file */ + if (myid == MASTER_NODE) { + fclose(optimfile); + printf("Optimfile: %s\n", optimfilename); + } + + delete config; + + MPI_Finalize(); + return 0; } diff --git a/src/network.cpp b/src/network.cpp index 4c9ccb1..9b85664 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -1,152 +1,141 @@ #include "network.hpp" -#include +#include -Network::Network() -{ - nlayers_global = 0; - nlayers_local = 0; - nchannels = 0; - dt = 0.0; - loss = 0.0; - accuracy = 0.0; +Network::Network() { + nlayers_global = 0; + nlayers_local = 0; + nchannels = 0; + dt = 0.0; + loss = 0.0; + accuracy = 0.0; - startlayerID = 0; - endlayerID = 0; + startlayerID = 0; + endlayerID = 0; - ndesign_local = 0; - ndesign_global = 0; - ndesign_layermax = 0; + ndesign_local = 0; + ndesign_global = 0; + ndesign_layermax = 0; - design = NULL; - gradient = NULL; + design = NULL; + gradient = NULL; - layers = NULL; - openlayer = NULL; - layer_left = NULL; - layer_right = NULL; + layers = NULL; + openlayer = NULL; + layer_left = NULL; + layer_right = NULL; - comm = MPI_COMM_WORLD; + comm = MPI_COMM_WORLD; } -void Network::createNetworkBlock(int StartLayerID, - int EndLayerID, - Config* config, - MPI_Comm Comm) -{ - /* Initilizize */ - startlayerID = StartLayerID; - endlayerID = EndLayerID; - nlayers_local = endlayerID - startlayerID + 1; - nlayers_global = config->nlayers; - nchannels = config->nchannels; - dt = (config->T) / (MyReal)(config->nlayers-2); // nlayers-2 = nhiddenlayers - comm = Comm; - - /* --- Create the layers --- */ - ndesign_local = 0; - - if (startlayerID == 0) // Opening layer - { - /* Create the opening layer */ - int index = -1; - openlayer = createLayer(index, config); - ndesign_local += openlayer->getnDesign(); - // printf("Create opening layer %d, ndesign_local %d \n", index, openlayer->getnDesign()); - } - - layers = new Layer*[nlayers_local]; // Intermediate and classification layer - for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) - { - /* Create a layer at time step ilayer. Local storage at ilayer - startlayerID */ - int storeID = getLocalID(ilayer); - layers[storeID] = createLayer(ilayer, config); - ndesign_local += layers[storeID]->getnDesign(); - // printf("creating hidden/class layer %d/%d, ndesign_local%d\n", ilayer, nlayers_local, layers[storeID]->getnDesign()); - } - - /* Create left neighbouring layer */ - int leftID = startlayerID - 1; - layer_left = createLayer(leftID, config); - - /* Create right neighbrouing layer */ - int rightID = endlayerID + 1; - layer_right = createLayer(rightID, config); - - /* Sum up global number of design vars */ - MPI_Allreduce(&ndesign_local, &ndesign_global, 1, MPI_INT, MPI_SUM, comm); - - /* Store maximum number of designs over all layers layermax */ - ndesign_layermax = computeLayermax(); - - /* Allocate memory for network design and gradient variables */ - design = new MyReal[ndesign_local]; - gradient = new MyReal[ndesign_local]; - - /* Set the memory locations for all layers */ - int istart = 0; - if (openlayer != NULL) // Openlayer on first processor - { - openlayer->setMemory(&(design[istart]), &(gradient[istart])); - istart += openlayer->getnDesign(); - } - for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) // intermediate and hidden layers - { - layers[getLocalID(ilayer)]->setMemory(&(design[istart]), &(gradient[istart])); - istart += layers[getLocalID(ilayer)]->getnDesign(); - } - - /* left anr right neighbouring layer design, if exists */ - if (layer_left != NULL) - { - MyReal *left_design = new MyReal[layer_left->getnDesign()]; - MyReal *left_gradient = new MyReal[layer_left->getnDesign()]; - layer_left->setMemory(left_design, left_gradient); - } - /* Create and initialize right neighbouring layer design, if exists */ - if (layer_right != NULL) - { - MyReal *right_design = new MyReal[layer_right->getnDesign()]; - MyReal *right_gradient = new MyReal[layer_right->getnDesign()]; - layer_right->setMemory(right_design, right_gradient); - } - -} - - - - - - -Network::~Network() -{ - /* Delete openlayer */ - if (openlayer != NULL) delete openlayer; - - /* Delete intermediate and classification layers */ - for (int ilayer = 0; ilayer < nlayers_local; ilayer++) - { - delete layers[ilayer]; - } - delete [] layers; - - /* Delete design and gradient */ - delete [] design; - delete [] gradient; - - /* Delete neighbouring layer information */ - if (layer_left != NULL) - { - delete [] layer_left->getWeights(); - delete [] layer_left->getWeightsBar(); - delete layer_left; - } +void Network::createNetworkBlock(int StartLayerID, int EndLayerID, + Config *config, MPI_Comm Comm) { + /* Initilizize */ + startlayerID = StartLayerID; + endlayerID = EndLayerID; + nlayers_local = endlayerID - startlayerID + 1; + nlayers_global = config->nlayers; + nchannels = config->nchannels; + dt = (config->T) / (MyReal)(config->nlayers - 2); // nlayers-2 = nhiddenlayers + comm = Comm; + + /* --- Create the layers --- */ + ndesign_local = 0; + + if (startlayerID == 0) // Opening layer + { + /* Create the opening layer */ + int index = -1; + openlayer = createLayer(index, config); + ndesign_local += openlayer->getnDesign(); + // printf("Create opening layer %d, ndesign_local %d \n", index, + // openlayer->getnDesign()); + } + + layers = new Layer *[nlayers_local]; // Intermediate and classification layer + for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { + /* Create a layer at time step ilayer. Local storage at ilayer - + * startlayerID */ + int storeID = getLocalID(ilayer); + layers[storeID] = createLayer(ilayer, config); + ndesign_local += layers[storeID]->getnDesign(); + // printf("creating hidden/class layer %d/%d, ndesign_local%d\n", ilayer, + // nlayers_local, layers[storeID]->getnDesign()); + } + + /* Create left neighbouring layer */ + int leftID = startlayerID - 1; + layer_left = createLayer(leftID, config); + + /* Create right neighbrouing layer */ + int rightID = endlayerID + 1; + layer_right = createLayer(rightID, config); + + /* Sum up global number of design vars */ + MPI_Allreduce(&ndesign_local, &ndesign_global, 1, MPI_INT, MPI_SUM, comm); + + /* Store maximum number of designs over all layers layermax */ + ndesign_layermax = computeLayermax(); + + /* Allocate memory for network design and gradient variables */ + design = new MyReal[ndesign_local]; + gradient = new MyReal[ndesign_local]; + + /* Set the memory locations for all layers */ + int istart = 0; + if (openlayer != NULL) // Openlayer on first processor + { + openlayer->setMemory(&(design[istart]), &(gradient[istart])); + istart += openlayer->getnDesign(); + } + for (int ilayer = startlayerID; ilayer <= endlayerID; + ilayer++) // intermediate and hidden layers + { + layers[getLocalID(ilayer)]->setMemory(&(design[istart]), + &(gradient[istart])); + istart += layers[getLocalID(ilayer)]->getnDesign(); + } + + /* left anr right neighbouring layer design, if exists */ + if (layer_left != NULL) { + MyReal *left_design = new MyReal[layer_left->getnDesign()]; + MyReal *left_gradient = new MyReal[layer_left->getnDesign()]; + layer_left->setMemory(left_design, left_gradient); + } + /* Create and initialize right neighbouring layer design, if exists */ + if (layer_right != NULL) { + MyReal *right_design = new MyReal[layer_right->getnDesign()]; + MyReal *right_gradient = new MyReal[layer_right->getnDesign()]; + layer_right->setMemory(right_design, right_gradient); + } +} - if (layer_right != NULL) - { - delete [] layer_right->getWeights(); - delete [] layer_right->getWeightsBar(); - delete layer_right; - } +Network::~Network() { + /* Delete openlayer */ + if (openlayer != NULL) + delete openlayer; + + /* Delete intermediate and classification layers */ + for (int ilayer = 0; ilayer < nlayers_local; ilayer++) { + delete layers[ilayer]; + } + delete[] layers; + + /* Delete design and gradient */ + delete[] design; + delete[] gradient; + + /* Delete neighbouring layer information */ + if (layer_left != NULL) { + delete[] layer_left->getWeights(); + delete[] layer_left->getWeightsBar(); + delete layer_left; + } + + if (layer_right != NULL) { + delete[] layer_right->getWeights(); + delete[] layer_right->getWeightsBar(); + delete layer_right; + } } int Network::getnChannels() { return nchannels; } @@ -155,10 +144,9 @@ int Network::getnLayersGlobal() { return nlayers_global; } MyReal Network::getDT() { return dt; } -int Network::getLocalID(int ilayer) -{ - int idx = ilayer - startlayerID; - return idx; +int Network::getLocalID(int ilayer) { + int idx = ilayer - startlayerID; + return idx; } MyReal Network::getLoss() { return loss; } @@ -169,399 +157,373 @@ int Network::getnDesignLocal() { return ndesign_local; } int Network::getnDesignGlobal() { return ndesign_global; } -MyReal* Network::getDesign() { return design; } - -MyReal* Network::getGradient() { return gradient; } +MyReal *Network::getDesign() { return design; } + +MyReal *Network::getGradient() { return gradient; } int Network::getStartLayerID() { return startlayerID; } -int Network::getEndLayerID() { return endlayerID; } +int Network::getEndLayerID() { return endlayerID; } MPI_Comm Network::getComm() { return comm; } +Layer *Network::createLayer(int index, Config *config) { + Layer *layer = 0; + if (index == -1) // Opening layer + { + switch (config->network_type) { + case DENSE: + if (config->weights_open_init == 0.0) { + layer = new OpenExpandZero(config->nfeatures, nchannels); + } else { + layer = new OpenDenseLayer(config->nfeatures, nchannels, + config->activation, config->gamma_tik); + } + break; + case CONVOLUTIONAL: + /**< (Weight_open_init == 0.0) not needed for convolutional layers*/ + if (config->openlayer_type == 0) { + layer = new OpenConvLayer(config->nfeatures, nchannels); + } else if (config->openlayer_type == 1) { + layer = new OpenConvLayerMNIST(config->nfeatures, nchannels); + } + break; + } + } else if (0 <= index && index < nlayers_global - 2) // Intermediate layer + { + switch (config->network_type) { + case DENSE: + layer = + new DenseLayer(index, nchannels, nchannels, dt, config->activation, + config->gamma_tik, config->gamma_ddt); + break; + case CONVOLUTIONAL: + // TODO: Fix + int convolution_size = 3; + layer = + new ConvLayer(index, nchannels, nchannels, convolution_size, + nchannels / config->nfeatures, dt, config->activation, + config->gamma_tik, config->gamma_ddt); + break; + } + } else if (index == nlayers_global - 2) // Classification layer + { + layer = new ClassificationLayer(index, nchannels, config->nclasses, + config->gamma_class); + } else { + layer = NULL; + } + + return layer; +} -Layer* Network::createLayer(int index, - Config *config) -{ - Layer* layer = 0; - if (index == -1) // Opening layer - { - switch ( config->network_type ) -{ - case DENSE: - if (config->weights_open_init == 0.0) - { - layer = new OpenExpandZero(config->nfeatures, nchannels); - } - else - { - layer = new OpenDenseLayer(config->nfeatures, nchannels, config->activation, config->gamma_tik); - } - break; - case CONVOLUTIONAL: - /**< (Weight_open_init == 0.0) not needed for convolutional layers*/ - if (config->openlayer_type == 0) - { - layer = new OpenConvLayer(config->nfeatures, nchannels); - } - else if (config->openlayer_type == 1) - { - layer = new OpenConvLayerMNIST(config->nfeatures, nchannels); - } - break; - } - } - else if (0 <= index && index < nlayers_global-2) // Intermediate layer - { - switch ( config->network_type ) - { - case DENSE: - layer = new DenseLayer(index, nchannels, nchannels, dt, config->activation, config->gamma_tik, config->gamma_ddt); - break; - case CONVOLUTIONAL: - // TODO: Fix - int convolution_size = 3; - layer = new ConvLayer(index, nchannels, nchannels, convolution_size, nchannels/config->nfeatures, dt, config->activation, config->gamma_tik, config->gamma_ddt); - break; - } - } - else if (index == nlayers_global-2) // Classification layer - { - layer = new ClassificationLayer(index, nchannels, config->nclasses, config->gamma_class); - } - else - { - layer = NULL; - } - - return layer; -} - -Layer* Network::getLayer(int layerindex) -{ - Layer* layer; - - if (layerindex == -1) // opening layer - { - layer = openlayer; - } - else if (layerindex == startlayerID - 1) - { - layer = layer_left; - } - else if (startlayerID <= layerindex && layerindex <= endlayerID) - { - layer = layers[getLocalID(layerindex)]; - } - else if (layerindex == endlayerID + 1) - { - layer = layer_right; - } - else - { - layer = NULL; - } - - return layer; +Layer *Network::getLayer(int layerindex) { + Layer *layer; + + if (layerindex == -1) // opening layer + { + layer = openlayer; + } else if (layerindex == startlayerID - 1) { + layer = layer_left; + } else if (startlayerID <= layerindex && layerindex <= endlayerID) { + layer = layers[getLocalID(layerindex)]; + } else if (layerindex == endlayerID + 1) { + layer = layer_right; + } else { + layer = NULL; + } + + return layer; } int Network::getnDesignLayermax() { return ndesign_layermax; } -int Network::computeLayermax() -{ - int ndesignlayer; - int max = 0; +int Network::computeLayermax() { + int ndesignlayer; + int max = 0; - /* Loop over all local layers */ - for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) + /* Loop over all local layers */ + for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { + if (ilayer < nlayers_global - 2) // excludes classification layer { - if (ilayer < nlayers_global-2) // excludes classification layer - { - /* Update maximum */ - ndesignlayer = layers[getLocalID(ilayer)]->getnDesign(); - if ( ndesignlayer > max) max = ndesignlayer; - } + /* Update maximum */ + ndesignlayer = layers[getLocalID(ilayer)]->getnDesign(); + if (ndesignlayer > max) + max = ndesignlayer; } + } - /* Get maximum over all local layer blocks */ - int mymax = max; - MPI_Allreduce(&mymax, &max, 1, MPI_INT, MPI_MAX, comm); + /* Get maximum over all local layer blocks */ + int mymax = max; + MPI_Allreduce(&mymax, &max, 1, MPI_INT, MPI_MAX, comm); - return max; + return max; } -void Network::setInitialDesign(Config *config) -{ - MyReal factor; - MyReal* design_init; - char filename[255]; - int myid; - MPI_Comm_rank(comm, &myid); - - /* Initialize design with random numbers (do on one processor and scatter for scaling test) */ - if (myid == 0) - { - srand(1.0); - design_init = new MyReal[ndesign_global]; - for (int i = 0; i < ndesign_global; i++) - { - design_init[i] = (MyReal) rand() / ((MyReal) RAND_MAX); - } - } - /* Scatter initial design to all processors */ - MPI_ScatterVector(design_init, design, ndesign_local, 0, comm); - - /* Scale the initial design by a factor and read from file, if set */ - - /* Opening layer on first processor */ - if (startlayerID == 0) - { - /* Scale design by the factor */ - factor = config->weights_open_init; - openlayer->scaleDesign(factor); - - /* if set, overwrite opening design from file */ - if (strcmp(config->weightsopenfile, "NONE") != 0) - { - sprintf(filename, "%s/%s", config->datafolder, config->weightsopenfile); - read_vector(filename, openlayer->getWeights(), openlayer->getnDesign()); - } - } +void Network::setInitialDesign(Config *config) { + MyReal factor; + MyReal *design_init; + char filename[255]; + int myid; + MPI_Comm_rank(comm, &myid); - /* Intermediate (hidden) and classification layers */ - for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) - { - if (ilayer < nlayers_global-1) // Intermediate layer - { - factor = config->weights_init; - } - else // Classification layer - { - factor = config->weights_class_init; - } - - /* Set memory location and scale the current design by the factor */ - int storeID = getLocalID(ilayer); - layers[storeID]->scaleDesign(factor); - - /* if set, overwrite classification design from file */ - if (ilayer == nlayers_global-1) - { - if (strcmp(config->weightsclassificationfile, "NONE") != 0) - { - sprintf(filename, "%s/%s", config->datafolder, config->weightsclassificationfile); - read_vector(filename, layers[storeID]->getWeights(), layers[storeID]->getnDesign()); - } - } + /* Initialize design with random numbers (do on one processor and scatter for + * scaling test) */ + if (myid == 0) { + srand(1.0); + design_init = new MyReal[ndesign_global]; + for (int i = 0; i < ndesign_global; i++) { + design_init[i] = (MyReal)rand() / ((MyReal)RAND_MAX); } + } + /* Scatter initial design to all processors */ + MPI_ScatterVector(design_init, design, ndesign_local, 0, comm); - /* Communicate the neighbours across processors */ - MPI_CommunicateNeighbours(comm); - - if (myid == 0) delete [] design_init; - -} - + /* Scale the initial design by a factor and read from file, if set */ -void Network::MPI_CommunicateNeighbours(MPI_Comm comm) -{ - int myid, comm_size; - MPI_Comm_rank(comm, &myid); - MPI_Comm_size(comm, &comm_size); - MPI_Request sendlastreq, recvlastreq; - MPI_Request sendfirstreq, recvfirstreq; - MPI_Status status; + /* Opening layer on first processor */ + if (startlayerID == 0) { + /* Scale design by the factor */ + factor = config->weights_open_init; + openlayer->scaleDesign(factor); - /* Allocate buffers */ - int size_left = -1; - int size_right = -1; - - MyReal* sendlast = 0; - MyReal* recvlast = 0; - MyReal* sendfirst = 0; - MyReal* recvfirst = 0; - - /* --- All but the first process receive the last layer from left neighbour --- */ - if (myid > 0) - { - /* Receive from left neighbour */ - int source = myid - 1; - - size_left = layer_left->getnDesign(); - recvlast = new MyReal[size_left]; - - MPI_Irecv(recvlast, size_left, MPI_MyReal, source, 0, comm, &recvlastreq); - } - - /* --- All but the last process sent their last layer to right neighbour --- */ - if (myid < comm_size-1) - { - size_left = layers[getLocalID(endlayerID)]->getnDesign(); - sendlast = new MyReal[size_left]; - - /* Pack the last layer into a buffer */ - layers[getLocalID(endlayerID)]->packDesign(sendlast, size_left); - - /* Send to right neighbour */ - int receiver = myid + 1; - MPI_Isend(sendlast, size_left, MPI_MyReal, receiver, 0, comm, &sendlastreq); + /* if set, overwrite opening design from file */ + if (strcmp(config->weightsopenfile, "NONE") != 0) { + sprintf(filename, "%s/%s", config->datafolder, config->weightsopenfile); + read_vector(filename, openlayer->getWeights(), openlayer->getnDesign()); } + } - /* --- All but the last processor recv the first layer from the right neighbour --- */ - if (myid < comm_size - 1) + /* Intermediate (hidden) and classification layers */ + for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { + if (ilayer < nlayers_global - 1) // Intermediate layer { - /* Receive from right neighbour */ - int source = myid + 1; - - size_right = layer_right->getnDesign(); - recvfirst = new MyReal[size_right]; - - MPI_Irecv(recvfirst, size_right, MPI_MyReal, source, 1, comm, &recvfirstreq); - } - - - /* --- All but the first processor send their first layer to the left neighbour --- */ - if (myid > 0) + factor = config->weights_init; + } else // Classification layer { - size_right = layers[getLocalID(startlayerID)]->getnDesign(); - sendfirst = new MyReal[size_right]; - - /* Pack the first layer into a buffer */ - layers[getLocalID(startlayerID)]->packDesign(sendfirst, size_right); - - /* Send to left neighbour */ - int receiver = myid - 1; - MPI_Isend(sendfirst, size_right, MPI_MyReal, receiver, 1, comm, &sendfirstreq); + factor = config->weights_class_init; } + /* Set memory location and scale the current design by the factor */ + int storeID = getLocalID(ilayer); + layers[storeID]->scaleDesign(factor); - /* Wait to finish up communication */ - if (myid > 0) MPI_Wait(&recvlastreq, &status); - if (myid < comm_size - 1) MPI_Wait(&sendlastreq, &status); - if (myid < comm_size - 1) MPI_Wait(&recvfirstreq, &status); - if (myid > 0) MPI_Wait(&sendfirstreq, &status); - - /* Unpack and store the left received layer */ - if (myid > 0) - { - layer_left->unpackDesign(recvlast); + /* if set, overwrite classification design from file */ + if (ilayer == nlayers_global - 1) { + if (strcmp(config->weightsclassificationfile, "NONE") != 0) { + sprintf(filename, "%s/%s", config->datafolder, + config->weightsclassificationfile); + read_vector(filename, layers[storeID]->getWeights(), + layers[storeID]->getnDesign()); + } } + } - /* Unpack and store the right received layer */ - if (myid < comm_size - 1) - { - layer_right->unpackDesign(recvfirst); - } + /* Communicate the neighbours across processors */ + MPI_CommunicateNeighbours(comm); - /* Free the buffer */ - if(sendlast!=0) delete [] sendlast; - if(recvlast!=0) delete [] recvlast; - if(sendfirst!=0) delete [] sendfirst; - if(recvfirst!=0) delete [] recvfirst; + if (myid == 0) + delete[] design_init; } +void Network::MPI_CommunicateNeighbours(MPI_Comm comm) { + int myid, comm_size; + MPI_Comm_rank(comm, &myid); + MPI_Comm_size(comm, &comm_size); + MPI_Request sendlastreq, recvlastreq; + MPI_Request sendfirstreq, recvfirstreq; + MPI_Status status; + + /* Allocate buffers */ + int size_left = -1; + int size_right = -1; + + MyReal *sendlast = 0; + MyReal *recvlast = 0; + MyReal *sendfirst = 0; + MyReal *recvfirst = 0; + + /* --- All but the first process receive the last layer from left neighbour + * --- */ + if (myid > 0) { + /* Receive from left neighbour */ + int source = myid - 1; + + size_left = layer_left->getnDesign(); + recvlast = new MyReal[size_left]; + + MPI_Irecv(recvlast, size_left, MPI_MyReal, source, 0, comm, &recvlastreq); + } + + /* --- All but the last process sent their last layer to right neighbour --- + */ + if (myid < comm_size - 1) { + size_left = layers[getLocalID(endlayerID)]->getnDesign(); + sendlast = new MyReal[size_left]; + + /* Pack the last layer into a buffer */ + layers[getLocalID(endlayerID)]->packDesign(sendlast, size_left); + + /* Send to right neighbour */ + int receiver = myid + 1; + MPI_Isend(sendlast, size_left, MPI_MyReal, receiver, 0, comm, &sendlastreq); + } + + /* --- All but the last processor recv the first layer from the right + * neighbour --- */ + if (myid < comm_size - 1) { + /* Receive from right neighbour */ + int source = myid + 1; + + size_right = layer_right->getnDesign(); + recvfirst = new MyReal[size_right]; + + MPI_Irecv(recvfirst, size_right, MPI_MyReal, source, 1, comm, + &recvfirstreq); + } + + /* --- All but the first processor send their first layer to the left + * neighbour --- */ + if (myid > 0) { + size_right = layers[getLocalID(startlayerID)]->getnDesign(); + sendfirst = new MyReal[size_right]; + + /* Pack the first layer into a buffer */ + layers[getLocalID(startlayerID)]->packDesign(sendfirst, size_right); + + /* Send to left neighbour */ + int receiver = myid - 1; + MPI_Isend(sendfirst, size_right, MPI_MyReal, receiver, 1, comm, + &sendfirstreq); + } + + /* Wait to finish up communication */ + if (myid > 0) + MPI_Wait(&recvlastreq, &status); + if (myid < comm_size - 1) + MPI_Wait(&sendlastreq, &status); + if (myid < comm_size - 1) + MPI_Wait(&recvfirstreq, &status); + if (myid > 0) + MPI_Wait(&sendfirstreq, &status); + + /* Unpack and store the left received layer */ + if (myid > 0) { + layer_left->unpackDesign(recvlast); + } + + /* Unpack and store the right received layer */ + if (myid < comm_size - 1) { + layer_right->unpackDesign(recvfirst); + } + + /* Free the buffer */ + if (sendlast != 0) + delete[] sendlast; + if (recvlast != 0) + delete[] recvlast; + if (sendfirst != 0) + delete[] sendfirst; + if (recvfirst != 0) + delete[] recvfirst; +} -void Network::evalClassification(DataSet* data, - MyReal** state, - int output) -{ - MyReal *tmpstate = new MyReal[nchannels]; - - int class_id; - int success, success_local; - FILE* classfile; - ClassificationLayer* classificationlayer; - - - /* Get classification layer */ - classificationlayer = dynamic_cast(getLayer(nlayers_global - 2)); - if (classificationlayer == NULL) - { - printf("\n ERROR: Network can't access classification layer!\n\n"); - exit(1); - } - - /* open file for printing predicted file */ - if (output) classfile = fopen("classprediction.dat", "w"); - - loss = 0.0; - accuracy = 0.0; - success = 0; - for (int iex = 0; iex < data->getnBatch(); iex++) - { - /* Copy values so that they are not overwrittn (they are needed for adjoint)*/ - for (int ic = 0; ic < nchannels; ic++) - { - tmpstate[ic] = state[iex][ic]; - } - /* Apply classification on tmpstate */ - classificationlayer->setLabel(data->getLabel(iex)); - classificationlayer->applyFWD(tmpstate); - /* Evaluate Loss */ - loss += classificationlayer->crossEntropy(tmpstate); - success_local = classificationlayer->prediction(tmpstate, &class_id); - success += success_local; - if (output) fprintf(classfile, "%d %d\n", class_id, success_local ); - } - loss = 1. / data->getnBatch() * loss; - accuracy = 100.0 * ( (MyReal) success ) / data->getnBatch(); - // printf("Classification %d: %1.14e using layer %1.14e state %1.14e tmpstate[0] %1.14e\n", getIndex(), loss, weights[0], state[1][1], tmpstate[0]); - - if (output) fclose(classfile); - if (output) printf("Prediction file written: classprediction.dat\n"); - - delete [] tmpstate; -} - - -void Network::evalClassification_diff(DataSet* data, - MyReal** primalstate, - MyReal** adjointstate, - int compute_gradient) -{ - MyReal *tmpstate = new MyReal[nchannels]; - ClassificationLayer* classificationlayer; - - /* Get classification layer */ - classificationlayer = dynamic_cast(getLayer(nlayers_global - 2)); - if (classificationlayer == NULL) - { - printf("\n ERROR: Network can't access classification layer!\n\n"); - exit(1); - } - - int nbatch = data->getnBatch(); - MyReal loss_bar = 1./nbatch; - - for (int iex = 0; iex < nbatch; iex++) - { - /* Recompute the Classification */ - for (int ic = 0; ic < nchannels; ic++) - { - tmpstate[ic] = primalstate[iex][ic]; - } - classificationlayer->setLabel(data->getLabel(iex)); - classificationlayer->applyFWD(tmpstate); - - /* Derivative of Loss and classification. */ - classificationlayer->crossEntropy_diff(tmpstate, adjointstate[iex], loss_bar); - classificationlayer->applyBWD(primalstate[iex], adjointstate[iex], compute_gradient); - } - // printf("Classification_diff %d using layer %1.14e state %1.14e tmpstate %1.14e biasbar[dimOut-1] %1.14e\n", getIndex(), weights[0], primalstate[1][1], tmpstate[0], bias_bar[dim_Out-1]); - - delete [] tmpstate; +void Network::evalClassification(DataSet *data, MyReal **state, int output) { + MyReal *tmpstate = new MyReal[nchannels]; + + int class_id; + int success, success_local; + FILE *classfile; + ClassificationLayer *classificationlayer; + + /* Get classification layer */ + classificationlayer = + dynamic_cast(getLayer(nlayers_global - 2)); + if (classificationlayer == NULL) { + printf("\n ERROR: Network can't access classification layer!\n\n"); + exit(1); + } + + /* open file for printing predicted file */ + if (output) + classfile = fopen("classprediction.dat", "w"); + + loss = 0.0; + accuracy = 0.0; + success = 0; + for (int iex = 0; iex < data->getnBatch(); iex++) { + /* Copy values so that they are not overwrittn (they are needed for + * adjoint)*/ + for (int ic = 0; ic < nchannels; ic++) { + tmpstate[ic] = state[iex][ic]; + } + /* Apply classification on tmpstate */ + classificationlayer->setLabel(data->getLabel(iex)); + classificationlayer->applyFWD(tmpstate); + /* Evaluate Loss */ + loss += classificationlayer->crossEntropy(tmpstate); + success_local = classificationlayer->prediction(tmpstate, &class_id); + success += success_local; + if (output) + fprintf(classfile, "%d %d\n", class_id, success_local); + } + loss = 1. / data->getnBatch() * loss; + accuracy = 100.0 * ((MyReal)success) / data->getnBatch(); + // printf("Classification %d: %1.14e using layer %1.14e state %1.14e + // tmpstate[0] %1.14e\n", getIndex(), loss, weights[0], state[1][1], + // tmpstate[0]); + + if (output) + fclose(classfile); + if (output) + printf("Prediction file written: classprediction.dat\n"); + + delete[] tmpstate; +} +void Network::evalClassification_diff(DataSet *data, MyReal **primalstate, + MyReal **adjointstate, + int compute_gradient) { + MyReal *tmpstate = new MyReal[nchannels]; + ClassificationLayer *classificationlayer; + + /* Get classification layer */ + classificationlayer = + dynamic_cast(getLayer(nlayers_global - 2)); + if (classificationlayer == NULL) { + printf("\n ERROR: Network can't access classification layer!\n\n"); + exit(1); + } + + int nbatch = data->getnBatch(); + MyReal loss_bar = 1. / nbatch; + + for (int iex = 0; iex < nbatch; iex++) { + /* Recompute the Classification */ + for (int ic = 0; ic < nchannels; ic++) { + tmpstate[ic] = primalstate[iex][ic]; + } + classificationlayer->setLabel(data->getLabel(iex)); + classificationlayer->applyFWD(tmpstate); + + /* Derivative of Loss and classification. */ + classificationlayer->crossEntropy_diff(tmpstate, adjointstate[iex], + loss_bar); + classificationlayer->applyBWD(primalstate[iex], adjointstate[iex], + compute_gradient); + } + // printf("Classification_diff %d using layer %1.14e state %1.14e tmpstate + // %1.14e biasbar[dimOut-1] %1.14e\n", getIndex(), weights[0], + // primalstate[1][1], tmpstate[0], bias_bar[dim_Out-1]); + + delete[] tmpstate; } -void Network::updateDesign(MyReal stepsize, - MyReal *direction, - MPI_Comm comm) -{ - /* Update design locally on this network-block */ - for (int id = 0; id < ndesign_local; id++) - { - design[id] += stepsize * direction[id]; - } +void Network::updateDesign(MyReal stepsize, MyReal *direction, MPI_Comm comm) { + /* Update design locally on this network-block */ + for (int id = 0; id < ndesign_local; id++) { + design[id] += stepsize * direction[id]; + } - /* Communicate design across neighbouring processors (ghostlayers) */ - MPI_CommunicateNeighbours(comm); -} \ No newline at end of file + /* Communicate design across neighbouring processors (ghostlayers) */ + MPI_CommunicateNeighbours(comm); +} \ No newline at end of file diff --git a/src/util.cpp b/src/util.cpp index 5a58260..f0f2f0d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,148 +1,120 @@ #include "util.hpp" -void read_matrix(char *filename, - MyReal **var, - int dimx, - int dimy) -{ - FILE *file; - MyReal tmp; - - /* Open file */ - file = fopen(filename, "r"); - if (file == NULL) - { - printf("Can't open %s \n", filename); - exit(1); - } - - /* Read data */ - printf("Reading file %s\n", filename); - for (int ix = 0; ix < dimx; ix++) - { - for (int iy = 0; iy < dimy; iy++) - { - fscanf(file, "%lf", &tmp); - var[ix][iy] = tmp; - } - } - - fclose(file); +void read_matrix(char *filename, MyReal **var, int dimx, int dimy) { + FILE *file; + MyReal tmp; + + /* Open file */ + file = fopen(filename, "r"); + if (file == NULL) { + printf("Can't open %s \n", filename); + exit(1); + } + + /* Read data */ + printf("Reading file %s\n", filename); + for (int ix = 0; ix < dimx; ix++) { + for (int iy = 0; iy < dimy; iy++) { + fscanf(file, "%lf", &tmp); + var[ix][iy] = tmp; + } + } + + fclose(file); } -void read_vector(char *filename, - MyReal *var, - int dimx) -{ - FILE *file; - MyReal tmp; - - /* Open file */ - file = fopen(filename, "r"); - if (file == NULL) - { - printf("Can't open %s \n", filename); - exit(1); - } - - /* Read data */ - printf("Reading file %s\n", filename); - for (int ix = 0; ix < dimx; ix++) - { - fscanf(file, "%lf", &tmp); - var[ix] = tmp; - } - - fclose(file); +void read_vector(char *filename, MyReal *var, int dimx) { + FILE *file; + MyReal tmp; + + /* Open file */ + file = fopen(filename, "r"); + if (file == NULL) { + printf("Can't open %s \n", filename); + exit(1); + } + + /* Read data */ + printf("Reading file %s\n", filename); + for (int ix = 0; ix < dimx; ix++) { + fscanf(file, "%lf", &tmp); + var[ix] = tmp; + } + + fclose(file); } +void write_vector(char *filename, MyReal *var, int dimN) { + FILE *file; + int i; + + /* open file */ + file = fopen(filename, "w"); + if (file == NULL) { + printf("Can't open %s \n", filename); + exit(1); + } + + /* Write data */ + printf("Writing file %s\n", filename); + for (i = 0; i < dimN; i++) { + fprintf(file, "%1.14e\n", var[i]); + } + + /* close file */ + fclose(file); +} -void write_vector(char *filename, - MyReal * var, - int dimN) -{ - FILE *file; - int i; - - /* open file */ - file = fopen(filename, "w"); - if (file == NULL) - { - printf("Can't open %s \n", filename); - exit(1); - } - - /* Write data */ - printf("Writing file %s\n", filename); - for ( i = 0; i < dimN; i++) - { - fprintf(file, "%1.14e\n", var[i]); - } - - /* close file */ - fclose(file); - -} - -void MPI_GatherVector(MyReal* sendbuffer, - int localsendcount, - MyReal* recvbuffer, - int rootprocessID, - MPI_Comm comm) -{ - int comm_size; - MPI_Comm_size(comm, &comm_size); - - int* recvcount = new int[comm_size]; - int* displs = new int[comm_size]; - - /* Gather the local send counts and store in recvcount vector on root */ - MPI_Gather(&localsendcount, 1, MPI_INT, recvcount , 1, MPI_INT, rootprocessID, comm); - - /* Compute displacement vector */ - displs[0] = 0; - for (int i=1; i Date: Tue, 9 Jul 2019 10:38:23 +0200 Subject: [PATCH 04/38] Add SOLIDs to Readme --- Readme.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index f16eead..91ab575 100644 --- a/Readme.md +++ b/Readme.md @@ -31,8 +31,13 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold ## 2Dos 😊 -* [ ] Clean up syntax (google std) +* [X] Clean up syntax (google std) * [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles + - [ ] Single Responsibility + - [ ] Open-Closed + - [ ] Liskov Substitution + - [ ] Interface segregation + - [ ] Dependency inversion * [ ] Extract methods and clean up objects * [ ] Comment everything From 62cade64bb6442af33d82998673ff3a2384b6a71 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 9 Jul 2019 10:46:11 +0200 Subject: [PATCH 05/38] Add CHANGELOG and format README --- CHANGELOG.md | 17 +++++++++++++++++ Readme.md => README.md | 8 -------- 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.md rename Readme.md => README.md (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..102b81d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog +All notable high-level changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.1] - 2019.07.09 +### Added +- This CHANGELOG file. +- Format project using `clang-project` +- README contains WIP elements, which will be eliminated after completion + +## [1.0.0] - 2019.07.09 +### Added +- This project as of state of the following publication: TODO diff --git a/Readme.md b/README.md similarity index 99% rename from Readme.md rename to README.md index 91ab575..dafa0be 100644 --- a/Readme.md +++ b/README.md @@ -1,15 +1,12 @@ # Layer-parallel training of deep residual neural networks - This code performs layer-parallel training of deep neural networks of residual type. It utilizes the parallel-in-time software library [XBraid](https://github.com/XBraid/xbraid) to distribute layers of the network to different compute units. Instead of sequential forward and backward propagation through the network, iterative multigrid udpates are performed in parallel to solve for the network propagation and the training simultaneously. See the paper [Guenther et al.](https://arxiv.org/pdf/1812.04352.pdf) for a describtion of the method and all details. ## Build - The repository includes XBraid as a submodule. To clone both, use either `git clone --recurse-submodules [...]` for Git version >= 2.13, or `git clone [...]` followed by `cd xbraid`, `git submodule init` and `git submodule update` for older Git versions. Type `make` in the main directory to build both the code and the XBraid library. ## Run - Test cases are located in the 'examples/' subfolder. Each example contains a `*.cfg` that holds configuration options for the current example dataset, the layer-parallelization with XBraid, and the optimization method and parameters. Run the test cases by callying './main' with the corresponding configuration file, e.g. `./main examples/peaks/peaks.cfg` @@ -20,7 +17,6 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold ## Roland / Stef combo - LEARNING/TODO: ### Overview: - * Xbraid => 3 braid apps know one net * One NN * Braid has to be initialized first -> Decides about layers per core @@ -30,7 +26,6 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold - init nn ## 2Dos 😊 - * [X] Clean up syntax (google std) * [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles - [ ] Single Responsibility @@ -40,6 +35,3 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold - [ ] Dependency inversion * [ ] Extract methods and clean up objects * [ ] Comment everything - - - From 72abcfd95c8ada2c3e43bc9c7d94942c4315504e Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 9 Jul 2019 10:46:56 +0200 Subject: [PATCH 06/38] Add .vscode and tags to gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 0cce01a..abff3db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# cpp build/ *out* *.o @@ -5,3 +6,7 @@ build/ *run_* *optim.dat main + +# unix and dev environment +.vscode +tags From 46422eb5008a123a64fa71dd77f85432e43cba46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=87=C9=B9=C7=9Dq=C6=83=C7=9D=E1=B4=89s=20pu=C9=90lo?= =?UTF-8?q?=C9=B9?= Date: Wed, 10 Jul 2019 10:49:37 +0200 Subject: [PATCH 07/38] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index dafa0be..9289ce4 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold ## 2Dos 😊 * [X] Clean up syntax (google std) +* [ ] Associate code with paper * [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles - [ ] Single Responsibility - [ ] Open-Closed From 1969454b5112562f87a7a2c42b0b45e7af6820a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=87=C9=B9=C7=9Dq=C6=83=C7=9D=E1=B4=89s=20pu=C9=90lo?= =?UTF-8?q?=C9=B9?= Date: Wed, 10 Jul 2019 10:50:14 +0200 Subject: [PATCH 08/38] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9289ce4..2d788a2 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,12 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold ## 2Dos 😊 * [X] Clean up syntax (google std) -* [ ] Associate code with paper +* [ ] Associate code with [paper](https://arxiv.org/pdf/1812.04352.pdf) * [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles - [ ] Single Responsibility - [ ] Open-Closed - [ ] Liskov Substitution - - [ ] Interface segregation - - [ ] Dependency inversion + - [ ] Interface Segregation + - [ ] Dependency Inversion * [ ] Extract methods and clean up objects * [ ] Comment everything From 7ed2621cdeeb7f84987ac59f42b67fe31db07dfe Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Wed, 10 Jul 2019 22:14:08 +0200 Subject: [PATCH 09/38] Remove tags file from git repo without deleting it locally --- tags | 1168 ---------------------------------------------------------- 1 file changed, 1168 deletions(-) delete mode 100644 tags diff --git a/tags b/tags deleted file mode 100644 index 1dc9776..0000000 --- a/tags +++ /dev/null @@ -1,1168 +0,0 @@ -!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ -!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ -!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ -!_TAG_PROGRAM_NAME Exuberant Ctags // -!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ -!_TAG_PROGRAM_VERSION 5.9~svn20110310 // --interaction xbraid/docs/Makefile /^ if test -d developer_manual; then cd developer_manual; sed 's\/pdflatex\/pdflatex --interaction=nonstopmode\/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi$/;" m --interaction xbraid/docs/Makefile /^ if test -d user_manual; then cd user_manual; sed 's\/pdflatex\/pdflatex --interaction=nonstopmode\/g' Makefile > Makefile.temp; mv Makefile.temp Makefile; fi$/;" m -.*|^ xbraid/test/adjoint.sh /^lines_to_check="^ time steps.*|^ number of levels.*|^ iterations.*|^ residual norm.*|^ state residual.*|^ adjoint residual.*|^ Objective function.*|^ Gradient norm.*|^ optimization iterations.*|^Finished braid_TestAll: no fails detected, however some results must be|.*Braid: Temporal refinement occurred.*|^255.*|^ 3 .*"$/;" f -../img/logo_with_subtext.pdf xbraid/docs/developer_manual_header.tex /^ \\includegraphics[width=0.7\\textwidth]{..\/img\/logo_with_subtext.pdf}$/;" g -../img/logo_with_subtext.pdf xbraid/docs/user_manual_header.tex /^ \\includegraphics[width=0.7\\textwidth]{..\/img\/logo_with_subtext.pdf}$/;" g -A include/hessianApprox.hpp /^ MyReal* A;$/;" m class:BFGS -A xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrix & A;$/;" m class:DenseMatrixTimeDependentOperator -A xbraid/drivers/mfem_arnoldi.hpp /^ Operator *A;$/;" m class:Arnoldi -ACCESS xbraid/braid/_braid_tape.h /^ ACCESS = 8,$/;" e enum:_braid_Call_enum -ACCESSOR_HEADER_GET1 xbraid/braid/braid_status.h 45;" d -ACCESSOR_HEADER_GET2 xbraid/braid/braid_status.h 47;" d -ACCESSOR_HEADER_GET4 xbraid/braid/braid_status.h 49;" d -ACCESSOR_HEADER_GET5 xbraid/braid/braid_status.h 51;" d -ACCESSOR_HEADER_SET1 xbraid/braid/braid_status.h 53;" d -ALL_EXAMPLES xbraid/drivers/Makefile /^ALL_EXAMPLES := $(patsubst %.c,%,$(ALL_EXAMPLES))$/;" m -ALL_EXAMPLES xbraid/drivers/Makefile /^ALL_EXAMPLES := $(patsubst %.cpp,%,$(wildcard *.c *.cpp))$/;" m -Access xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Access(braid_Vector u_,$/;" f class:MFEMBraidApp -Access xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Access(braid_Vector u_, BraidAccessStatus &astatus)$/;" f class:MFEMBraidApp -AddMeshOptions xbraid/drivers/braid_mfem.hpp /^void BraidOptions::AddMeshOptions()$/;" f class:BraidOptions -AddMeshOptions xbraid/drivers/braid_mfem_block.hpp /^void BraidOptions::AddMeshOptions()$/;" f class:BraidOptions -AllocLevels xbraid/drivers/braid_mfem.hpp /^ virtual void AllocLevels(int num_levels) { }$/;" f class:MFEMBraidApp -AllocLevels xbraid/drivers/braid_mfem_block.hpp /^ virtual void AllocLevels(int num_space_levels) { }$/;" f class:MFEMBraidApp -ApplyV xbraid/drivers/mfem_arnoldi.hpp /^ void ApplyV(const Vector & ubar, Vector & u)$/;" f class:Arnoldi -ApplyVT xbraid/drivers/mfem_arnoldi.hpp /^ void ApplyVT(const Vector & u, Vector & ubar)$/;" f class:Arnoldi -Arnoldi xbraid/drivers/mfem_arnoldi.hpp /^ Arnoldi(int k_max_, MPI_Comm comm_)$/;" f class:Arnoldi -Arnoldi xbraid/drivers/mfem_arnoldi.hpp /^class Arnoldi$/;" c -B include/hessianApprox.hpp /^ MyReal* B;$/;" m class:BFGS -BACKTRACKINGLS include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" e enum:stepsizetype -BFGS include/hessianApprox.hpp /^class BFGS : public HessianApprox {$/;" c -BFGS_SERIAL include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" e enum:hessiantype -BRAID_DIR xbraid/drivers/Makefile /^BRAID_DIR=..\/braid$/;" m -BRAID_DIR xbraid/examples/Makefile /^BRAID_DIR=..\/braid$/;" m -BRAID_FILES xbraid/braid/Makefile /^BRAID_FILES = _util.c braid.c _braid.c braid_test.c _braid_status.c braid_F90_iface.c _braid_base.c _braid_tape.c$/;" m -BRAID_FLAGS xbraid/drivers/Makefile /^BRAID_FLAGS = -I$(BRAID_DIR)$/;" m -BRAID_FLAGS xbraid/examples/Makefile /^BRAID_FLAGS = -I$(BRAID_DIR)$/;" m -BRAID_HEADERS xbraid/braid/Makefile /^BRAID_HEADERS = _braid.h braid.h _util.h braid_test.h braid_status.h braid_defs.h _braid_base.h _braid_tape.h$/;" m -BRAID_INC_DIR Makefile /^BRAID_INC_DIR = xbraid\/braid$/;" m -BRAID_LIB_FILE Makefile /^BRAID_LIB_FILE = xbraid\/braid\/libbraid.a$/;" m -BRAID_LIB_FILE xbraid/drivers/Makefile /^BRAID_LIB_FILE = $(BRAID_DIR)\/libbraid.a$/;" m -BRAID_LIB_FILE xbraid/examples/Makefile /^BRAID_LIB_FILE = $(BRAID_DIR)\/libbraid.a$/;" m -BRAID_OBJ xbraid/braid/Makefile /^BRAID_OBJ = $(BRAID_FILES:.c=.o)$/;" m -BUFPACK xbraid/braid/_braid_tape.h /^ BUFPACK = 6,$/;" e enum:_braid_Call_enum -BUFUNPACK xbraid/braid/_braid_tape.h /^ BUFUNPACK = 7,$/;" e enum:_braid_Call_enum -BUILD_DIR Makefile /^BUILD_DIR = build$/;" m -BraidAccessStatus xbraid/braid/braid.hpp /^ BraidAccessStatus(braid_AccessStatus _astatus)$/;" f class:BraidAccessStatus -BraidAccessStatus xbraid/braid/braid.hpp /^class BraidAccessStatus$/;" c -BraidApp xbraid/braid/braid.hpp /^ BraidApp(MPI_Comm _comm_t,$/;" f class:BraidApp -BraidApp xbraid/braid/braid.hpp /^class BraidApp$/;" c -BraidBufferStatus xbraid/braid/braid.hpp /^ BraidBufferStatus( braid_BufferStatus _bstatus )$/;" f class:BraidBufferStatus -BraidBufferStatus xbraid/braid/braid.hpp /^class BraidBufferStatus$/;" c -BraidCoarsenRefStatus xbraid/braid/braid.hpp /^ BraidCoarsenRefStatus(braid_CoarsenRefStatus _cstatus)$/;" f class:BraidCoarsenRefStatus -BraidCoarsenRefStatus xbraid/braid/braid.hpp /^class BraidCoarsenRefStatus$/;" c -BraidCore xbraid/braid/braid.hpp /^ BraidCore(MPI_Comm comm_world, BraidApp *app)$/;" f class:BraidCore -BraidCore xbraid/braid/braid.hpp /^class BraidCore$/;" c -BraidOptions xbraid/drivers/braid_mfem.hpp /^BraidOptions::BraidOptions(int argc, char *argv[])$/;" f class:BraidOptions -BraidOptions xbraid/drivers/braid_mfem.hpp /^struct BraidOptions : public OptionsParser$/;" s -BraidOptions xbraid/drivers/braid_mfem_block.hpp /^BraidOptions::BraidOptions(int argc, char *argv[])$/;" f class:BraidOptions -BraidOptions xbraid/drivers/braid_mfem_block.hpp /^struct BraidOptions : public OptionsParser$/;" s -BraidStepStatus xbraid/braid/braid.hpp /^ BraidStepStatus(braid_StepStatus _pstatus)$/;" f class:BraidStepStatus -BraidStepStatus xbraid/braid/braid.hpp /^class BraidStepStatus$/;" c -BraidUtil xbraid/braid/braid.hpp /^ BraidUtil() { }$/;" f class:BraidUtil -BraidUtil xbraid/braid/braid.hpp /^class BraidUtil$/;" c -BraidVector xbraid/drivers/braid_mfem.hpp /^ BraidVector(const BraidVector &source_vector)$/;" f class:BraidVector -BraidVector xbraid/drivers/braid_mfem.hpp /^ BraidVector(int source_level, ParFiniteElementSpace *pfes)$/;" f class:BraidVector -BraidVector xbraid/drivers/braid_mfem.hpp /^ BraidVector(int source_level, const HypreParVector &source_vector)$/;" f class:BraidVector -BraidVector xbraid/drivers/braid_mfem.hpp /^class BraidVector : public HypreParVector$/;" c -BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::BraidVector(const BraidVector &source_vector)$/;" f class:BraidVector -BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::BraidVector(int source_level, const Array &bOffsets)$/;" f class:BraidVector -BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::BraidVector(int source_level, const BlockVector &source_vector)$/;" f class:BraidVector -BraidVector xbraid/drivers/braid_mfem_block.hpp /^class BraidVector : public BlockVector$/;" c -BufPack xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::BufPack(braid_Vector u_,$/;" f class:MFEMBraidApp -BufPack xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::BufPack(braid_Vector u_, $/;" f class:MFEMBraidApp -BufSize xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::BufSize(int *size_ptr,$/;" f class:MFEMBraidApp -BufSize xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::BufSize(int *size_ptr,$/;" f class:MFEMBraidApp -BufUnpack xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::BufUnpack(void *buffer,$/;" f class:MFEMBraidApp -BufUnpack xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::BufUnpack(void *buffer,$/;" f class:MFEMBraidApp -CC Makefile /^CC = mpicc$/;" m -CLASSIFICATION include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -CLONE xbraid/braid/_braid_tape.h /^ CLONE = 3,$/;" e enum:_braid_Call_enum -CONFIG_ARG_MAX_BYTES include/config.hpp 7;" d -CONVOLUTION include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -CONVOLUTIONAL include/config.hpp /^enum networkType{DENSE, CONVOLUTIONAL}; $/;" e enum:networkType -CXX Makefile /^CXX = mpicxx$/;" m -CXX_EXAMPLES xbraid/drivers/Makefile /^CXX_EXAMPLES = drive-diffusion-1D-moving-mesh drive-diffusion-1D-moving-mesh-serial \\$/;" m -CXX_FLAGS Makefile /^CXX_FLAGS = -g -Wall -pedantic -lm -Wno-write-strings -Wno-delete-non-virtual-dtor -std=c++11$/;" m -C_EXAMPLES xbraid/drivers/Makefile /^C_EXAMPLES = drive-burgers-1D drive-diffusion-2D drive-lorenz$/;" m -C_EXAMPLES xbraid/examples/Makefile /^C_EXAMPLES = ex-03 ex-03-serial$/;" m -C_NOHYPRE xbraid/examples/Makefile /^C_NOHYPRE = ex-01 ex-01-adjoint ex-01-optimization ex-01-refinement ex-01-expanded ex-01-expanded-bdf2 ex-02 ex-04 ex-04-serial$/;" m -ClassificationLayer include/layer.hpp /^class ClassificationLayer : public Layer$/;" c -Clone xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Clone(braid_Vector u_,$/;" f class:MFEMBraidApp -Clone xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Clone(braid_Vector u_,$/;" f class:MFEMBraidApp -Coarsen xbraid/braid/braid.hpp /^ virtual braid_Int Coarsen(braid_Vector fu_,$/;" f class:BraidApp -Coarsen xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Coarsen(braid_Vector fu_,$/;" f class:MFEMBraidApp -Coarsen xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Coarsen(braid_Vector fu_, braid_Vector *cu_ptr, BraidCoarsenRefStatus &status)$/;" f class:MFEMBraidApp -ComputeMeshSize xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::ComputeMeshSize( ParMesh *pmesh, double * h_min_ptr, double * h_max_ptr)$/;" f class:SpaceTimeMeshInfo -ComputeMeshSize xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::ComputeMeshSize( ParMesh *pmesh, double * h_min_ptr, double * h_max_ptr)$/;" f class:SpaceTimeMeshInfo -ComputeSpaceLevel xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::ComputeSpaceLevel(double tstart, double tprior, double tstop)$/;" f class:MFEMBraidApp -ComputeSpaceLevel xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::ComputeSpaceLevel(double tstart, double tprior, double tstop)$/;" f class:MFEMBraidApp -Config include/config.hpp /^class Config {$/;" c -Config pythonutil/config.py /^class Config(OrderedBunch):$/;" c -ConstructFESpace xbraid/drivers/braid_mfem.hpp /^ParFiniteElementSpace *MFEMBraidApp::ConstructFESpace(ParMesh *pmesh)$/;" f class:MFEMBraidApp -ConstructFESpace xbraid/drivers/braid_mfem_block.hpp /^ParFiniteElementSpace *MFEMBraidApp::ConstructFESpace(ParMesh *pmesh)$/;" f class:MFEMBraidApp -ConvLayer include/layer.hpp /^class ConvLayer : public Layer {$/;" c -DENSE include/config.hpp /^enum networkType{DENSE, CONVOLUTIONAL}; $/;" e enum:networkType -DENSE include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -DETERMINISTIC include/config.hpp /^enum batchtype{DETERMINISTIC, STOCHASTIC};$/;" e enum:batchtype -DOX xbraid/docs/Makefile /^DOX=doxygen$/;" m -DOXVERSION xbraid/docs/Makefile /^DOXVERSION := $(shell expr `doxygen --version | sed -e 's\/\\.\\([0-9][0-9]\\)\/\\1\/g' -e 's\/\\.\\([0-9]\\)\/0\\1\/g' -e 's\/^[0-9]\\{3,4\\}$$\/&00\/'` \\>= 10800)$/;" m -DataSet include/dataset.hpp /^class DataSet {$/;" c -DenseLayer include/layer.hpp /^class DenseLayer : public Layer {$/;" c -DenseMatrixTimeDependentOperator xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrixTimeDependentOperator(DenseMatrix & A_) : TimeDependentOperator(A_.Width()), A(A_) {}$/;" f class:DenseMatrixTimeDependentOperator -DenseMatrixTimeDependentOperator xbraid/drivers/mfem_arnoldi.hpp /^class DenseMatrixTimeDependentOperator : public TimeDependentOperator$/;" c -Dot xbraid/drivers/mfem_arnoldi.hpp /^ double Dot(const Vector &x, const Vector &y) const$/;" f class:Arnoldi -Drive xbraid/braid/braid.hpp /^ void Drive() { braid_Drive(core); }$/;" f class:BraidCore -EvalBufSize xbraid/drivers/braid_mfem.hpp /^ static int EvalBufSize(int vector_size)$/;" f class:MFEMBraidApp -EvalBufSize xbraid/drivers/braid_mfem_block.hpp /^ static int EvalBufSize(int vector_size)$/;" f class:MFEMBraidApp -FIXED include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" e enum:stepsizetype -FREE xbraid/braid/_braid_tape.h /^ FREE = 4,$/;" e enum:_braid_Call_enum -F_NOHYPRE xbraid/examples/Makefile /^F_NOHYPRE = ex-01-expanded-f$/;" m -Free xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Free(braid_Vector u_)$/;" f class:MFEMBraidApp -Free xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Free(braid_Vector u_)$/;" f class:MFEMBraidApp -GenKrylovSpace xbraid/drivers/mfem_arnoldi.hpp /^ void GenKrylovSpace(const Vector & u)$/;" f class:Arnoldi -GetCTprior xbraid/braid/braid.hpp /^ void GetCTprior(braid_Real *c_tprior_ptr) { braid_CoarsenRefStatusGetCTprior(cstatus, c_tprior_ptr); }$/;" f class:BraidCoarsenRefStatus -GetCTstop xbraid/braid/braid.hpp /^ void GetCTstop(braid_Real *c_tstop_ptr) { braid_CoarsenRefStatusGetCTstop(cstatus, c_tstop_ptr); }$/;" f class:BraidCoarsenRefStatus -GetCore xbraid/braid/braid.hpp /^ braid_Core GetCore() { return core; };$/;" f class:BraidCore -GetDistribution xbraid/braid/braid.hpp /^ void GetDistribution(braid_Int *ilower_ptr, braid_Int *iupper_ptr) { _braid_GetDistribution(core, ilower_ptr, iupper_ptr); };$/;" f class:BraidCore -GetDone xbraid/braid/braid.hpp /^ void GetDone(braid_Int *done_ptr) { braid_AccessStatusGetDone(astatus, done_ptr); }$/;" f class:BraidAccessStatus -GetFTprior xbraid/braid/braid.hpp /^ void GetFTprior(braid_Real *f_tprior_ptr) { braid_CoarsenRefStatusGetFTprior(cstatus, f_tprior_ptr); }$/;" f class:BraidCoarsenRefStatus -GetFTstop xbraid/braid/braid.hpp /^ void GetFTstop(braid_Real *f_tstop_ptr) { braid_CoarsenRefStatusGetFTstop(cstatus, f_tstop_ptr); }$/;" f class:BraidCoarsenRefStatus -GetH xbraid/drivers/mfem_arnoldi.hpp /^ TimeDependentOperator & GetH( )$/;" f class:Arnoldi -GetIter xbraid/braid/braid.hpp /^ void GetIter(braid_Int *iter_ptr) { braid_StepStatusGetIter(pstatus, iter_ptr); }$/;" f class:BraidStepStatus -GetIter xbraid/braid/braid.hpp /^ void GetIter(braid_Int *iter_ptr) { braid_AccessStatusGetIter(astatus, iter_ptr); }$/;" f class:BraidAccessStatus -GetLevel xbraid/braid/braid.hpp /^ void GetLevel(braid_Int *level_ptr) { braid_StepStatusGetLevel(pstatus, level_ptr); }$/;" f class:BraidStepStatus -GetLevel xbraid/braid/braid.hpp /^ void GetLevel(braid_Int *level_ptr) { braid_AccessStatusGetLevel(astatus, level_ptr); }$/;" f class:BraidAccessStatus -GetLevel xbraid/braid/braid.hpp /^ void GetLevel(braid_Int *level_ptr) { braid_CoarsenRefStatusGetLevel(cstatus, level_ptr); }$/;" f class:BraidCoarsenRefStatus -GetMessageType xbraid/braid/braid.hpp /^ void GetMessageType( braid_Int *messagetype_ptr ) { braid_BufferStatusGetMessageType( bstatus, messagetype_ptr); }$/;" f class:BraidBufferStatus -GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_StepStatusGetNLevels(pstatus, nlevels_ptr); }$/;" f class:BraidStepStatus -GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_AccessStatusGetNLevels(astatus, nlevels_ptr);}$/;" f class:BraidAccessStatus -GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_CoarsenRefStatusGetNLevels(cstatus, nlevels_ptr); }$/;" f class:BraidCoarsenRefStatus -GetNLevels xbraid/braid/braid.hpp /^ void GetNLevels(braid_Int *nlevels_ptr) { braid_GetNLevels(core, nlevels_ptr); }$/;" f class:BraidCore -GetNRefine xbraid/braid/braid.hpp /^ void GetNRefine(braid_Int *nrefine_ptr) { braid_StepStatusGetNRefine(pstatus, nrefine_ptr); }$/;" f class:BraidStepStatus -GetNRefine xbraid/braid/braid.hpp /^ void GetNRefine(braid_Int *nrefine_ptr) { braid_AccessStatusGetNRefine(astatus, nrefine_ptr); }$/;" f class:BraidAccessStatus -GetNRefine xbraid/braid/braid.hpp /^ void GetNRefine(braid_Int *nrefine_ptr) { braid_CoarsenRefStatusGetNRefine(cstatus, nrefine_ptr); }$/;" f class:BraidCoarsenRefStatus -GetNumBlocks xbraid/drivers/braid_mfem_block.hpp /^void BraidVector::GetNumBlocks(int &blocks)$/;" f class:BraidVector -GetNumIter xbraid/braid/braid.hpp /^ void GetNumIter(braid_Int *niter_ptr) { braid_GetNumIter(core, niter_ptr); }$/;" f class:BraidCore -GetNumSpaceLevels xbraid/drivers/braid_mfem.hpp /^ int GetNumSpaceLevels() const { return ode.Size(); }$/;" f class:MFEMBraidApp -GetNumSpaceLevels xbraid/drivers/braid_mfem_block.hpp /^ int GetNumSpaceLevels() const { return ode.Size(); }$/;" f class:MFEMBraidApp -GetOffsetsPtr xbraid/drivers/braid_mfem_block.hpp /^void BraidVector::GetOffsetsPtr(const int *&address)$/;" f class:BraidVector -GetOldFineTolx xbraid/braid/braid.hpp /^ void GetOldFineTolx(braid_Real *old_fine_tolx_ptr) { braid_StepStatusGetOldFineTolx(pstatus, old_fine_tolx_ptr); }$/;" f class:BraidStepStatus -GetRNorms xbraid/braid/braid.hpp /^ void GetRNorms(braid_Int *nrequest_ptr, braid_Real *rnorms)$/;" f class:BraidStepStatus -GetRNorms xbraid/braid/braid.hpp /^ void GetRNorms(braid_Int *nrequest_ptr, braid_Real *rnorms) { braid_GetRNorms(core, nrequest_ptr, rnorms); }$/;" f class:BraidCore -GetResidual xbraid/braid/braid.hpp /^ void GetResidual(braid_Real *rnorm_ptr) { braid_AccessStatusGetResidual(astatus, rnorm_ptr); }$/;" f class:BraidAccessStatus -GetSpatialAccuracy xbraid/braid/braid.hpp /^ void GetSpatialAccuracy(braid_StepStatus sstatus,$/;" f class:BraidUtil -GetT xbraid/braid/braid.hpp /^ void GetT(braid_Real *t_ptr) { braid_AccessStatusGetT(astatus, t_ptr); }$/;" f class:BraidAccessStatus -GetT xbraid/braid/braid.hpp /^ void GetT(braid_Real *tstart_ptr) { braid_StepStatusGetT(pstatus, tstart_ptr); }$/;" f class:BraidStepStatus -GetT xbraid/braid/braid.hpp /^ void GetT(braid_Real *tstart_ptr) { braid_CoarsenRefStatusGetT(cstatus, tstart_ptr); }$/;" f class:BraidCoarsenRefStatus -GetTILD xbraid/braid/braid.hpp /^ void GetTILD(braid_Real *t_ptr,$/;" f class:BraidAccessStatus -GetTIndex xbraid/braid/braid.hpp /^ void GetTIndex(braid_Int *tindex_ptr) { braid_StepStatusGetTIndex(pstatus, tindex_ptr); }$/;" f class:BraidStepStatus -GetTIndex xbraid/braid/braid.hpp /^ void GetTIndex(braid_Int *tindex_ptr) { braid_AccessStatusGetTIndex(astatus, tindex_ptr); }$/;" f class:BraidAccessStatus -GetTIndex xbraid/braid/braid.hpp /^ void GetTIndex(braid_Int *tindex_ptr) { braid_CoarsenRefStatusGetTIndex(cstatus, tindex_ptr); }$/;" f class:BraidCoarsenRefStatus -GetTpriorTstop xbraid/braid/braid.hpp /^ void GetTpriorTstop(braid_Real *tstart_ptr,$/;" f class:BraidCoarsenRefStatus -GetTstartTstop xbraid/braid/braid.hpp /^ void GetTstartTstop(braid_Real *tstart_ptr, braid_Real *tstop_ptr)$/;" f class:BraidStepStatus -GetTstop xbraid/braid/braid.hpp /^ void GetTstop(braid_Real *tstop_ptr) { braid_StepStatusGetTstop(pstatus, tstop_ptr); }$/;" f class:BraidStepStatus -GetWarmRestart xbraid/braid/braid.hpp /^ braid_Int GetWarmRestart() { return _braid_CoreElt(core, warm_restart); };$/;" f class:BraidCore -GetWrapperTest xbraid/braid/braid.hpp /^ void GetWrapperTest(braid_Int *wtest_ptr) { braid_AccessStatusGetWrapperTest(astatus, wtest_ptr); }$/;" f class:BraidAccessStatus -H xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrix H;$/;" m class:Arnoldi -H0 include/hessianApprox.hpp /^ MyReal H0; \/* Initial Hessian scaling factor *\/$/;" m class:L_BFGS -HYPRE_DIR xbraid/drivers/Makefile /^HYPRE_DIR = ..\/..\/hypre\/src\/hypre$/;" m -HYPRE_DIR xbraid/examples/Makefile /^HYPRE_DIR = ..\/..\/hypre\/src\/hypre$/;" m -HYPRE_FLAGS xbraid/drivers/Makefile /^HYPRE_FLAGS = -I$(HYPRE_DIR)\/include$/;" m -HYPRE_FLAGS xbraid/examples/Makefile /^HYPRE_FLAGS = -I$(HYPRE_DIR)\/include$/;" m -HYPRE_LIB xbraid/drivers/Makefile /^HYPRE_LIB = -L$(HYPRE_DIR)\/lib -lHYPRE$/;" m -HYPRE_LIB xbraid/examples/Makefile /^HYPRE_LIB = -L$(HYPRE_DIR)\/lib -lHYPRE$/;" m -HYPRE_LIB_FILE xbraid/examples/Makefile /^HYPRE_LIB_FILE = $(HYPRE_DIR)\/lib\/libHYPRE.a$/;" m -Hessian include/hessianApprox.hpp /^ MyReal* Hessian; \/* Storing the Hessian approximation (flattened: dimN*dimN) *\/$/;" m class:BFGS -HessianApprox include/hessianApprox.hpp /^class HessianApprox {$/;" c -Hop xbraid/drivers/mfem_arnoldi.hpp /^ DenseMatrixTimeDependentOperator Hop;$/;" m class:Arnoldi -Hy include/hessianApprox.hpp /^ MyReal* Hy;$/;" m class:BFGS -IDENTITY include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" e enum:hessiantype -INC Makefile /^INC = -I$(INC_DIR) -I$(BRAID_INC_DIR)$/;" m -INC_DIR Makefile /^INC_DIR = include$/;" m -INIT xbraid/braid/_braid_tape.h /^ INIT = 2,$/;" e enum:_braid_Call_enum -Identity include/hessianApprox.hpp /^class Identity : public HessianApprox{$/;" c -Init xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Init(double t,$/;" f class:MFEMBraidApp -Init xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Init(double t, braid_Vector *u_ptr)$/;" f class:MFEMBraidApp -InitLevel xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::InitLevel(int l)$/;" f class:MFEMBraidApp -InitLevel xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::InitLevel(int l)$/;" f class:MFEMBraidApp -InitMultilevelApp xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::InitMultilevelApp(ParMesh *pmesh, int pref, bool scoarsen)$/;" f class:MFEMBraidApp -InitMultilevelApp xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::InitMultilevelApp(ParMesh *pmesh, int pref, bool scoarsen)$/;" f class:MFEMBraidApp -LBFGS include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" e enum:hessiantype -L_BFGS include/hessianApprox.hpp /^class L_BFGS : public HessianApprox {$/;" c -Layer include/layer.hpp /^class Layer $/;" c -LoadMeshAndRefine xbraid/drivers/braid_mfem.hpp /^ParMesh *BraidOptions::LoadMeshAndRefine(MPI_Comm comm_x)$/;" f class:BraidOptions -LoadMeshAndSerialRefine xbraid/drivers/braid_mfem.hpp /^Mesh *BraidOptions::LoadMeshAndSerialRefine()$/;" f class:BraidOptions -LoadMeshAndSerialRefine xbraid/drivers/braid_mfem_block.hpp /^Mesh *BraidOptions::LoadMeshAndSerialRefine()$/;" f class:BraidOptions -M include/hessianApprox.hpp /^ int M; \/* Length of the l-bfgs memory (stages) *\/$/;" m class:L_BFGS -MFEMBraidApp xbraid/drivers/braid_mfem.hpp /^MFEMBraidApp::MFEMBraidApp($/;" f class:MFEMBraidApp -MFEMBraidApp xbraid/drivers/braid_mfem.hpp /^class MFEMBraidApp : public BraidApp$/;" c -MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::MFEMBraidApp( MPI_Comm comm_t_, TimeDependentOperator *ode_, BlockVector *X0_,$/;" f class:MFEMBraidApp -MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::MFEMBraidApp( MPI_Comm comm_t_, const int num_space_levels, double tstart_,$/;" f class:MFEMBraidApp -MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::MFEMBraidApp(MPI_Comm comm_t_, double tstart_, double tstop_, int ntime_)$/;" f class:MFEMBraidApp -MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^class MFEMBraidApp : public BraidApp$/;" c -MFEM_CONFIG_MK xbraid/drivers/Makefile /^MFEM_CONFIG_MK = $(MFEM_DIR)\/config\/config.mk$/;" m -MFEM_CONFIG_MK xbraid/examples/Makefile /^MFEM_CONFIG_MK = $(MFEM_DIR)\/config\/config.mk$/;" m -MFEM_DIR xbraid/drivers/Makefile /^MFEM_DIR = ..\/..\/mfem$/;" m -MFEM_DIR xbraid/examples/Makefile /^MFEM_DIR = ..\/..\/mfem$/;" m -MFEM_INTERFACE xbraid/drivers/Makefile /^MFEM_INTERFACE = .\/braid_mfem.hpp .\/braid_mfem_block.hpp ..\/braid\/braid.hpp$/;" m -MFEM_LIB_FILE xbraid/drivers/Makefile /^MFEM_LIB_FILE = mfem_is_not_built$/;" m -MFEM_LIB_FILE xbraid/examples/Makefile /^MFEM_LIB_FILE = mfem_is_not_built$/;" m -MPI_ANY_SOURCE xbraid/braid/mpistubs.h 65;" d -MPI_ANY_TAG xbraid/braid/mpistubs.h 66;" d -MPI_Aint xbraid/braid/mpistubs.h /^typedef int MPI_Aint;$/;" t -MPI_BOTTOM xbraid/braid/mpistubs.h 46;" d -MPI_BYTE xbraid/braid/mpistubs.h 52;" d -MPI_CHAR xbraid/braid/mpistubs.h 50;" d -MPI_COMM_NULL xbraid/braid/mpistubs.h 44;" d -MPI_COMM_WORLD xbraid/braid/mpistubs.h 43;" d -MPI_COMPLEX xbraid/braid/mpistubs.h 54;" d -MPI_Comm xbraid/braid/braid.h /^typedef int MPI_Comm;$/;" t -MPI_DOUBLE xbraid/braid/mpistubs.h 48;" d -MPI_Datatype xbraid/braid/mpistubs.h /^typedef int MPI_Datatype;$/;" t -MPI_Group xbraid/braid/mpistubs.h /^typedef int MPI_Group;$/;" t -MPI_INT xbraid/braid/mpistubs.h 49;" d -MPI_LONG xbraid/braid/mpistubs.h 51;" d -MPI_LOR xbraid/braid/mpistubs.h 59;" d -MPI_MAX xbraid/braid/mpistubs.h 58;" d -MPI_MIN xbraid/braid/mpistubs.h 57;" d -MPI_MyReal include/defs.hpp 11;" d -MPI_Op xbraid/braid/mpistubs.h /^typedef int MPI_Op;$/;" t -MPI_REAL xbraid/braid/mpistubs.h 53;" d -MPI_REQUEST_NULL xbraid/braid/mpistubs.h 64;" d -MPI_Request xbraid/braid/mpistubs.h /^typedef int MPI_Request;$/;" t -MPI_SOURCE xbraid/braid/mpistubs.h /^ int MPI_SOURCE;$/;" m struct:__anon1 -MPI_STATUSES_IGNORE xbraid/braid/mpistubs.h 61;" d -MPI_SUCCESS xbraid/braid/mpistubs.h 60;" d -MPI_SUM xbraid/braid/mpistubs.h 56;" d -MPI_Status xbraid/braid/mpistubs.h /^} MPI_Status;$/;" t typeref:struct:__anon1 -MPI_TAG xbraid/braid/mpistubs.h /^ int MPI_TAG;$/;" m struct:__anon1 -MPI_UNDEFINED xbraid/braid/mpistubs.h 63;" d -MPIcomm include/hessianApprox.hpp /^ MPI_Comm MPIcomm; \/* MPI communicator for parallel L-BFGS updates *\/$/;" m class:HessianApprox -MPIrank include/dataset.hpp /^ int MPIrank; \/* Processors rank *\/$/;" m class:DataSet -MPIsize include/dataset.hpp /^ int MPIsize; \/* Size of the global communicator *\/$/;" m class:DataSet -Mult xbraid/drivers/mfem_arnoldi.hpp /^ virtual void Mult(const Vector &x, Vector &y) const$/;" f class:DenseMatrixTimeDependentOperator -MyReal include/defs.hpp /^typedef double MyReal;$/;" t -Network include/network.hpp /^class Network$/;" c -OBJECTIVET xbraid/braid/_braid_tape.h /^ OBJECTIVET = 9$/;" e enum:_braid_Call_enum -OBJ_FILES Makefile /^OBJ_FILES = $(patsubst $(SRC_DIR)\/%.cpp,$(BUILD_DIR)\/%.o,$(SRC_FILES))$/;" m -ONEOVERK include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" e enum:stepsizetype -OPENCONV include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -OPENCONVMNIST include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -OPENDENSE include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -OPENZERO include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" e enum:Layer::layertype -OpenConvLayer include/layer.hpp /^class OpenConvLayer : public Layer {$/;" c -OpenConvLayerMNIST include/layer.hpp /^class OpenConvLayerMNIST : public OpenConvLayer {$/;" c -OpenDenseLayer include/layer.hpp /^class OpenDenseLayer : public DenseLayer {$/;" c -OpenExpandZero include/layer.hpp /^class OpenExpandZero : public Layer $/;" c -OrderedBunch pythonutil/ordered_bunch.py /^class OrderedBunch(OrderedDict):$/;" c -OrderedDict pythonutil/ordered_dict.py /^class OrderedDict(dict):$/;" c -P xbraid/drivers/braid_mfem.hpp /^ Array P; \/\/ local prolongation matrices, l+1 --> l$/;" m class:MFEMBraidApp -P xbraid/drivers/braid_mfem_block.hpp /^ Array P; \/\/ local interpolation matrices, l --> l+1$/;" m class:MFEMBraidApp -Print xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::Print(MPI_Comm comm)$/;" f class:SpaceTimeMeshInfo -Print xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::Print(MPI_Comm comm)$/;" f class:SpaceTimeMeshInfo -RELU include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" e enum:activation -Refine xbraid/braid/braid.hpp /^ virtual braid_Int Refine(braid_Vector cu_,$/;" f class:BraidApp -Refine xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Refine(braid_Vector cu_,$/;" f class:MFEMBraidApp -Refine xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Refine(braid_Vector cu_, braid_Vector *fu_ptr, BraidCoarsenRefStatus &status)$/;" f class:MFEMBraidApp -Reinitialize xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::Reinitialize(int _max_levels)$/;" f class:SpaceTimeMeshInfo -Reinitialize xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::Reinitialize(int _max_levels)$/;" f class:SpaceTimeMeshInfo -Residual xbraid/drivers/braid_mfem.hpp /^ virtual int Residual(braid_Vector u_,$/;" f class:MFEMBraidApp -Residual xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Residual(braid_Vector u_, braid_Vector r_, BraidStepStatus &pstatus)$/;" f class:MFEMBraidApp -SEQFLAGS xbraid/braid/Makefile /^ SEQFLAGS = $/;" m -SEQFLAGS xbraid/braid/Makefile /^ SEQFLAGS = -Dbraid_SEQUENTIAL$/;" m -SMRELU include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" e enum:activation -SRC_DIR Makefile /^SRC_DIR = src$/;" m -SRC_FILES Makefile /^SRC_FILES = $(wildcard $(SRC_DIR)\/*.cpp)$/;" m -STEP xbraid/braid/_braid_tape.h /^ STEP = 1,$/;" e enum:_braid_Call_enum -STOCHASTIC include/config.hpp /^enum batchtype{DETERMINISTIC, STOCHASTIC};$/;" e enum:batchtype -SUM xbraid/braid/_braid_tape.h /^ SUM = 5,$/;" e enum:_braid_Call_enum -SetAbsTol xbraid/braid/braid.hpp /^ void SetAbsTol(braid_Real tol) { braid_SetAbsTol(core, tol); }$/;" f class:BraidCore -SetAccessLevel xbraid/braid/braid.hpp /^ void SetAccessLevel(braid_Int access_level) { braid_SetAccessLevel(core, access_level); }$/;" f class:BraidCore -SetAggCFactor xbraid/braid/braid.hpp /^ void SetAggCFactor(braid_Int cfactor0)$/;" f class:BraidCore -SetBraidCoreOptions xbraid/drivers/braid_mfem.hpp /^void BraidOptions::SetBraidCoreOptions(BraidCore &core)$/;" f class:BraidOptions -SetBraidCoreOptions xbraid/drivers/braid_mfem_block.hpp /^void BraidOptions::SetBraidCoreOptions(BraidCore &core)$/;" f class:BraidOptions -SetCFactor xbraid/braid/braid.hpp /^ void SetCFactor(braid_Int level, braid_Int cfactor)$/;" f class:BraidCore -SetExactSolution xbraid/drivers/braid_mfem.hpp /^ void SetExactSolution(Coefficient *exsol) { exact_sol = exsol; }$/;" f class:MFEMBraidApp -SetExactSolution xbraid/drivers/braid_mfem_block.hpp /^ void SetExactSolution(Coefficient *exsol) { exact_sol = exsol; }$/;" f class:MFEMBraidApp -SetFMG xbraid/braid/braid.hpp /^ void SetFMG() { braid_SetFMG(core); }$/;" f class:BraidCore -SetInitialCondition xbraid/drivers/braid_mfem.hpp /^ void SetInitialCondition(HypreParVector *_X0) { X0 = _X0; }$/;" f class:MFEMBraidApp -SetInitialCondition xbraid/drivers/braid_mfem_block.hpp /^ void SetInitialCondition(BlockVector *_X0) { X0 = _X0; }$/;" f class:MFEMBraidApp -SetMaxIter xbraid/braid/braid.hpp /^ void SetMaxIter(braid_Int max_iter) { braid_SetMaxIter(core, max_iter); }$/;" f class:BraidCore -SetMaxLevels xbraid/braid/braid.hpp /^ void SetMaxLevels(braid_Int max_levels) { braid_SetMaxLevels(core, max_levels); }$/;" f class:BraidCore -SetMaxRefinements xbraid/braid/braid.hpp /^ void SetMaxRefinements(braid_Int max_refinements) {braid_SetMaxRefinements(core, max_refinements);}$/;" f class:BraidCore -SetMinCoarse xbraid/braid/braid.hpp /^ void SetMinCoarse(braid_Int min_coarse) { braid_SetMinCoarse(core, min_coarse); }$/;" f class:BraidCore -SetNFMG xbraid/braid/braid.hpp /^ void SetNFMG(braid_Int k) { braid_SetNFMG(core, k); }$/;" f class:BraidCore -SetNFMGVcyc xbraid/braid/braid.hpp /^ void SetNFMGVcyc(braid_Int nfmg_Vcyc) { braid_SetNFMGVcyc(core, nfmg_Vcyc); }$/;" f class:BraidCore -SetNRelax xbraid/braid/braid.hpp /^ void SetNRelax(braid_Int level, braid_Int nrelax)$/;" f class:BraidCore -SetOldFineTolx xbraid/braid/braid.hpp /^ void SetOldFineTolx(braid_Real old_fine_tolx) { braid_StepStatusSetOldFineTolx(pstatus, old_fine_tolx); }$/;" f class:BraidStepStatus -SetOperator xbraid/drivers/mfem_arnoldi.hpp /^ void SetOperator(Operator &A_)$/;" f class:Arnoldi -SetPrintFile xbraid/braid/braid.hpp /^ void SetPrintFile(const char *printfile_name) { braid_SetPrintFile(core, printfile_name); }$/;" f class:BraidCore -SetPrintLevel xbraid/braid/braid.hpp /^ void SetPrintLevel(braid_Int print_level) { braid_SetPrintLevel(core, print_level); }$/;" f class:BraidCore -SetRFactor xbraid/braid/braid.hpp /^ void SetRFactor(braid_Int rfactor) { braid_StepStatusSetRFactor(pstatus, rfactor); }$/;" f class:BraidStepStatus -SetRSpace xbraid/braid/braid.hpp /^ void SetRSpace(braid_Int rspace) { braid_StepStatusSetRSpace(pstatus, rspace); }$/;" f class:BraidStepStatus -SetRandomInitVectors xbraid/drivers/braid_mfem.hpp /^ void SetRandomInitVectors(unsigned seed)$/;" f class:MFEMBraidApp -SetRefine xbraid/braid/braid.hpp /^ void SetRefine(braid_Int refine) {braid_SetRefine(core, refine);}$/;" f class:BraidCore -SetRelTol xbraid/braid/braid.hpp /^ void SetRelTol(braid_Real tol) { braid_SetRelTol(core, tol); }$/;" f class:BraidCore -SetResidual xbraid/braid/braid.hpp /^ void SetResidual() { braid_SetResidual(core, _BraidAppResidual); }$/;" f class:BraidCore -SetRevertedRanks xbraid/braid/braid.hpp /^ void SetRevertedRanks(braid_Int reverted_ranks) { braid_SetRevertedRanks(core, reverted_ranks); }$/;" f class:BraidCore -SetRow xbraid/drivers/braid_mfem.hpp /^void SpaceTimeMeshInfo::SetRow(int braid_level, int vec_level, ParMesh * pmesh, double dt)$/;" f class:SpaceTimeMeshInfo -SetRow xbraid/drivers/braid_mfem_block.hpp /^void SpaceTimeMeshInfo::SetRow(int braid_level, int vec_level, ParMesh * pmesh, double dt)$/;" f class:SpaceTimeMeshInfo -SetSeqSoln xbraid/braid/braid.hpp /^ void SetSeqSoln(braid_Int use_seq_soln) { braid_SetSeqSoln(core, use_seq_soln); }$/;" f class:BraidCore -SetSize xbraid/braid/braid.hpp /^ void SetSize( braid_Int size ) { braid_BufferStatusSetSize( bstatus, size ); }$/;" f class:BraidBufferStatus -SetSkip xbraid/braid/braid.hpp /^ void SetSkip(braid_Int skip) { braid_SetSkip(core, skip); }$/;" f class:BraidCore -SetSpaceLevel xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::SetSpaceLevel(int l, TimeDependentOperator *ode_l,$/;" f class:MFEMBraidApp -SetSpaceLevel xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::SetSpaceLevel(int l, TimeDependentOperator *ode_l, ODESolver *solver_l, $/;" f class:MFEMBraidApp -SetSpatialCoarsenAndRefine xbraid/braid/braid.hpp /^ void SetSpatialCoarsenAndRefine()$/;" f class:BraidCore -SetStorage xbraid/braid/braid.hpp /^ void SetStorage(braid_Int storage) { braid_SetStorage(core, storage); }$/;" f class:BraidCore -SetTemporalNorm xbraid/braid/braid.hpp /^ void SetTemporalNorm(braid_Int tnorm) { braid_SetTemporalNorm(core, tnorm); }$/;" f class:BraidCore -SetTightFineTolx xbraid/braid/braid.hpp /^ void SetTightFineTolx(braid_Int tight_fine_tolx) { braid_StepStatusSetTightFineTolx(pstatus, tight_fine_tolx); }$/;" f class:BraidStepStatus -SetVisHostAndPort xbraid/drivers/braid_mfem.hpp /^void MFEMBraidApp::SetVisHostAndPort(const char *vh, int vp)$/;" f class:MFEMBraidApp -SetVisHostAndPort xbraid/drivers/braid_mfem_block.hpp /^void MFEMBraidApp::SetVisHostAndPort(const char *vh, int vp)$/;" f class:MFEMBraidApp -SetVisSampling xbraid/drivers/braid_mfem.hpp /^ void SetVisSampling(int time_steps, int braid_steps)$/;" f class:MFEMBraidApp -SetVisSampling xbraid/drivers/braid_mfem_block.hpp /^ void SetVisSampling(int time_steps, int braid_steps)$/;" f class:MFEMBraidApp -SetVisScreenshots xbraid/drivers/braid_mfem.hpp /^ void SetVisScreenshots(bool ss) { vis_screenshots = ss; }$/;" f class:MFEMBraidApp -SetVisScreenshots xbraid/drivers/braid_mfem_block.hpp /^ void SetVisScreenshots(bool ss) { vis_screenshots = ss; }$/;" f class:MFEMBraidApp -SpaceTimeMeshInfo xbraid/drivers/braid_mfem.hpp /^ SpaceTimeMeshInfo(int _max_levels) :$/;" f class:SpaceTimeMeshInfo -SpaceTimeMeshInfo xbraid/drivers/braid_mfem.hpp /^class SpaceTimeMeshInfo$/;" c -SpaceTimeMeshInfo xbraid/drivers/braid_mfem_block.hpp /^ SpaceTimeMeshInfo(int _max_levels) : $/;" f class:SpaceTimeMeshInfo -SpaceTimeMeshInfo xbraid/drivers/braid_mfem_block.hpp /^class SpaceTimeMeshInfo$/;" c -SpatialNorm xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::SpatialNorm(braid_Vector u_,$/;" f class:MFEMBraidApp -SpatialNorm xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::SpatialNorm(braid_Vector u_, double *norm_ptr)$/;" f class:MFEMBraidApp -SplitCommworld xbraid/braid/braid.hpp /^ void SplitCommworld(const MPI_Comm *comm_world,$/;" f class:BraidUtil -Step xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Step(braid_Vector u_,$/;" f class:MFEMBraidApp -Step xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Step(braid_Vector u_, braid_Vector ustop_, braid_Vector fstop_, BraidStepStatus &pstatus)$/;" f class:MFEMBraidApp -StepStatusGetTol xbraid/braid/braid.hpp /^ void StepStatusGetTol(braid_Real *tol_ptr) { braid_StepStatusGetTol(pstatus, tol_ptr); }$/;" f class:BraidStepStatus -Sum xbraid/drivers/braid_mfem.hpp /^int MFEMBraidApp::Sum(double alpha,$/;" f class:MFEMBraidApp -Sum xbraid/drivers/braid_mfem_block.hpp /^int MFEMBraidApp::Sum(double alpha, braid_Vector a_, double beta, braid_Vector b_)$/;" f class:MFEMBraidApp -T include/config.hpp /^ MyReal T;$/;" m class:Config -TABLE OF CONTENTS xbraid/docs/developer_manual_header.tex /^\\tableofcontents$/;" s -TABLE OF CONTENTS xbraid/docs/user_manual_header.tex /^\\tableofcontents$/;" s -TANH include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" e enum:activation -TestAll xbraid/braid/braid.hpp /^ braid_Int TestAll(BraidApp *app,$/;" f class:BraidUtil -TestBuf xbraid/braid/braid.hpp /^ braid_Int TestBuf(BraidApp *app,$/;" f class:BraidUtil -TestClone xbraid/braid/braid.hpp /^ void TestClone(BraidApp *app,$/;" f class:BraidUtil -TestCoarsenRefine xbraid/braid/braid.hpp /^ braid_Int TestCoarsenRefine(BraidApp *app,$/;" f class:BraidUtil -TestInitAccess xbraid/braid/braid.hpp /^ void TestInitAccess(BraidApp *app,$/;" f class:BraidUtil -TestResidual xbraid/braid/braid.hpp /^ braid_Int TestResidual(BraidApp *app,$/;" f class:BraidUtil -TestSpatialNorm xbraid/braid/braid.hpp /^ braid_Int TestSpatialNorm(BraidApp *app,$/;" f class:BraidUtil -TestSum xbraid/braid/braid.hpp /^ void TestSum(BraidApp *app,$/;" f class:BraidUtil -TrueDofsToLDofs xbraid/drivers/braid_mfem_block.hpp /^void TrueDofsToLDofs(const Vector &u, ParGridFunction &v)$/;" f namespace:mfem -V xbraid/drivers/mfem_arnoldi.hpp /^ Vector *V;$/;" m class:Arnoldi -X0 xbraid/drivers/braid_mfem.hpp /^ HypreParVector *X0; \/\/ Initial condition (at the finest level 0)$/;" m class:MFEMBraidApp -X0 xbraid/drivers/braid_mfem_block.hpp /^ BlockVector *X0; \/\/ Initial condition (at the finest level 0)$/;" m class:MFEMBraidApp -_BraidAppAccess xbraid/braid/braid.hpp /^static braid_Int _BraidAppAccess(braid_App _app,$/;" f -_BraidAppBufPack xbraid/braid/braid.hpp /^static braid_Int _BraidAppBufPack(braid_App _app,$/;" f -_BraidAppBufSize xbraid/braid/braid.hpp /^static braid_Int _BraidAppBufSize(braid_App _app,$/;" f -_BraidAppBufUnpack xbraid/braid/braid.hpp /^static braid_Int _BraidAppBufUnpack(braid_App _app,$/;" f -_BraidAppClone xbraid/braid/braid.hpp /^static braid_Int _BraidAppClone(braid_App _app,$/;" f -_BraidAppCoarsen xbraid/braid/braid.hpp /^static braid_Int _BraidAppCoarsen(braid_App _app,$/;" f -_BraidAppFree xbraid/braid/braid.hpp /^static braid_Int _BraidAppFree(braid_App _app,$/;" f -_BraidAppInit xbraid/braid/braid.hpp /^static braid_Int _BraidAppInit(braid_App _app,$/;" f -_BraidAppRefine xbraid/braid/braid.hpp /^static braid_Int _BraidAppRefine(braid_App _app,$/;" f -_BraidAppResidual xbraid/braid/braid.hpp /^static braid_Int _BraidAppResidual(braid_App _app,$/;" f -_BraidAppSpatialNorm xbraid/braid/braid.hpp /^static braid_Int _BraidAppSpatialNorm(braid_App _app,$/;" f -_BraidAppStep xbraid/braid/braid.hpp /^static braid_Int _BraidAppStep(braid_App _app,$/;" f -_BraidAppSum xbraid/braid/braid.hpp /^static braid_Int _BraidAppSum(braid_App _app,$/;" f -__contains__ pythonutil/ordered_bunch.py /^ def __contains__(self, k):$/;" m class:OrderedBunch file: -__delattr__ pythonutil/ordered_bunch.py /^ def __delattr__(self, k):$/;" m class:OrderedBunch file: -__delitem__ pythonutil/ordered_dict.py /^ def __delitem__(self, key, dict_delitem=dict.__delitem__):$/;" m class:OrderedDict file: -__eq__ pythonutil/config.py /^ def __eq__(self,konfig):$/;" m class:Config file: -__eq__ pythonutil/ordered_dict.py /^ def __eq__(self, other):$/;" m class:OrderedDict file: -__getattr__ pythonutil/config.py /^ def __getattr__(self,k):$/;" m class:Config file: -__getattr__ pythonutil/ordered_bunch.py /^ def __getattr__(self, k):$/;" m class:OrderedBunch file: -__getitem__ pythonutil/config.py /^ def __getitem__(self,k):$/;" m class:Config file: -__init__ pythonutil/config.py /^ def __init__(self,*args,**kwarg):$/;" m class:Config -__init__ pythonutil/ordered_bunch.py /^ def __init__(self,*args,**kwarg):$/;" m class:OrderedBunch -__init__ pythonutil/ordered_dict.py /^ def __init__(self, *args, **kwds):$/;" m class:OrderedDict -__init__ pythonutil/switch.py /^ def __init__(self, value):$/;" m class:switch -__iter__ pythonutil/ordered_dict.py /^ def __iter__(self):$/;" m class:OrderedDict file: -__iter__ pythonutil/switch.py /^ def __iter__(self):$/;" m class:switch file: -__marker pythonutil/ordered_dict.py /^ __marker = object()$/;" v class:OrderedDict -__ne__ pythonutil/config.py /^ def __ne__(self,konfig):$/;" m class:Config file: -__ne__ pythonutil/ordered_dict.py /^ def __ne__(self, other):$/;" m class:OrderedDict file: -__reduce__ pythonutil/ordered_dict.py /^ def __reduce__(self):$/;" m class:OrderedDict file: -__repr__ pythonutil/config.py /^ def __repr__(self):$/;" m class:Config file: -__repr__ pythonutil/ordered_bunch.py /^ def __repr__(self):$/;" m class:OrderedBunch file: -__repr__ pythonutil/ordered_dict.py /^ def __repr__(self, _repr_running={}):$/;" m class:OrderedDict file: -__reversed__ pythonutil/ordered_dict.py /^ def __reversed__(self):$/;" m class:OrderedDict file: -__setattr__ pythonutil/ordered_bunch.py /^ def __setattr__(self, k, v):$/;" m class:OrderedBunch file: -__setitem__ pythonutil/ordered_dict.py /^ def __setitem__(self, key, value, dict_setitem=dict.__setitem__):$/;" m class:OrderedDict file: -__str__ pythonutil/config.py /^ def __str__(self):$/;" m class:Config file: -__str__ pythonutil/ordered_bunch.py /^ def __str__(self):$/;" m class:OrderedBunch file: -__update pythonutil/ordered_dict.py /^ __update = update # let subclasses override update without breaking __init__$/;" v class:OrderedDict -_braid_AccessStatus_struct xbraid/braid/_braid_status.h /^struct _braid_AccessStatus_struct$/;" s -_braid_Action xbraid/braid/_braid_tape.h /^} _braid_Action;$/;" t typeref:struct:_braid_Action_struct -_braid_Action_struct xbraid/braid/_braid_tape.h /^typedef struct _braid_Action_struct$/;" s -_braid_BaseVector_struct xbraid/braid/_braid.h /^struct _braid_BaseVector_struct$/;" s -_braid_BufferStatus_struct xbraid/braid/_braid_status.h /^struct _braid_BufferStatus_struct$/;" s -_braid_CTAlloc xbraid/braid/braid_defs.h 96;" d -_braid_Call xbraid/braid/_braid_tape.h /^} _braid_Call;$/;" t typeref:enum:_braid_Call_enum -_braid_Call_enum xbraid/braid/_braid_tape.h /^typedef enum _braid_Call_enum$/;" g -_braid_CoarsenRefStatus_struct xbraid/braid/_braid_status.h /^struct _braid_CoarsenRefStatus_struct$/;" s -_braid_CommHandle xbraid/braid/_braid.h /^} _braid_CommHandle;$/;" t typeref:struct:__anon2 -_braid_CommHandleElt xbraid/braid/_braid.h 307;" d -_braid_Core xbraid/braid/_braid.h /^} _braid_Core;$/;" t typeref:struct:_braid_Core_struct -_braid_CoreElt xbraid/braid/_braid.h 317;" d -_braid_CoreFcn xbraid/braid/_braid.h 322;" d -_braid_Core_struct xbraid/braid/_braid.h /^typedef struct _braid_Core_struct$/;" s -_braid_Error xbraid/braid/braid_defs.h 80;" d -_braid_ErrorInArg xbraid/braid/braid_defs.h 81;" d -_braid_Grid xbraid/braid/_braid.h /^} _braid_Grid;$/;" t typeref:struct:__anon3 -_braid_GridElt xbraid/braid/_braid.h 312;" d -_braid_HEADER xbraid/braid/_braid.h 32;" d -_braid_IsCPoint xbraid/braid/_braid.h 360;" d -_braid_IsFPoint xbraid/braid/_braid.h 354;" d -_braid_MapCoarseToFine xbraid/braid/_braid.h 348;" d -_braid_MapFineToCoarse xbraid/braid/_braid.h 341;" d -_braid_NextCPoint xbraid/braid/_braid.h 366;" d -_braid_ObjectiveStatus_struct xbraid/braid/_braid_status.h /^struct _braid_ObjectiveStatus_struct$/;" s -_braid_Optimization_struct xbraid/braid/_braid.h /^struct _braid_Optimization_struct$/;" s -_braid_PriorCPoint xbraid/braid/_braid.h 372;" d -_braid_Status xbraid/braid/_braid_status.h /^typedef struct _braid_Status_struct _braid_Status;$/;" t typeref:struct:_braid_Status_struct -_braid_StatusElt xbraid/braid/_braid_status.h 84;" d -_braid_Status_struct xbraid/braid/_braid_status.h /^struct _braid_Status_struct$/;" s -_braid_StepStatus_struct xbraid/braid/_braid_status.h /^struct _braid_StepStatus_struct$/;" s -_braid_TAlloc xbraid/braid/braid_defs.h 90;" d -_braid_TFree xbraid/braid/braid_defs.h 108;" d -_braid_TReAlloc xbraid/braid/braid_defs.h 102;" d -_braid_Tape xbraid/braid/_braid_tape.h /^} _braid_Tape;$/;" t typeref:struct:_braid_tape_struct -_braid_VectorBar_struct xbraid/braid/_braid.h /^struct _braid_VectorBar_struct$/;" s -_braid_base_HEADER xbraid/braid/_braid_base.h 40;" d -_braid_max xbraid/braid/braid_defs.h 116;" d -_braid_min xbraid/braid/braid_defs.h 119;" d -_braid_status_HEADER xbraid/braid/_braid_status.h 31;" d -_braid_tape_struct xbraid/braid/_braid_tape.h /^typedef struct _braid_tape_struct$/;" s -_filename pythonutil/config.py /^ _filename = 'config.cfg'$/;" v class:Config -_initialized pythonutil/ordered_bunch.py /^ _initialized = False$/;" v class:OrderedBunch -a xbraid/misc/user_utils/cycleplot.py /^ a = data[:,4].min()$/;" v -access xbraid/braid/_braid.h /^ braid_PtFcnAccess access; \/**< user access function to XBraid and current vector *\/$/;" m struct:_braid_Core_struct -access_level xbraid/braid/_braid.h /^ braid_Int access_level; \/**< determines how often to call the user's access routine *\/ $/;" m struct:_braid_Core_struct -access_level xbraid/drivers/braid_mfem.hpp /^ int access_level;$/;" m struct:BraidOptions -access_level xbraid/drivers/braid_mfem_block.hpp /^ int access_level;$/;" m struct:BraidOptions -access_level xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level, access_level,/;" v program:ex01_f90 -accuracy include/network.hpp /^ MyReal accuracy; \/* Accuracy of the network prediction (percentage of successfully predicted classes) *\/$/;" m class:Network -actionTape xbraid/braid/_braid.h /^ _braid_Tape* actionTape; \/**< tape storing the actions while recording *\/$/;" m struct:_braid_Core_struct -activ include/layer.hpp /^ int activ; \/* Activaation function (enum element) *\/$/;" m class:Layer -activation include/config.hpp /^ int activation;$/;" m class:Config -activation include/config.hpp /^enum activation{TANH, RELU, SMRELU}; $/;" g -adjoint xbraid/braid/_braid.h /^ braid_Int adjoint; \/**< determines if adjoint run is performed (1) or not (0) *\/$/;" m struct:_braid_Core_struct -adjoints xbraid/braid/_braid.h /^ braid_Vector *adjoints; \/**< vector for the adjoint variables *\/$/;" m struct:_braid_Optimization_struct -app xbraid/braid/_braid.h /^ braid_App app; \/**< application data for the user *\/$/;" m struct:_braid_Core_struct -app xbraid/examples/ex-01-expanded-f.f90 /^ type(my_app)/;" v program:ex01_f90 -arg xbraid/examples/ex-01-expanded-f.f90 /^ character (len = 255) arg$/;" v program:ex01_f90 -args testing/testing.py /^args = parser.parse_args()$/;" v -assemble_batch_script pythonutil/batch_job.py /^def assemble_batch_script(name, run_command, args):$/;" f -astatus xbraid/braid/braid.hpp /^ braid_AccessStatus astatus;$/;" m class:BraidAccessStatus -availIDs include/dataset.hpp /^ int* availIDs; \/* Auxilliary: holding available batchIDs when generating a batch *\/$/;" m class:DataSet -ax2 xbraid/misc/user_utils/cycleplot.py /^ ax2 = ax.twinx()$/;" v -bar xbraid/braid/_braid.h /^ braid_VectorBar bar; \/**< holds the bar vector (shared pointer implementation) *\/$/;" m struct:_braid_BaseVector_struct -barTape xbraid/braid/_braid.h /^ _braid_Tape* barTape; \/**< tape storing intermediate AD-bar variables while recording *\/$/;" m struct:_braid_Core_struct -batchIDs include/dataset.hpp /^ int *batchIDs; \/* Array of batch indicees *\/$/;" m class:DataSet -batch_args_mapping pythonutil/batch_job.py /^batch_args_mapping = batch_args_mapping_slurm$/;" v -batch_args_mapping_slurm pythonutil/batch_job.py /^batch_args_mapping_slurm = {"NAME" : "--job-name",$/;" v -batch_type include/config.hpp /^ int batch_type;$/;" m class:Config -batchtype include/config.hpp /^enum batchtype{DETERMINISTIC, STOCHASTIC};$/;" g -bias include/layer.hpp /^ MyReal* bias; \/* Bias *\/$/;" m class:Layer -bias_bar include/layer.hpp /^ MyReal* bias_bar; \/* Derivative of bias *\/$/;" m class:Layer -braidCall xbraid/braid/_braid_tape.h /^ _braid_Call braidCall; \/**< type of the user routine *\/$/;" m struct:_braid_Action_struct -braid_ASCaller_FAccess xbraid/braid/braid_status.h 525;" d -braid_ASCaller_FInterp xbraid/braid/braid_status.h 519;" d -braid_ASCaller_FRefine xbraid/braid/braid_status.h 523;" d -braid_ASCaller_FRestrict xbraid/braid/braid_status.h 521;" d -braid_AccessStatus xbraid/braid/braid_status.h /^typedef struct _braid_AccessStatus_struct *braid_AccessStatus;$/;" t typeref:struct:_braid_AccessStatus_struct -braid_Access_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Access_F90(/;" s -braid_App xbraid/braid/braid.h /^typedef struct _braid_App_struct *braid_App;$/;" t typeref:struct:_braid_App_struct -braid_BaseVector xbraid/braid/_braid.h /^typedef struct _braid_BaseVector_struct *braid_BaseVector;$/;" t typeref:struct:_braid_BaseVector_struct -braid_BufPack_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_BufPack_F90(/;" s -braid_BufSize_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_BufSize_F90(/;" s -braid_BufUnPack_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_BufUnPack_F90(/;" s -braid_BufferStatus xbraid/braid/braid_status.h /^typedef struct _braid_BufferStatus_struct *braid_BufferStatus;$/;" t typeref:struct:_braid_BufferStatus_struct -braid_Clone_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Clone_F90(/;" s -braid_CoarsenRefStatus xbraid/braid/braid_status.h /^typedef struct _braid_CoarsenRefStatus_struct *braid_CoarsenRefStatus;$/;" t typeref:struct:_braid_CoarsenRefStatus_struct -braid_Core xbraid/braid/braid.h /^typedef struct _braid_Core_struct *braid_Core;$/;" t typeref:struct:_braid_Core_struct -braid_ERROR_ARG xbraid/braid/braid.h 86;" d -braid_ERROR_GENERIC xbraid/braid/braid.h 84;" d -braid_ERROR_MEMORY xbraid/braid/braid.h 85;" d -braid_FMANGLE xbraid/braid/braid.h 62;" d -braid_Fortran_Residual xbraid/braid/braid.h 66;" d -braid_Fortran_SpatialCoarsen xbraid/braid/braid.h 64;" d -braid_Fortran_TimeGrid xbraid/braid/braid.h 68;" d -braid_Free_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Free_F90(/;" s -braid_HEADER xbraid/braid/braid.h 32;" d -braid_INVALID_RNORM xbraid/braid/braid.h 82;" d -braid_Init_Vec_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Init_Vec_F90(/;" s -braid_Int xbraid/braid/braid_defs.h /^typedef int braid_Int;$/;" t -braid_Int_Max xbraid/braid/braid_defs.h 50;" d -braid_Int_Min xbraid/braid/braid_defs.h 51;" d -braid_MPI_INT xbraid/braid/braid_defs.h 67;" d -braid_MPI_REAL xbraid/braid/braid_defs.h 66;" d -braid_ObjectiveStatus xbraid/braid/braid_status.h /^typedef struct _braid_ObjectiveStatus_struct *braid_ObjectiveStatus;$/;" t typeref:struct:_braid_ObjectiveStatus_struct -braid_Optim xbraid/braid/_braid.h /^typedef struct _braid_Optimization_struct *braid_Optim;$/;" t typeref:struct:_braid_Optimization_struct -braid_PtFcnAccess xbraid/braid/braid.h /^(*braid_PtFcnAccess)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnBufPack xbraid/braid/braid.h /^(*braid_PtFcnBufPack)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnBufSize xbraid/braid/braid.h /^(*braid_PtFcnBufSize)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnBufUnpack xbraid/braid/braid.h /^(*braid_PtFcnBufUnpack)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnClone xbraid/braid/braid.h /^(*braid_PtFcnClone)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnFree xbraid/braid/braid.h /^(*braid_PtFcnFree)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnInit xbraid/braid/braid.h /^(*braid_PtFcnInit)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnObjectiveT xbraid/braid/braid.h /^(*braid_PtFcnObjectiveT)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnObjectiveTDiff xbraid/braid/braid.h /^(*braid_PtFcnObjectiveTDiff)(braid_App app, \/**< input \/ output: user-defined _braid_App structure, used to store gradient *\/$/;" t -braid_PtFcnPostprocessObjective xbraid/braid/braid.h /^(*braid_PtFcnPostprocessObjective)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnPostprocessObjective_diff xbraid/braid/braid.h /^(*braid_PtFcnPostprocessObjective_diff)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnResetGradient xbraid/braid/braid.h /^(*braid_PtFcnResetGradient)(braid_App app \/**< output: user-defined _braid_App structure, used to store gradient *\/$/;" t -braid_PtFcnResidual xbraid/braid/braid.h /^(*braid_PtFcnResidual)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnSClone xbraid/braid/braid.h /^(*braid_PtFcnSClone)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnSCoarsen xbraid/braid/braid.h /^(*braid_PtFcnSCoarsen)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnSFree xbraid/braid/braid.h /^(*braid_PtFcnSFree)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnSInit xbraid/braid/braid.h /^(*braid_PtFcnSInit)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnSRefine xbraid/braid/braid.h /^(*braid_PtFcnSRefine)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnSpatialNorm xbraid/braid/braid.h /^(*braid_PtFcnSpatialNorm)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnStep xbraid/braid/braid.h /^(*braid_PtFcnStep)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnStepDiff xbraid/braid/braid.h /^(*braid_PtFcnStepDiff)(braid_App app, \/**< input \/ output: user-defined _braid_App structure, used to store gradient *\/$/;" t -braid_PtFcnSum xbraid/braid/braid.h /^(*braid_PtFcnSum)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_PtFcnTimeGrid xbraid/braid/braid.h /^(*braid_PtFcnTimeGrid)(braid_App app, \/**< user-defined _braid_App structure *\/$/;" t -braid_RAND_MAX xbraid/braid/braid_defs.h 129;" d -braid_Real xbraid/braid/braid_defs.h /^typedef double braid_Real;$/;" t -braid_Residual_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Residual_F90(/;" s -braid_SpatialNorm_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_SpatialNorm_F90(/;" s -braid_Status xbraid/braid/braid_status.h /^typedef struct _braid_Status_struct *braid_Status;$/;" t typeref:struct:_braid_Status_struct -braid_StepStatus xbraid/braid/braid_status.h /^typedef struct _braid_StepStatus_struct *braid_StepStatus;$/;" t typeref:struct:_braid_StepStatus_struct -braid_Step_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Step_F90(/;" s -braid_Sum_F90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_Sum_F90(/;" s -braid_Vector xbraid/braid/braid.h /^typedef struct _braid_Vector_struct *braid_Vector;$/;" t typeref:struct:_braid_Vector_struct -braid_VectorBar xbraid/braid/_braid.h /^typedef struct _braid_VectorBar_struct *braid_VectorBar;$/;" t typeref:struct:_braid_VectorBar_struct -braid_abstol include/config.hpp /^ MyReal braid_abstol;$/;" m class:Config -braid_abstoladj include/config.hpp /^ MyReal braid_abstoladj;$/;" m class:Config -braid_accesslevel include/config.hpp /^ int braid_accesslevel;$/;" m class:Config -braid_cfactor include/config.hpp /^ int braid_cfactor;$/;" m class:Config -braid_cfactor0 include/config.hpp /^ int braid_cfactor0; $/;" m class:Config -braid_core xbraid/examples/ex-01-expanded-f.f90 /^ integer (kind=8) :: braid_core$/;" v module:braid_types -braid_fmg include/config.hpp /^ int braid_fmg;$/;" m class:Config -braid_hpp_HEADER xbraid/braid/braid.hpp 23;" d -braid_hypre_extra_HEADER xbraid/drivers/hypre_extra.hpp 23;" d -braid_isnan xbraid/braid/braid_defs.h 122;" d -braid_iter xbraid/braid/_braid_tape.h /^ braid_Int braid_iter; \/**< iteration number of xBraid *\/$/;" m struct:_braid_Action_struct -braid_iter xbraid/drivers/braid_mfem_block.hpp /^ int braid_iter;$/;" m class:MFEMBraidApp -braid_maxiter include/config.hpp /^ int braid_maxiter;$/;" m class:Config -braid_maxlevels include/config.hpp /^ int braid_maxlevels;$/;" m class:Config -braid_maxlevelslist testing/testing.py /^braid_maxlevelslist = args.maxlevels$/;" v -braid_mfem_HEADER xbraid/drivers/braid_mfem.hpp 23;" d -braid_mfem_HEADER xbraid/drivers/braid_mfem_block.hpp 23;" d -braid_mincoarse include/config.hpp /^ int braid_mincoarse;$/;" m class:Config -braid_nrelax include/config.hpp /^ int braid_nrelax;$/;" m class:Config -braid_nrelax0 include/config.hpp /^ int braid_nrelax0;$/;" m class:Config -braid_printlevel include/config.hpp /^ int braid_printlevel;$/;" m class:Config -braid_setskip include/config.hpp /^ int braid_setskip;$/;" m class:Config -braid_status_HEADER xbraid/braid/braid_status.h 32;" d -braid_tape_HEADER xbraid/braid/_braid_tape.h 8;" d -braid_test_HEADER xbraid/braid/braid_test.h 33;" d -braid_timegrid_f90 xbraid/examples/ex-01-expanded-f.f90 /^subroutine braid_timegrid_f90(/;" s -braid_types xbraid/examples/ex-01-expanded-f.f90 /^module braid_types$/;" m -braid_util_HEADER xbraid/braid/_util.h 34;" d -braiddefs_HEADER xbraid/braid/braid_defs.h 31;" d -bstatus xbraid/braid/braid.hpp /^ braid_BufferStatus bstatus;$/;" m class:BraidBufferStatus -buff_size xbraid/drivers/braid_mfem.hpp /^ Array buff_size;$/;" m class:MFEMBraidApp -buff_size xbraid/drivers/braid_mfem_block.hpp /^ Array buff_size;$/;" m class:MFEMBraidApp -buffer xbraid/braid/_braid.h /^ void *buffer; \/**< Buffer for message *\/$/;" m struct:__anon2 -bufpack xbraid/braid/_braid.h /^ braid_PtFcnBufPack bufpack; \/**< pack a buffer *\/$/;" m struct:_braid_Core_struct -bufsize xbraid/braid/_braid.h /^ braid_PtFcnBufSize bufsize; \/**< return buffer size *\/$/;" m struct:_braid_Core_struct -bufunpack xbraid/braid/_braid.h /^ braid_PtFcnBufUnpack bufunpack; \/**< unpack a buffer *\/$/;" m struct:_braid_Core_struct -c_tprior xbraid/braid/_braid.h /^ braid_Real c_tprior; \/**< time value to the left of tstart on coarse grid *\/$/;" m struct:_braid_Core_struct -c_tstop xbraid/braid/_braid.h /^ braid_Real c_tstop; \/**< time value to the right of tstart on coarse grid *\/$/;" m struct:_braid_Core_struct -calling_function xbraid/braid/_braid.h /^ braid_Int calling_function; \/**< from which function are we accessing the vector *\/$/;" m struct:_braid_Core_struct -case testing/testing.py /^case = args.case$/;" v -cfactor xbraid/braid/_braid.h /^ braid_Int cfactor; \/**< coarsening factor *\/$/;" m struct:__anon3 -cfactor xbraid/drivers/braid_mfem.hpp /^ int cfactor;$/;" m struct:BraidOptions -cfactor xbraid/drivers/braid_mfem_block.hpp /^ int cfactor;$/;" m struct:BraidOptions -cfactor xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax, nrelax0, cfactor,/;" v program:ex01_f90 -cfactor0 xbraid/drivers/braid_mfem.hpp /^ int cfactor0;$/;" m struct:BraidOptions -cfactor0 xbraid/drivers/braid_mfem_block.hpp /^ int cfactor0;$/;" m struct:BraidOptions -cfactor0 xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax, nrelax0, cfactor, cfactor0$/;" v program:ex01_f90 -cfactors xbraid/braid/_braid.h /^ braid_Int *cfactors; \/**< coarsening factors *\/$/;" m struct:_braid_Core_struct -cfdefault xbraid/braid/_braid.h /^ braid_Int cfdefault; \/**< default coarsening factor *\/$/;" m struct:_braid_Core_struct -clear pythonutil/ordered_dict.py /^ def clear(self):$/;" m class:OrderedDict -clone xbraid/braid/_braid.h /^ braid_PtFcnClone clone; \/**< clone a vector *\/$/;" m struct:_braid_Core_struct -clone xbraid/drivers/braid_mfem.hpp /^ BraidVector *clone()$/;" f class:BraidVector -clone xbraid/drivers/braid_mfem_block.hpp /^ BraidVector *clone()$/;" f class:BraidVector -clower xbraid/braid/_braid.h /^ braid_Int clower; \/**< smallest C point index *\/$/;" m struct:__anon3 -comm include/network.hpp /^ MPI_Comm comm; \/* MPI communicator *\/$/;" m class:Network -comm xbraid/braid/_braid.h /^ MPI_Comm comm; \/**< communicator for the time dimension *\/$/;" m struct:_braid_Core_struct -comm xbraid/drivers/mfem_arnoldi.hpp /^ MPI_Comm comm;$/;" m class:Arnoldi -comm xbraid/examples/ex-01-expanded-f.f90 /^ integer :: comm$/;" k type:my_app -comm_t xbraid/braid/braid.hpp /^ MPI_Comm comm_t;$/;" m class:BraidApp -comm_world xbraid/braid/_braid.h /^ MPI_Comm comm_world;$/;" m struct:_braid_Core_struct -comparefiles pythonutil/util.py /^def comparefiles(refname, testname):$/;" f -config testing/testing.py /^config = Config(case + ".cfg")$/;" v -config_option include/config.hpp /^ struct config_option {$/;" s class:Config -configfile examples/mnist/mnist_runs/submit_paramstudy.py /^configfile = Config("config.cfg")$/;" v -configfile pythonutil/submit_paramstudy.py /^configfile = Config("config.cfg")$/;" v -copy pythonutil/ordered_dict.py /^ def copy(self):$/;" m class:OrderedDict -core include/braid_wrapper.hpp /^ BraidCore* core; \/* Braid core for running PinT simulation *\/$/;" m class:myBraidApp -core xbraid/braid/_braid_status.h /^ _braid_Core core;$/;" m struct:_braid_Status_struct -core xbraid/braid/_braid_tape.h /^ braid_Core core; \/**< pointer to braid's core structure *\/$/;" m struct:_braid_Action_struct -core xbraid/braid/braid.hpp /^ braid_Core core;$/;" m class:BraidCore -csize include/layer.hpp /^ int csize;$/;" m class:Layer -csize2 include/layer.hpp /^ int csize2;$/;" m class:ConvLayer -cstatus xbraid/braid/braid.hpp /^ braid_CoarsenRefStatus cstatus;$/;" m class:BraidCoarsenRefStatus -cupper xbraid/braid/_braid.h /^ braid_Int cupper; \/**< largest C point index *\/$/;" m struct:__anon3 -current_lvl xbraid/misc/user_utils/cycleplot.py /^ current_lvl = 0$/;" v -current_lvl xbraid/misc/user_utils/cycleplot.py /^ current_lvl = data[-1,0]$/;" v -current_rank xbraid/examples/viz-ex-02.py /^ current_rank = current_rank + 1$/;" v -current_rank xbraid/examples/viz-ex-02.py /^current_rank = 0$/;" v -current_rank xbraid/examples/viz-ex-04.py /^ current_rank = current_rank + 1$/;" v -current_rank xbraid/examples/viz-ex-04.py /^ current_rank = 0$/;" v -cycleplot xbraid/misc/user_utils/cycleplot.m /^function cycleplot(filename);$/;" f -data include/braid_wrapper.hpp /^ DataSet* data; \/* Pointer to the Data set *\/$/;" m class:myBraidApp -data xbraid/drivers/viz-burgers-1D.py /^data = loadtxt(fname)$/;" v -data xbraid/drivers/viz-burgers-1D.py /^data = zeros((nsteps,data.shape[0]-6))$/;" v -data xbraid/drivers/viz-lorenz.py /^data = numpy.loadtxt('drive-lorenz.out')$/;" v -data xbraid/examples/viz-ex-02.py /^data = loadtxt(fname)$/;" v -data xbraid/examples/viz-ex-02.py /^data = zeros((nsteps,data.shape[0]-6))$/;" v -data xbraid/misc/user_utils/cycleplot.py /^ data = loadtxt(fname)$/;" v -data_ptr xbraid/braid/_braid_tape.h /^ void *data_ptr;$/;" m struct:_braid_tape_struct -datafolder examples/mnist/mnist_runs/submit_paramstudy.py /^datafolder = "data"$/;" v -datafolder include/config.hpp /^ const char* datafolder; $/;" m class:Config -datafolder pythonutil/submit_paramstudy.py /^datafolder = "data"$/;" v -datafolder testing/testing.py /^ datafolder = "..\/" + config.datafolder$/;" v -default_batch_args pythonutil/batch_job.py /^default_batch_args = {batch_args_mapping["NAME"] : "default",$/;" v -design include/network.hpp /^ MyReal* design; \/* Local vector of design variables*\/$/;" m class:Network -design xbraid/examples/viz-ex-04.py /^design = loadtxt('ex-04.out.design')$/;" v -design_old include/hessianApprox.hpp /^ MyReal* design_old; \/* Design at previous iteration *\/$/;" m class:L_BFGS -design_old include/hessianApprox.hpp /^ MyReal* design_old; \/* Design at previous iteration *\/$/;" m class:BFGS -dimN include/hessianApprox.hpp /^ int dimN; \/* Dimension of the gradient vector *\/$/;" m class:HessianApprox -dim_Bias include/layer.hpp /^ int dim_Bias; \/* Dimension of the bias vector *\/$/;" m class:Layer -dim_In include/layer.hpp /^ int dim_In; \/* Dimension of incoming data *\/$/;" m class:Layer -dim_Out include/layer.hpp /^ int dim_Out; \/* Dimension of outgoing data *\/$/;" m class:Layer -done xbraid/braid/_braid.h /^ braid_Int done; \/**< boolean describing whether XBraid has finished *\/$/;" m struct:_braid_Core_struct -dr xbraid/misc/user_utils/cycleplot.py /^ dr = r[:-1] - r[1:]$/;" v -dt include/layer.hpp /^ MyReal dt; \/* Step size for Layer update *\/$/;" m class:Layer -dt include/network.hpp /^ MyReal dt; \/* Time step size *\/$/;" m class:Network -dt xbraid/examples/ex-01-expanded-f.f90 /^ double precision, allocatable :: dt(/;" k type:my_app -dump pythonutil/config.py /^ def dump(self,filename=''):$/;" m class:Config -dump_config pythonutil/config.py /^def dump_config(filename,config):$/;" f -endlayerID include/network.hpp /^ int endlayerID; \/* ID of the last layer on that processor *\/$/;" m class:Network -err testing/testing.py /^ err = comparefiles(refname, testfoldername + "\/" + outfile)$/;" v -ex01_f90 xbraid/examples/ex-01-expanded-f.f90 /^program ex01_f90$/;" p -exact_sol xbraid/drivers/braid_mfem.hpp /^ Coefficient *exact_sol;$/;" m class:MFEMBraidApp -exact_sol xbraid/drivers/braid_mfem_block.hpp /^ Coefficient *exact_sol;$/;" m class:MFEMBraidApp -example include/layer.hpp /^ MyReal* example; \/* Pointer to the current example data *\/$/;" m class:OpenExpandZero -example include/layer.hpp /^ MyReal* example; \/* Pointer to the current example data *\/$/;" m class:OpenConvLayer -example include/layer.hpp /^ MyReal* example; \/* Pointer to the current example data *\/$/;" m class:OpenDenseLayer -examples include/dataset.hpp /^ MyReal **examples; \/* Array of Feature vectors (dim: nelements x nfeatures) *\/$/;" m class:DataSet -f_bar xbraid/braid/_braid.h /^ braid_Real f_bar; \/**< contains the seed for tape evaluation *\/$/;" m struct:_braid_Optimization_struct -f_tprior xbraid/braid/_braid.h /^ braid_Real f_tprior; \/**< time value to the left of tstart on fine grid *\/$/;" m struct:_braid_Core_struct -f_tstop xbraid/braid/_braid.h /^ braid_Real f_tstop; \/**< time value to the right of tstart on fine grid *\/$/;" m struct:_braid_Core_struct -fa xbraid/braid/_braid.h /^ braid_BaseVector *fa; \/**< rhs vectors f (all points, NULL on level 0) *\/$/;" m struct:__anon3 -fa_alloc xbraid/braid/_braid.h /^ braid_BaseVector *fa_alloc; \/**< original memory allocation for fa *\/$/;" m struct:__anon3 -fcsize include/layer.hpp /^ int fcsize;$/;" m class:ConvLayer -fe_space xbraid/drivers/braid_mfem.hpp /^ Array fe_space;$/;" m class:MFEMBraidApp -fe_space xbraid/drivers/braid_mfem_block.hpp /^ Array fe_space;$/;" m class:MFEMBraidApp -fig_size xbraid/misc/user_utils/cycleplot.py /^ fig_size = [niter*1.7, nlevels*1.0]$/;" v -file_stem xbraid/drivers/viz-burgers-1D.py /^file_stem = 'drive-burgers-1D.out.'$/;" v -file_stem xbraid/examples/viz-ex-02.py /^file_stem = 'ex-02.out.'$/;" v -file_stem xbraid/examples/viz-ex-04.py /^ file_stem = "ex-04.out."$/;" v -fmg xbraid/braid/_braid.h /^ braid_Int fmg; \/**< use FMG cycle *\/$/;" m struct:_braid_Core_struct -fmg xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg,/;" v program:ex01_f90 -fname xbraid/drivers/viz-burgers-1D.py /^ fname = file_stem + "%07d"%step + '.' + "%05d"%rank$/;" v -fname xbraid/drivers/viz-burgers-1D.py /^fname = file_stem + "%07d"%step + '.' + "%05d"%rank$/;" v -fname xbraid/examples/viz-ex-02.py /^ fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank$/;" v -fname xbraid/examples/viz-ex-02.py /^fname = file_stem + "%07d"%step + '.' + "%05d"%current_rank$/;" v -fname xbraid/examples/viz-ex-04.py /^ fname = file_stem + "%04d"%step + '.' + "%03d"%current_rank$/;" v -fname xbraid/misc/user_utils/cycleplot.py /^ fname = "braid.out.cycle"$/;" v -fontsize xbraid/misc/user_utils/cycleplot.py /^ fontsize = 22$/;" v -free xbraid/braid/_braid.h /^ braid_PtFcnFree free; \/**< free up a vector *\/$/;" m struct:_braid_Core_struct -fromOrderedDict pythonutil/ordered_bunch.py /^ def fromOrderedDict(d):$/;" m class:OrderedBunch -fromYAML pythonutil/ordered_bunch.py /^ def fromYAML(*args, **kwargs):$/;" f -from_yaml pythonutil/ordered_bunch.py /^ def from_yaml(loader, node):$/;" f -fromkeys pythonutil/ordered_dict.py /^ def fromkeys(cls, iterable, value=None):$/;" m class:OrderedDict -ftrain_ex include/config.hpp /^ const char* ftrain_ex;$/;" m class:Config -ftrain_labels include/config.hpp /^ const char* ftrain_labels;$/;" m class:Config -full_rnorm0 xbraid/braid/_braid.h /^ braid_Real full_rnorm0; \/**< (optional) initial full residual norm *\/$/;" m struct:_braid_Core_struct -full_rnorm_res xbraid/braid/_braid.h /^ braid_PtFcnResidual full_rnorm_res; \/**< (optional) used to compute full residual norm *\/$/;" m struct:_braid_Core_struct -full_rnorms xbraid/braid/_braid.h /^ braid_Real *full_rnorms; \/**< (optional) full residual norm history *\/$/;" m struct:_braid_Core_struct -fval_ex include/config.hpp /^ const char* fval_ex;$/;" m class:Config -fval_labels include/config.hpp /^ const char* fval_labels;$/;" m class:Config -gamma_class include/config.hpp /^ MyReal gamma_class;$/;" m class:Config -gamma_ddt include/config.hpp /^ MyReal gamma_ddt;$/;" m class:Config -gamma_ddt include/layer.hpp /^ MyReal gamma_ddt; \/* Parameter for DDT regularization of weights and bias *\/$/;" m class:Layer -gamma_tik include/config.hpp /^ MyReal gamma_tik;$/;" m class:Config -gamma_tik include/layer.hpp /^ MyReal gamma_tik; \/* Parameter for Tikhonov regularization of weights and bias *\/$/;" m class:Layer -gammaclass examples/mnist/mnist_runs/submit_paramstudy.py /^gammaclass = [1e-1,1e-3,1e-5]$/;" v -gammaclass pythonutil/submit_paramstudy.py /^gammaclass = [1e-1, 1e-5]$/;" v -gammaddt examples/mnist/mnist_runs/submit_paramstudy.py /^gammaddt = [1e-1,1e-3,1e-5]$/;" v -gammaddt pythonutil/submit_paramstudy.py /^gammaddt = [1e-5]$/;" v -gammatik examples/mnist/mnist_runs/submit_paramstudy.py /^gammatik = [1e-1,1e-3,1e-5]$/;" v -gammatik pythonutil/submit_paramstudy.py /^gammatik = [1e-5]$/;" v -globaltime xbraid/braid/_braid.h /^ braid_Real globaltime; \/**< global wall time for braid_Drive() *\/$/;" m struct:_braid_Core_struct -gradient include/network.hpp /^ MyReal* gradient; \/* Local Gradient *\/$/;" m class:Network -gradient_old include/hessianApprox.hpp /^ MyReal* gradient_old; \/* Gradient at previous iteration *\/$/;" m class:L_BFGS -gradient_old include/hessianApprox.hpp /^ MyReal* gradient_old; \/* Gradient at previous iteration *\/$/;" m class:BFGS -grids xbraid/braid/_braid.h /^ _braid_Grid **grids; \/**< pointer to temporal grid structures for each level*\/$/;" m struct:_braid_Core_struct -gtol include/config.hpp /^ MyReal gtol;$/;" m class:Config -guess xbraid/drivers/braid_mfem_block.hpp /^ BlockVector *guess; $/;" m class:MFEMBraidApp -gupper xbraid/braid/_braid.h /^ braid_Int gupper; \/**< global size of the fine grid *\/$/;" m struct:_braid_Core_struct -gupper xbraid/braid/_braid.h /^ braid_Int gupper; \/**< global size of the grid *\/$/;" m struct:__anon3 -gupper xbraid/braid/_braid_tape.h /^ braid_Int gupper; \/**< global size of the fine grid *\/$/;" m struct:_braid_Action_struct -hessianapprox_type include/config.hpp /^ int hessianapprox_type;$/;" m class:Config -hessiantype include/config.hpp /^enum hessiantype{BFGS_SERIAL, LBFGS, IDENTITY};$/;" g -hypre xbraid/drivers/hypre_extra.hpp /^namespace hypre$/;" n -hypre_CSRMatrixSetConstantValues xbraid/drivers/hypre_extra.hpp /^ hypre_CSRMatrixSetConstantValues( hypre_CSRMatrix *A,$/;" f namespace:hypre -hypre_CSRMatrixSum xbraid/drivers/hypre_extra.hpp /^ hypre_CSRMatrixSum( hypre_CSRMatrix *A,$/;" f namespace:hypre -hypre_ParCSRMatrixAdd xbraid/drivers/hypre_extra.hpp /^ hypre_ParCSRMatrixAdd( hypre_ParCSRMatrix *A,$/;" f namespace:hypre -hypre_ParCSRMatrixSetConstantValues xbraid/drivers/hypre_extra.hpp /^ hypre_ParCSRMatrixSetConstantValues( hypre_ParCSRMatrix *A,$/;" f namespace:hypre -hypre_ParCSRMatrixSum xbraid/drivers/hypre_extra.hpp /^ hypre_ParCSRMatrixSum( hypre_ParCSRMatrix *A,$/;" f namespace:hypre -i xbraid/examples/ex-01-expanded-f.f90 /^ in/;" v program:ex01_f90 -idx xbraid/braid/_braid.h /^ braid_Int idx; \/**< time point index value corresponding to t on the global time grid *\/$/;" m struct:_braid_Core_struct -ierr xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr,/;" v program:ex01_f90 -ilower xbraid/braid/_braid.h /^ braid_Int ilower; \/**< smallest time index at this level*\/$/;" m struct:__anon3 -img_size include/layer.hpp /^ int img_size;$/;" m class:ConvLayer -img_size_sqrt include/layer.hpp /^ int img_size_sqrt;$/;" m class:ConvLayer -inTime xbraid/braid/_braid_tape.h /^ braid_Real inTime; \/**< time of the input vector *\/$/;" m struct:_braid_Action_struct -inTimeIdx xbraid/braid/_braid_tape.h /^ braid_Int inTimeIdx; \/**< index of time of input vector *\/$/;" m struct:_braid_Action_struct -index include/layer.hpp /^ int index; \/* Number of the layer *\/$/;" m class:Layer -inf pythonutil/config.py /^inf = 1.0e20$/;" v -init xbraid/braid/_braid.h /^ braid_PtFcnInit init; \/**< return an initialized braid_BaseVector *\/$/;" m struct:_braid_Core_struct -init_rand xbraid/drivers/braid_mfem.hpp /^ bool init_rand; \/* If true, use std::rand() to initialize BraidVectors in$/;" m class:MFEMBraidApp -init_timesteps xbraid/examples/ex-01-expanded-f.f90 /^subroutine init_timesteps(/;" s -interactive xbraid/misc/user_utils/cycleplot.py /^ interactive = 0$/;" v -interactive xbraid/misc/user_utils/cycleplot.py /^ interactive = float(argv[1])$/;" v -io_level xbraid/braid/_braid.h /^ braid_Int io_level; \/**< determines amount of output printed to files (0,1) *\/$/;" m struct:_braid_Core_struct -items pythonutil/ordered_dict.py /^ def items(self):$/;" m class:OrderedDict -iteritems pythonutil/ordered_dict.py /^ def iteritems(self):$/;" m class:OrderedDict -iterkeys pythonutil/ordered_dict.py /^ def iterkeys(self):$/;" m class:OrderedDict -itervalues pythonutil/ordered_dict.py /^ def itervalues(self):$/;" m class:OrderedDict -iupper xbraid/braid/_braid.h /^ braid_Int iupper; \/**< largest time index at this level*\/$/;" m struct:__anon3 -jobname examples/mnist/mnist_runs/submit_paramstudy.py /^ "-class" + str(konfig.gamma_class)$/;" v -jobname pythonutil/submit_paramstudy.py /^ "class" + str(konfig.gamma_class)$/;" v -k_max xbraid/drivers/mfem_arnoldi.hpp /^ int k_max;$/;" m class:Arnoldi -key include/config.hpp /^ char key[CONFIG_ARG_MAX_BYTES];$/;" m struct:Config::config_option -keys pythonutil/ordered_dict.py /^ def keys(self):$/;" m class:OrderedDict -konfig examples/mnist/mnist_runs/submit_paramstudy.py /^ konfig = copy.deepcopy(configfile)$/;" v -konfig pythonutil/submit_paramstudy.py /^ konfig = copy.deepcopy(configfile)$/;" v -konfig testing/testing.py /^ konfig = copy.deepcopy(config)$/;" v -label include/layer.hpp /^ MyReal* label; \/* Pointer to the current label vector *\/$/;" m class:ClassificationLayer -labels include/dataset.hpp /^ MyReal **labels; \/* Array of Label vectors (dim: nelements x nlabels) *\/$/;" m class:DataSet -layer include/braid_wrapper.hpp /^ Layer* layer; \/* Pointer to layer information *\/$/;" m class:myBraidVector -layer_left include/network.hpp /^ Layer* layer_left; \/* Copy of last layer of left-neighbouring processor *\/$/;" m class:Network -layer_right include/network.hpp /^ Layer* layer_right; \/* Copy of first layer of right-neighbouring processor *\/$/;" m class:Network -layers include/network.hpp /^ Layer** layers; \/* Array of hidden layers (includes classification layer at last processor *\/$/;" m class:Network -layertype include/layer.hpp /^ enum layertype{OPENZERO=0, OPENDENSE=1, DENSE=2, CLASSIFICATION=3, OPENCONV=4, OPENCONVMNIST=5, CONVOLUTION=6};$/;" g class:Layer -lbfgs_stages include/config.hpp /^ int lbfgs_stages;$/;" m class:Config -level xbraid/braid/_braid.h /^ braid_Int level; \/**< Level that grid is on *\/$/;" m struct:__anon3 -level xbraid/braid/_braid.h /^ braid_Int level; \/**< current level in XBraid*\/$/;" m struct:_braid_Core_struct -level xbraid/braid/_braid_tape.h /^ braid_Int level; \/**< current level in Braid *\/$/;" m struct:_braid_Action_struct -level xbraid/drivers/braid_mfem.hpp /^ int level;$/;" m class:BraidVector -level xbraid/misc/user_utils/cycleplot.py /^ level = -level$/;" v -level xbraid/misc/user_utils/cycleplot.py /^ level = data[:,0] - data[:,1]$/;" v -localtime xbraid/braid/_braid.h /^ braid_Real localtime; \/**< local wall time for braid_Drive() *\/$/;" m struct:_braid_Core_struct -loss include/network.hpp /^ MyReal loss; \/* Value of the loss function *\/$/;" m class:Network -ls_factor include/config.hpp /^ MyReal ls_factor;$/;" m class:Config -ls_maxiter include/config.hpp /^ int ls_maxiter;$/;" m class:Config -ma xbraid/misc/user_utils/cycleplot.py /^ ma = r_to_print.max()$/;" v -make_link pythonutil/util.py /^def make_link(src,dst):$/;" f -match pythonutil/switch.py /^ def match(self, *args):$/;" m class:switch -maxBlocks xbraid/drivers/braid_mfem_block.hpp /^ static const int maxBlocks = 2;$/;" m class:MFEMBraidApp -max_dt xbraid/drivers/braid_mfem.hpp /^ Array max_dt; \/\/ maximal safe dt on each spatial mesh$/;" m class:MFEMBraidApp -max_dt xbraid/drivers/braid_mfem_block.hpp /^ Array max_dt; \/\/ maximal safe dt on each spatial mesh$/;" m class:MFEMBraidApp -max_iter xbraid/braid/_braid.h /^ braid_Int max_iter; \/**< maximum number of multigrid in time iterations *\/$/;" m struct:_braid_Core_struct -max_iter xbraid/drivers/braid_mfem.hpp /^ int max_iter;$/;" m struct:BraidOptions -max_iter xbraid/drivers/braid_mfem_block.hpp /^ int max_iter;$/;" m struct:BraidOptions -max_iter xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter,/;" v program:ex01_f90 -max_levels xbraid/braid/_braid.h /^ braid_Int max_levels; \/**< maximum number of temporal grid levels *\/$/;" m struct:_braid_Core_struct -max_levels xbraid/drivers/braid_mfem.hpp /^ int max_levels;$/;" m class:SpaceTimeMeshInfo -max_levels xbraid/drivers/braid_mfem.hpp /^ int max_levels;$/;" m struct:BraidOptions -max_levels xbraid/drivers/braid_mfem_block.hpp /^ int max_levels;$/;" m class:SpaceTimeMeshInfo -max_levels xbraid/drivers/braid_mfem_block.hpp /^ int max_levels;$/;" m struct:BraidOptions -max_levels xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels,/;" v program:ex01_f90 -max_refinements xbraid/braid/_braid.h /^ braid_Int max_refinements; \/**< maximum number of refinements *\/$/;" m struct:_braid_Core_struct -maxl xbraid/misc/user_utils/cycleplot.py /^ maxl = max(level)$/;" v -maxoptimiter include/config.hpp /^ int maxoptimiter;$/;" m class:Config -mesh xbraid/drivers/braid_mfem.hpp /^ Array mesh;$/;" m class:MFEMBraidApp -mesh xbraid/drivers/braid_mfem_block.hpp /^ Array mesh;$/;" m class:MFEMBraidApp -mesh xbraid/drivers/viz-burgers-1D.py /^mesh = linspace(xstart, xstop, nspace)$/;" v -mesh xbraid/examples/viz-ex-02.py /^mesh = linspace(xstart, xstop, nspace)$/;" v -mesh_file xbraid/drivers/braid_mfem.hpp /^ const char *mesh_file;$/;" m struct:BraidOptions -mesh_file xbraid/drivers/braid_mfem_block.hpp /^ const char *mesh_file;$/;" m struct:BraidOptions -mesh_table xbraid/drivers/braid_mfem.hpp /^ Array mesh_table;$/;" m class:SpaceTimeMeshInfo -mesh_table xbraid/drivers/braid_mfem_block.hpp /^ Array mesh_table;$/;" m class:SpaceTimeMeshInfo -mesh_table_global xbraid/drivers/braid_mfem.hpp /^ Array mesh_table_global;$/;" m class:SpaceTimeMeshInfo -mesh_table_global xbraid/drivers/braid_mfem_block.hpp /^ Array mesh_table_global;$/;" m class:SpaceTimeMeshInfo -messagetype xbraid/braid/_braid.h /^ braid_Int messagetype; \/**< message type, 0: for Step(), 1: for load balancing *\/$/;" m struct:_braid_Core_struct -messagetype xbraid/braid/_braid_tape.h /^ braid_Int messagetype; \/**< message type, 0: for Step(), 1: for load balancing *\/$/;" m struct:_braid_Action_struct -mfem xbraid/drivers/braid_mfem_block.hpp /^namespace mfem$/;" n -mfem_arnoldi_HEADER xbraid/drivers/mfem_arnoldi.hpp 2;" d -mi xbraid/misc/user_utils/cycleplot.py /^ mi = min( tols[tols>0].min()\/500., r_to_print.min())$/;" v -min_coarse xbraid/braid/_braid.h /^ braid_Int min_coarse; \/**< minimum possible coarse grid size *\/$/;" m struct:_braid_Core_struct -min_coarse xbraid/drivers/braid_mfem.hpp /^ int min_coarse;$/;" m struct:BraidOptions -min_coarse xbraid/drivers/braid_mfem_block.hpp /^ int min_coarse;$/;" m struct:BraidOptions -min_coarse xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse,/;" v program:ex01_f90 -minl xbraid/misc/user_utils/cycleplot.py /^ minl = maxl - nlevels$/;" v -myAdjointBraidApp include/braid_wrapper.hpp /^class myAdjointBraidApp : public myBraidApp$/;" c -myBraidApp include/braid_wrapper.hpp /^class myBraidApp : public BraidApp$/;" c -myBraidVector include/braid_wrapper.hpp /^class myBraidVector $/;" c -my_app xbraid/examples/ex-01-expanded-f.f90 /^ type my_app$/;" t module:braid_types -my_vector xbraid/examples/ex-01-expanded-f.f90 /^ type my_vector$/;" t module:braid_types -mydt xbraid/examples/ex-01-expanded-f.f90 /^ integer :: mydt$/;" k type:my_app -mydt xbraid/examples/ex-01-expanded-f.f90 /^ integer mydt,/;" v program:ex01_f90 -myid include/braid_wrapper.hpp /^ int myid; \/* Processor rank*\/$/;" m class:myBraidApp -myid xbraid/braid/_braid.h /^ braid_Int myid; \/**< my rank in the time communicator *\/$/;" m struct:_braid_Core_struct -myid xbraid/braid/_braid_tape.h /^ braid_Int myid; \/**< processors id *\/$/;" m struct:_braid_Action_struct -myid_world xbraid/braid/_braid.h /^ braid_Int myid_world; \/**< my rank in the world communicator *\/$/;" m struct:_braid_Core_struct -navail include/dataset.hpp /^ int navail; \/* Auxilliary: holding number of currently available batchIDs *\/$/;" m class:DataSet -nbatch include/braid_wrapper.hpp /^ int nbatch; \/* Number of examples *\/$/;" m class:myBraidVector -nbatch include/config.hpp /^ int nbatch;$/;" m class:Config -nbatch include/dataset.hpp /^ int nbatch; \/* Size of the batch *\/$/;" m class:DataSet -nchannels include/braid_wrapper.hpp /^ int nchannels; \/* Number of channels *\/$/;" m class:myBraidVector -nchannels include/config.hpp /^ int nchannels;$/;" m class:Config -nchannels include/network.hpp /^ int nchannels; \/* Width of the network *\/$/;" m class:Network -nclasses include/config.hpp /^ int nclasses;$/;" m class:Config -nconv include/layer.hpp /^ int nconv;$/;" m class:Layer -ncpoints xbraid/braid/_braid.h /^ braid_Int ncpoints; \/**< number of C points *\/$/;" m struct:__anon3 -ndesign include/layer.hpp /^ int ndesign; \/* Total number of design variables *\/$/;" m class:Layer -ndesign_global include/network.hpp /^ int ndesign_global; \/* Global number of design vars *\/$/;" m class:Network -ndesign_layermax include/network.hpp /^ int ndesign_layermax; \/* Max. number of design variables of all hidden layers *\/$/;" m class:Network -ndesign_local include/network.hpp /^ int ndesign_local; \/* Number of design vars of this local network block *\/$/;" m class:Network -nelements include/dataset.hpp /^ int nelements; \/* Number of data elements *\/$/;" m class:DataSet -network include/braid_wrapper.hpp /^ Network* network; \/* Pointer to the DNN Network Block (local layer storage) *\/$/;" m class:myBraidApp -networkType include/config.hpp /^enum networkType{DENSE, CONVOLUTIONAL}; $/;" g -network_type include/config.hpp /^ int network_type;$/;" m class:Config -new_iterations xbraid/misc/user_utils/cycleplot.py /^ new_iterations = (level == maxl).nonzero()[0]$/;" v -new_iterations xbraid/misc/user_utils/cycleplot.py /^ new_iterations = new_iterations[ ((new_iterations[1:] - new_iterations[:-1]) != 1).nonzero()[0] ]$/;" v -newconfigfile examples/mnist/mnist_runs/submit_paramstudy.py /^ newconfigfile = jobname + ".cfg"$/;" v -newconfigfile pythonutil/submit_paramstudy.py /^ newconfigfile = jobname + ".cfg"$/;" v -next xbraid/braid/_braid_tape.h /^ struct _braid_tape_struct *next;$/;" m struct:_braid_tape_struct typeref:struct:_braid_tape_struct::_braid_tape_struct -nfeatures include/config.hpp /^ int nfeatures;$/;" m class:Config -nfeatures include/dataset.hpp /^ int nfeatures; \/* Number of features per element *\/$/;" m class:DataSet -nfmg xbraid/braid/_braid.h /^ braid_Int nfmg; \/**< number of fmg cycles to do initially before switching to V-cycles *\/$/;" m struct:_braid_Core_struct -nfmg xbraid/drivers/braid_mfem_block.hpp /^ int nfmg;$/;" m struct:BraidOptions -nfmg_Vcyc xbraid/braid/_braid.h /^ braid_Int nfmg_Vcyc; \/**< number of V-cycle calls at each level in FMG *\/$/;" m struct:_braid_Core_struct -nfmg_Vcyc xbraid/drivers/braid_mfem.hpp /^ int nfmg_Vcyc;$/;" m struct:BraidOptions -nfmg_Vcyc xbraid/drivers/braid_mfem_block.hpp /^ int nfmg_Vcyc;$/;" m struct:BraidOptions -nfmg_Vcyc xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level, access_level, nfmg_Vcyc,/;" v program:ex01_f90 -niter xbraid/braid/_braid.h /^ braid_Int niter; \/**< number of iterations *\/$/;" m struct:_braid_Core_struct -niter xbraid/misc/user_utils/cycleplot.py /^ niter = data[:,2].max()$/;" v -niter xbraid/misc/user_utils/cycleplot.py /^ niter = max(niter_max, data[:,2].max())$/;" v -niter_max xbraid/misc/user_utils/cycleplot.py /^ niter_max = 12$/;" v -niter_max xbraid/misc/user_utils/cycleplot.py /^ niter_max = int(argv[2])$/;" v -nlabels include/dataset.hpp /^ int nlabels; \/* Number of different labels (i.e. classes) per element *\/$/;" m class:DataSet -nlayers include/config.hpp /^ int nlayers;$/;" m class:Config -nlayers_global include/network.hpp /^ int nlayers_global; \/* Total number of Layers of the network *\/$/;" m class:Network -nlayers_local include/network.hpp /^ int nlayers_local; \/* Number of Layers in this network block *\/$/;" m class:Network -nlevel_max xbraid/misc/user_utils/cycleplot.py /^ nlevel_max = 5$/;" v -nlevel_max xbraid/misc/user_utils/cycleplot.py /^ nlevel_max = int(argv[3])$/;" v -nlevels xbraid/braid/_braid.h /^ braid_Int nlevels; \/**< number of temporal grid levels *\/$/;" m struct:_braid_Core_struct -nlevels xbraid/misc/user_utils/cycleplot.py /^ nlevels = data[:,0].max() - data[:,0].min()$/;" v -nlevels xbraid/misc/user_utils/cycleplot.py /^ nlevels = max(nlevel_max, data[:,0].max() - data[:,0].min())$/;" v -npt examples/mnist/mnist_runs/submit_paramstudy.py /^npt = 2 # number of processors$/;" v -npt pythonutil/submit_paramstudy.py /^npt = 2 # number of processors$/;" v -nptlist testing/testing.py /^nptlist = args.nprocs$/;" v -nrdefault xbraid/braid/_braid.h /^ braid_Int nrdefault; \/**< default number of pre-relaxations *\/$/;" m struct:_braid_Core_struct -nrefine xbraid/braid/_braid.h /^ braid_Int nrefine; \/**< number of refinements done *\/$/;" m struct:_braid_Core_struct -nrefine xbraid/braid/_braid_tape.h /^ braid_Int nrefine; \/**< number of refinements done *\/$/;" m struct:_braid_Action_struct -nrelax xbraid/drivers/braid_mfem.hpp /^ int nrelax;$/;" m struct:BraidOptions -nrelax xbraid/drivers/braid_mfem_block.hpp /^ int nrelax;$/;" m struct:BraidOptions -nrelax xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax,/;" v program:ex01_f90 -nrelax0 xbraid/drivers/braid_mfem.hpp /^ int nrelax0;$/;" m struct:BraidOptions -nrelax0 xbraid/drivers/braid_mfem_block.hpp /^ int nrelax0;$/;" m struct:BraidOptions -nrelax0 xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc, max_levels, nrelax, nrelax0,/;" v program:ex01_f90 -nrels xbraid/braid/_braid.h /^ braid_Int *nrels; \/**< number of pre-relaxations on each level *\/$/;" m struct:_braid_Core_struct -nspace xbraid/drivers/viz-burgers-1D.py /^nspace = int(data[3])$/;" v -nspace xbraid/examples/viz-ex-02.py /^nspace = int(data[3])$/;" v -nsteps xbraid/drivers/viz-burgers-1D.py /^nsteps = int(data[0])$/;" v -nsteps xbraid/examples/viz-ex-02.py /^nsteps = int(data[0])$/;" v -nsteps xbraid/examples/viz-ex-04.py /^nsteps = design.shape[0]$/;" v -ntime xbraid/braid/_braid.h /^ braid_Int ntime; \/**< initial number of time intervals *\/$/;" m struct:_braid_Core_struct -ntime xbraid/braid/braid.hpp /^ braid_Int ntime;$/;" m class:BraidApp -ntime xbraid/examples/ex-01-expanded-f.f90 /^ integer :: ntime$/;" k type:my_app -ntime xbraid/examples/ex-01-expanded-f.f90 /^ integer mydt, ntime,/;" v program:ex01_f90 -ntraining include/config.hpp /^ int ntraining;$/;" m class:Config -num_procs_x xbraid/drivers/braid_mfem.hpp /^ int num_procs_x;$/;" m struct:BraidOptions -num_procs_x xbraid/drivers/braid_mfem_block.hpp /^ int num_procs_x;$/;" m struct:BraidOptions -num_requests xbraid/braid/_braid.h /^ braid_Int num_requests; \/**< number of active requests for this handle, usually 1 *\/$/;" m struct:__anon2 -num_time_steps xbraid/drivers/braid_mfem.hpp /^ int num_time_steps;$/;" m struct:BraidOptions -num_time_steps xbraid/drivers/braid_mfem_block.hpp /^ int num_time_steps;$/;" m struct:BraidOptions -numarg xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg, wrapper_tests, print_help, i, numarg$/;" v program:ex01_f90 -nupoints xbraid/braid/_braid.h /^ braid_Int nupoints; \/**< number of unknown vector points *\/$/;" m struct:__anon3 -nvalidation include/config.hpp /^ int nvalidation;$/;" m class:Config -nweights include/layer.hpp /^ int nweights; \/* Number of weights *\/$/;" m class:Layer -objT_diff xbraid/braid/_braid.h /^ braid_PtFcnObjectiveTDiff objT_diff; \/**< User function: apply differentiated objective function *\/$/;" m struct:_braid_Core_struct -obj_only xbraid/braid/_braid.h /^ braid_Int obj_only; \/**< determines if adjoint code computes ONLY objective, no gradients. *\/$/;" m struct:_braid_Core_struct -objective include/braid_wrapper.hpp /^ MyReal objective; \/* Objective function *\/$/;" m class:myBraidApp -objective xbraid/braid/_braid.h /^ braid_Real objective; \/**< global objective function value *\/$/;" m struct:_braid_Optimization_struct -objectiveT xbraid/braid/_braid.h /^ braid_PtFcnObjectiveT objectiveT; \/**< User function: evaluate objective function at time t *\/$/;" m struct:_braid_Core_struct -ode xbraid/drivers/braid_mfem.hpp /^ Array ode;$/;" m class:MFEMBraidApp -ode xbraid/drivers/braid_mfem_block.hpp /^ Array ode;$/;" m class:MFEMBraidApp -old_fine_tolx xbraid/braid/_braid.h /^ braid_Real old_fine_tolx; \/**< Allows for storing the previously used fine tolerance from GetSpatialAccuracy *\/$/;" m struct:_braid_Core_struct -openlayer include/network.hpp /^ Layer* openlayer; \/* At first processor: openinglayer, else: NULL *\/$/;" m class:Network -openlayer_type include/config.hpp /^ int openlayer_type;$/;" m class:Config -operator = xbraid/drivers/braid_mfem.hpp /^ BraidVector &operator=(const Vector &source_vector)$/;" f class:BraidVector -operator = xbraid/drivers/braid_mfem.hpp /^ BraidVector &operator=(double value)$/;" f class:BraidVector -operator = xbraid/drivers/braid_mfem_block.hpp /^ BraidVector &operator=(const BlockVector &source_vector)$/;" f class:BraidVector -optim xbraid/braid/_braid.h /^ braid_Optim optim; \/**< structure that stores optimization variables (objective function, etc.) *\/ $/;" m struct:_braid_Core_struct -ordered_bunchify pythonutil/ordered_bunch.py /^def ordered_bunchify(x):$/;" f -ordered_unbunchify pythonutil/ordered_bunch.py /^def ordered_unbunchify(x):$/;" f -outTime xbraid/braid/_braid_tape.h /^ braid_Real outTime; \/**< time of the output vector *\/$/;" m struct:_braid_Action_struct -outfile testing/testing.py /^outfile = "optim.dat"$/;" v -own_data xbraid/drivers/braid_mfem.hpp /^ bool own_data;$/;" m class:MFEMBraidApp -own_data xbraid/drivers/braid_mfem_block.hpp /^ bool own_data;$/;" m class:MFEMBraidApp -par_ref_levels xbraid/drivers/braid_mfem.hpp /^ int par_ref_levels;$/;" m struct:BraidOptions -par_ref_levels xbraid/drivers/braid_mfem_block.hpp /^ int par_ref_levels;$/;" m struct:BraidOptions -params xbraid/misc/user_utils/cycleplot.py /^ params = return_rcparams(fig_width=fig_size[0], fig_height=fig_size[1], fontfamily='serif', fontsize=fontsize)$/;" v -parser testing/testing.py /^parser = argparse.ArgumentParser()$/;" v -pop pythonutil/ordered_dict.py /^ def pop(self, key, default=__marker):$/;" m class:OrderedDict -popitem pythonutil/ordered_dict.py /^ def popitem(self, last=True):$/;" m class:OrderedDict -postprocess_obj xbraid/braid/_braid.h /^ braid_PtFcnPostprocessObjective postprocess_obj; \/**< Optional user function: Modify the time-averaged objective function, e.g. for inverse design problems, adding relaxation term etc. *\/$/;" m struct:_braid_Core_struct -postprocess_obj_diff xbraid/braid/_braid.h /^ braid_PtFcnPostprocessObjective_diff postprocess_obj_diff; \/**< Optional user function: Derivative of postprocessing function *\/$/;" m struct:_braid_Core_struct -prev include/config.hpp /^ struct config_option* prev;$/;" m struct:Config::config_option typeref:struct:Config::config_option::config_option -primalcore include/braid_wrapper.hpp /^ BraidCore* primalcore; \/* pointer to primal core for accessing primal states *\/$/;" m class:myAdjointBraidApp -print_help xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg, wrapper_tests, print_help,/;" v program:ex01_f90 -print_level xbraid/braid/_braid.h /^ braid_Int print_level; \/**< determines amount of output printed to screen (0,1,2,3) *\/$/;" m struct:_braid_Core_struct -print_level xbraid/drivers/braid_mfem.hpp /^ int print_level;$/;" m struct:BraidOptions -print_level xbraid/drivers/braid_mfem_block.hpp /^ int print_level;$/;" m struct:BraidOptions -print_level xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level,/;" v program:ex01_f90 -print_timegrid xbraid/examples/ex-01-expanded-f.f90 /^subroutine print_timegrid(/;" s -probability include/layer.hpp /^ MyReal* probability; \/* vector of pedicted class probabilities *\/$/;" m class:ClassificationLayer -pstatus xbraid/braid/braid.hpp /^ braid_StepStatus pstatus;$/;" m class:BraidStepStatus -r xbraid/misc/user_utils/cycleplot.py /^ r = data[:,4]$/;" v -r_indices xbraid/misc/user_utils/cycleplot.py /^ r_indices = setdiff1d((dr != 0).nonzero()[0], (r==0).nonzero()[0]-1) # x-locations to print$/;" v -r_level xbraid/misc/user_utils/cycleplot.py /^ r_level = level[r_indices] # corresponding level numbers$/;" v -r_space xbraid/braid/_braid.h /^ braid_Int r_space; \/**< spatial refinment flag *\/$/;" m struct:_braid_Core_struct -r_to_print xbraid/misc/user_utils/cycleplot.py /^ r_to_print = r[r_indices+1]$/;" v -rank xbraid/drivers/viz-burgers-1D.py /^rank = 0 #int(sys.argv[1])$/;" v -rank xbraid/examples/ex-01-expanded-f.f90 /^ integer :: rank$/;" k type:my_app -rank xbraid/examples/ex-01-expanded-f.f90 /^ integer mydt, ntime, rank$/;" v program:ex01_f90 -rc xbraid/examples/ex-01-expanded-f.f90 /^ integer ierr, rc,/;" v program:ex01_f90 -read pythonutil/config.py /^ def read(self,filename):$/;" m class:Config -read_config pythonutil/config.py /^def read_config(filename):$/;" f -record xbraid/braid/_braid.h /^ braid_Int record; \/**< determines if actions are recorded to the tape or not. This separate $/;" m struct:_braid_Core_struct -recv_handle xbraid/braid/_braid.h /^ _braid_CommHandle *recv_handle; \/**< Handle for nonblocking receives of braid_BaseVectors *\/$/;" m struct:__anon3 -recv_index xbraid/braid/_braid.h /^ braid_Int recv_index; \/**< -1 means no receive *\/$/;" m struct:__anon3 -refine xbraid/braid/_braid.h /^ braid_Int refine; \/**< refine in time (refine = 1) *\/$/;" m struct:_braid_Core_struct -refname testing/testing.py /^ refname = testname + "." + outfile $/;" v -replace xbraid/examples/ex-01-expanded-f.f90 /^subroutine replace(/;" s -request xbraid/braid/_braid.h /^ MPI_Request *request; \/**< helper: Storing the MPI request of BufUnPackDiff *\/$/;" m struct:_braid_Optimization_struct -request_type xbraid/braid/_braid.h /^ braid_Int request_type; \/**< two values: recv type = 1, and send type = 0 *\/$/;" m struct:__anon2 -requests xbraid/braid/_braid.h /^ MPI_Request *requests; \/**< MPI request structure *\/$/;" m struct:__anon2 -res xbraid/drivers/braid_mfem_block.hpp /^ int res;$/;" m struct:BraidOptions -res xbraid/examples/ex-01-expanded-f.f90 /^ integer min_coarse, print_level, access_level, nfmg_Vcyc, res$/;" v program:ex01_f90 -reset_gradient xbraid/braid/_braid.h /^ braid_PtFcnResetGradient reset_gradient; \/**< User function: Set the gradient to zero. Is called before each iteration *\/$/;" m struct:_braid_Core_struct -residual xbraid/braid/_braid.h /^ braid_PtFcnResidual residual; \/**< (optional) compute residual *\/$/;" m struct:_braid_Core_struct -return_rcparams xbraid/misc/user_utils/cycleplot.py /^def return_rcparams(fig_width=5, fig_height=5, fontsize=28, fontfamily='sans-serif'):$/;" f -reverted_ranks xbraid/braid/_braid.h /^ braid_Int reverted_ranks; $/;" m struct:_braid_Core_struct -rfactor xbraid/braid/_braid.h /^ braid_Int rfactor; \/**< if set by user, allows for subdivision of this interval for better time accuracy *\/$/;" m struct:_braid_Core_struct -rfactors xbraid/braid/_braid.h /^ braid_Int *rfactors; \/**< refinement factors for finest grid (if any) *\/$/;" m struct:_braid_Core_struct -rho include/hessianApprox.hpp /^ MyReal* rho; \/* storing M 1\/y^Ts values *\/$/;" m class:L_BFGS -rnorm xbraid/braid/_braid.h /^ braid_Real rnorm; \/**< norm of the state residual *\/$/;" m struct:_braid_Optimization_struct -rnorm xbraid/braid/_braid.h /^ braid_Real rnorm; \/**< residual norm *\/$/;" m struct:_braid_Core_struct -rnorm xbraid/misc/user_utils/cycleplot.py /^ rnorm = -1$/;" v -rnorm xbraid/misc/user_utils/cycleplot.py /^ rnorm = data[:,4]$/;" v -rnorm0 xbraid/braid/_braid.h /^ braid_Real rnorm0; \/**< initial residual norm *\/$/;" m struct:_braid_Core_struct -rnorm0 xbraid/braid/_braid.h /^ braid_Real rnorm0; \/**< initial norm of the state residual *\/$/;" m struct:_braid_Optimization_struct -rnorm0_adj xbraid/braid/_braid.h /^ braid_Real rnorm0_adj; \/**< initial norm of the adjoint residual *\/$/;" m struct:_braid_Optimization_struct -rnorm_adj xbraid/braid/_braid.h /^ braid_Real rnorm_adj; \/**< norm of the adjoint residual *\/$/;" m struct:_braid_Optimization_struct -rnorms xbraid/braid/_braid.h /^ braid_Real *rnorms; \/**< residual norm history *\/$/;" m struct:_braid_Core_struct -rstopped xbraid/braid/_braid.h /^ braid_Int rstopped; \/**< refinement stopped at iteration rstopped *\/$/;" m struct:_braid_Core_struct -rtol xbraid/braid/_braid.h /^ braid_Int rtol; \/**< use relative tolerance *\/$/;" m struct:_braid_Core_struct -rtol xbraid/drivers/braid_mfem.hpp /^ bool rtol;$/;" m struct:BraidOptions -rtol_adj xbraid/braid/_braid.h /^ braid_Int rtol_adj; \/**< flag: use relative tolerance for adjoint *\/$/;" m struct:_braid_Optimization_struct -runcommand examples/mnist/mnist_runs/submit_paramstudy.py /^runcommand = "mpirun -n"$/;" v -runcommand pythonutil/submit_paramstudy.py /^runcommand = "mpirun -n"$/;" v -runcommand testing/testing.py /^ runcommand = "mpirun -n " + str(npt) + " ..\/..\/main " + testconfig + " > tmp"$/;" v -s include/hessianApprox.hpp /^ MyReal* s; $/;" m class:BFGS -s include/hessianApprox.hpp /^ MyReal** s; \/* storing M (x_{k+1} - x_k) vectors *\/$/;" m class:L_BFGS -sclone xbraid/braid/_braid.h /^ braid_PtFcnSClone sclone; \/**< (optional) clone the shell of a vector *\/$/;" m struct:_braid_Core_struct -scoarsen xbraid/braid/_braid.h /^ braid_PtFcnSCoarsen scoarsen; \/**< (optional) return a spatially coarsened vector *\/$/;" m struct:_braid_Core_struct -send_handle xbraid/braid/_braid.h /^ _braid_CommHandle *send_handle; \/**< Handle for nonblocking sends of braid_BaseVectors *\/$/;" m struct:__anon3 -send_index xbraid/braid/_braid.h /^ braid_Int send_index; \/**< -1 means no send *\/$/;" m struct:__anon3 -send_recv_rank xbraid/braid/_braid.h /^ braid_Int send_recv_rank; \/***< holds the rank of the source \/ receiver from MPI_Send \/ MPI_Recv calls. *\/$/;" m struct:_braid_Core_struct -send_recv_rank xbraid/braid/_braid_tape.h /^ braid_Int send_recv_rank; \/**< processor rank of sender \/ receiver in my_bufpack \/ my_bufunpack *\/$/;" m struct:_braid_Action_struct -sendbuffer xbraid/braid/_braid.h /^ void *sendbuffer; \/**< helper: Memory for BufUnPackDiff communication *\/$/;" m struct:_braid_Optimization_struct -sendflag include/braid_wrapper.hpp /^ MyReal sendflag; $/;" m class:myBraidVector -seq_soln xbraid/braid/_braid.h /^ braid_Int seq_soln; \/**< boolean, controls if the initial guess is from sequential time stepping*\/$/;" m struct:_braid_Core_struct -ser_ref_levels xbraid/drivers/braid_mfem.hpp /^ int ser_ref_levels;$/;" m struct:BraidOptions -ser_ref_levels xbraid/drivers/braid_mfem_block.hpp /^ int ser_ref_levels;$/;" m struct:BraidOptions -setdefault pythonutil/ordered_dict.py /^ def setdefault(self, key, default=None):$/;" m class:OrderedDict -sfree xbraid/braid/_braid.h /^ braid_PtFcnSFree sfree; \/**< (optional) free up the data of a vector, keep the shell *\/$/;" m struct:_braid_Core_struct -sinit xbraid/braid/_braid.h /^ braid_PtFcnSInit sinit; \/**< (optional) return an initialized shell of braid_BaseVector *\/$/;" m struct:_braid_Core_struct -size xbraid/braid/_braid_tape.h /^ int size;$/;" m struct:_braid_tape_struct -size_buffer xbraid/braid/_braid.h /^ braid_Int size_buffer; \/**< if set by user, send buffer will be "size" bytes in length *\/$/;" m struct:_braid_Core_struct -size_buffer xbraid/braid/_braid_tape.h /^ braid_Int size_buffer; \/**< if set by user, size of send buffer is "size" bytes *\/$/;" m struct:_braid_Action_struct -sizeof_double xbraid/examples/ex-01-expanded-f.f90 /^ integer, parameter :: sizeof_double /;" v module:braid_types -sizeof_int xbraid/examples/ex-01-expanded-f.f90 /^ integer, parameter :: sizeof_int /;" v module:braid_types -skip xbraid/braid/_braid.h /^ braid_Int skip; \/**< boolean, controls skipping any work on first down-cycle *\/$/;" m struct:_braid_Core_struct -skip xbraid/drivers/braid_mfem.hpp /^ int skip;$/;" m struct:BraidOptions -skip xbraid/drivers/braid_mfem_block.hpp /^ int skip;$/;" m struct:BraidOptions -sol_sock xbraid/drivers/braid_mfem.hpp /^ socketstream sol_sock;$/;" m class:MFEMBraidApp -sol_sock xbraid/drivers/braid_mfem_block.hpp /^ socketstream sol_sock;$/;" m class:MFEMBraidApp -solver xbraid/drivers/braid_mfem.hpp /^ Array solver;$/;" m class:MFEMBraidApp -solver xbraid/drivers/braid_mfem_block.hpp /^ Array solver;$/;" m class:MFEMBraidApp -spatial_coarsen xbraid/drivers/braid_mfem.hpp /^ bool spatial_coarsen;$/;" m struct:BraidOptions -spatial_coarsen xbraid/drivers/braid_mfem_block.hpp /^ bool spatial_coarsen;$/;" m struct:BraidOptions -spatial_level xbraid/drivers/braid_mfem_block.hpp /^ int spatial_level;$/;" m class:BraidVector -spatialnorm xbraid/braid/_braid.h /^ braid_PtFcnSpatialNorm spatialnorm; \/**< Compute norm of a braid_BaseVector, this is a norm only over space *\/$/;" m struct:_braid_Core_struct -srefine xbraid/braid/_braid.h /^ braid_PtFcnSRefine srefine; \/**< (optional) return a spatially refined vector *\/$/;" m struct:_braid_Core_struct -startlayerID include/network.hpp /^ int startlayerID; \/* ID of the first layer on that processor *\/$/;" m class:Network -state include/braid_wrapper.hpp /^ MyReal **state; \/* Network state at one layer, dimensions: nbatch * nchannels *\/$/;" m class:myBraidVector -state_vec xbraid/examples/viz-ex-04.py /^ state_vec = loadtxt('ex-04.out.state')$/;" v -state_vec xbraid/examples/viz-ex-04.py /^ state_vec = zeros((nsteps,2))$/;" v -status xbraid/braid/_braid.h /^ MPI_Status *status; \/**< MPI status *\/$/;" m struct:__anon2 -status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_AccessStatus_struct -status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_BufferStatus_struct -status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_CoarsenRefStatus_struct -status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_ObjectiveStatus_struct -status xbraid/braid/_braid_status.h /^ _braid_Status status;$/;" m struct:_braid_StepStatus_struct -step xbraid/braid/_braid.h /^ braid_PtFcnStep step; \/**< apply step function *\/$/;" m struct:_braid_Core_struct -step xbraid/drivers/viz-burgers-1D.py /^step = 0$/;" v -step xbraid/examples/viz-ex-02.py /^step = 0$/;" v -step_diff xbraid/braid/_braid.h /^ braid_PtFcnStepDiff step_diff; \/**< User function: apply differentiated step function *\/$/;" m struct:_braid_Core_struct -stepsize_init include/config.hpp /^ MyReal stepsize_init;$/;" m class:Config -stepsize_type include/config.hpp /^ int stepsize_type;$/;" m class:Config -stepsizetype include/config.hpp /^enum stepsizetype{FIXED, BACKTRACKINGLS, ONEOVERK};$/;" g -storage xbraid/braid/_braid.h /^ braid_Int storage; \/**< storage = 0 (C-points), = 1 (all) *\/$/;" m struct:_braid_Core_struct -storage xbraid/drivers/braid_mfem.hpp /^ int storage;$/;" m struct:BraidOptions -storage xbraid/drivers/braid_mfem_block.hpp /^ int storage;$/;" m struct:BraidOptions -submit_job pythonutil/batch_job.py /^def submit_job(jobname, runcommand, ntasks, time_limit, executable, arguments,run=True):$/;" f -sum xbraid/braid/_braid.h /^ braid_PtFcnSum sum; \/**< vector sum *\/$/;" m struct:_braid_Core_struct -sum_alpha xbraid/braid/_braid_tape.h /^ braid_Real sum_alpha; \/**< first coefficient of my_sum *\/$/;" m struct:_braid_Action_struct -sum_beta xbraid/braid/_braid_tape.h /^ braid_Real sum_beta; \/**< second coefficient of my_sum *\/$/;" m struct:_braid_Action_struct -sum_user_obj xbraid/braid/_braid.h /^ braid_Real sum_user_obj; \/**< sum of user's objective function values over time *\/$/;" m struct:_braid_Optimization_struct -switch pythonutil/switch.py /^class switch(object):$/;" c -t xbraid/braid/_braid.h /^ braid_Real t; \/**< current time *\/$/;" m struct:_braid_Core_struct -t xbraid/examples/ex-01-expanded-f.f90 /^ double precision t,/;" v program:ex01_f90 -t_final xbraid/drivers/braid_mfem.hpp /^ double t_final;$/;" m struct:BraidOptions -t_final xbraid/drivers/braid_mfem_block.hpp /^ double t_final;$/;" m struct:BraidOptions -t_start xbraid/drivers/braid_mfem.hpp /^ double t_start;$/;" m struct:BraidOptions -t_start xbraid/drivers/braid_mfem_block.hpp /^ double t_start;$/;" m struct:BraidOptions -ta xbraid/braid/_braid.h /^ braid_Real *ta; \/**< time values (all points) *\/$/;" m struct:__anon3 -ta_alloc xbraid/braid/_braid.h /^ braid_Real *ta_alloc; \/**< original memory allocation for ta *\/$/;" m struct:__anon3 -tapeinput xbraid/braid/_braid.h /^ braid_VectorBar *tapeinput; \/**< helper: store pointer to input of one braid iteration *\/$/;" m struct:_braid_Optimization_struct -testconfig testing/testing.py /^ testconfig = testname + ".cfg"$/;" v -testfoldername testing/testing.py /^ testfoldername = "test." + testname$/;" v -testname testing/testing.py /^ testname = case + ".npt" + str(npt) + ".ml" + str(ml) $/;" v -tgrid xbraid/braid/_braid.h /^ braid_PtFcnTimeGrid tgrid; \/**< (optional) return time point values on level 0 *\/$/;" m struct:_braid_Core_struct -tight_fine_tolx xbraid/braid/_braid.h /^ braid_Int tight_fine_tolx; \/**< Boolean, indicating whether the tightest fine tolx has been used, condition for halting *\/$/;" m struct:_braid_Core_struct -tmesh xbraid/examples/viz-ex-04.py /^tmesh = linspace(0,1.0,nsteps+1)$/;" v -tnext xbraid/braid/_braid.h /^ braid_Real tnext; \/**< time value to evolve towards, time value to the right of tstart *\/$/;" m struct:_braid_Core_struct -tnorm xbraid/braid/_braid.h /^ braid_Int tnorm; \/**< choice of temporal norm *\/$/;" m struct:_braid_Core_struct -tnorm xbraid/drivers/braid_mfem.hpp /^ int tnorm;$/;" m struct:BraidOptions -tnorm xbraid/drivers/braid_mfem_block.hpp /^ int tnorm;$/;" m struct:BraidOptions -tnorm_a xbraid/braid/_braid.h /^ braid_Real *tnorm_a; \/**< local array of residual norms on a proc's interval, used for inf-norm *\/$/;" m struct:_braid_Core_struct -toJSON pythonutil/ordered_bunch.py /^ def toJSON(self, **options):$/;" f function:ordered_unbunchify -toOrderedDict pythonutil/ordered_bunch.py /^ def toOrderedDict(self):$/;" m class:OrderedBunch -toYAML pythonutil/ordered_bunch.py /^ def toYAML(self, **options):$/;" f -to_yaml pythonutil/ordered_bunch.py /^ def to_yaml(dumper, data):$/;" f -to_yaml_safe pythonutil/ordered_bunch.py /^ def to_yaml_safe(dumper, data):$/;" f -todo : Don't feed applyBWD with NULL! */ src/braid_wrapper.cpp /^ \/* TODO: Don't feed applyBWD with NULL! *\/$/;" t -todo : Fix src/network.cpp /^ \/\/ TODO: Fix$/;" t -todo : Remove these two lines, which are now useless since core==status */ xbraid/braid/_braid.c /^ \/* TODO : Remove these two lines, which are now useless since core==status *\/$/;" t -todo : read some design */ src/main.cpp /^ \/* TODO: read some design *\/$/;" t -todo : so something, if design is part of initial conditions!! */ xbraid/braid/_braid_tape.c /^ \/* TODO: so something, if design is part of initial conditions!! *\/$/;" t -todo Remove this line after modifing the _braid_StatusSetRFactor to set the rfactor in the array directly */ xbraid/braid/_braid.c /^ \/*TODO Remove this line after modifing the _braid_StatusSetRFactor to set the rfactor in the array directly *\/$/;" t -tol xbraid/braid/_braid.h /^ braid_Real tol; \/**< stopping tolerance *\/$/;" m struct:_braid_Core_struct -tol xbraid/braid/_braid_tape.h /^ braid_Real tol; \/**< primal stopping tolerance *\/ $/;" m struct:_braid_Action_struct -tol xbraid/drivers/braid_mfem.hpp /^ double tol;$/;" m struct:BraidOptions -tol xbraid/drivers/braid_mfem_block.hpp /^ double tol;$/;" m struct:BraidOptions -tol xbraid/examples/ex-01-expanded-f.f90 /^ double precision t, tol,/;" v program:ex01_f90 -tol xbraid/misc/user_utils/cycleplot.py /^ tol = data[:,5]$/;" v -tol_adj xbraid/braid/_braid.h /^ braid_Real tol_adj; \/**< tolerance of adjoint residual *\/$/;" m struct:_braid_Optimization_struct -tols xbraid/misc/user_utils/cycleplot.py /^ tols = data[:,5]$/;" v -tpoints_cutoff xbraid/braid/_braid.h /^ braid_Int tpoints_cutoff; \/**< refinements halt after the number of time steps exceed this value *\/$/;" m struct:_braid_Core_struct -tstart xbraid/braid/_braid.h /^ braid_Real tstart; \/**< start time *\/$/;" m struct:_braid_Core_struct -tstart xbraid/braid/braid.hpp /^ braid_Real tstart;$/;" m class:BraidApp -tstart xbraid/drivers/viz-burgers-1D.py /^tstart = float(data[1])$/;" v -tstart xbraid/examples/ex-01-expanded-f.f90 /^ double precision :: tstart$/;" k type:my_app -tstart xbraid/examples/ex-01-expanded-f.f90 /^ double precision t, tol, tstart,/;" v program:ex01_f90 -tstart xbraid/examples/viz-ex-02.py /^tstart = float(data[1])$/;" v -tstart_obj xbraid/braid/_braid.h /^ braid_Real tstart_obj; \/**< starting time for evaluating the user's local objective *\/$/;" m struct:_braid_Optimization_struct -tstop xbraid/braid/_braid.h /^ braid_Real tstop; \/**< stop time *\/$/;" m struct:_braid_Core_struct -tstop xbraid/braid/braid.hpp /^ braid_Real tstop;$/;" m class:BraidApp -tstop xbraid/drivers/viz-burgers-1D.py /^tstop = float(data[2])$/;" v -tstop xbraid/examples/ex-01-expanded-f.f90 /^ double precision :: tstop$/;" k type:my_app -tstop xbraid/examples/ex-01-expanded-f.f90 /^ double precision t, tol, tstart, tstop$/;" v program:ex01_f90 -tstop xbraid/examples/viz-ex-02.py /^tstop = float(data[2])$/;" v -tstop_obj xbraid/braid/_braid.h /^ braid_Real tstop_obj; \/**< stopping time for evaluating the user's local objective *\/$/;" m struct:_braid_Optimization_struct -type include/layer.hpp /^ int type; \/* Type of the layer (enum element) *\/$/;" m class:Layer -ua xbraid/braid/_braid.h /^ braid_BaseVector *ua; \/**< unknown vectors (C-points at least)*\/$/;" m struct:__anon3 -ua_alloc xbraid/braid/_braid.h /^ braid_BaseVector *ua_alloc; \/**< original memory allocation for ua *\/$/;" m struct:__anon3 -ulast xbraid/braid/_braid.h /^ braid_BaseVector ulast; \/**< stores last time step *\/$/;" m struct:__anon3 -update include/layer.hpp /^ MyReal *update; \/* Auxilliary for computing fwd update *\/$/;" m class:Layer -update pythonutil/ordered_dict.py /^ def update(*args, **kwds):$/;" m class:OrderedDict -update_bar include/layer.hpp /^ MyReal *update_bar; \/* Auxilliary for computing bwd update *\/$/;" m class:Layer -useCount xbraid/braid/_braid.h /^ braid_Int useCount; \/**< counts the number of pointers to this struct *\/$/;" m struct:_braid_VectorBar_struct -use_seq_soln xbraid/drivers/braid_mfem.hpp /^ int use_seq_soln;$/;" m struct:BraidOptions -userVector xbraid/braid/_braid.h /^ braid_Vector userVector; \/**< holds the users primal vector *\/$/;" m struct:_braid_BaseVector_struct -userVector xbraid/braid/_braid.h /^ braid_Vector userVector; \/**< holds the u_bar data *\/$/;" m struct:_braid_VectorBar_struct -userVectorTape xbraid/braid/_braid.h /^ _braid_Tape* userVectorTape; \/**< tape storing primal braid_vectors while recording *\/$/;" m struct:_braid_Core_struct -useshell xbraid/braid/_braid.h /^ braid_Int useshell; \/**< activate the shell structure of vectors *\/$/;" m struct:_braid_Core_struct -v xbraid/drivers/braid_mfem_block.hpp /^ Array v; \/\/ auxiliary ParGridFunctions for block v$/;" m class:MFEMBraidApp -va xbraid/braid/_braid.h /^ braid_BaseVector *va; \/**< restricted unknown vectors (all points, NULL on level 0) *\/$/;" m struct:__anon3 -va_alloc xbraid/braid/_braid.h /^ braid_BaseVector *va_alloc; \/**< original memory allocation for va *\/$/;" m struct:__anon3 -val xbraid/examples/ex-01-expanded-f.f90 /^ double precision val$/;" k type:my_vector -validationlevel include/config.hpp /^ int validationlevel;$/;" m class:Config -value include/config.hpp /^ char value[CONFIG_ARG_MAX_BYTES];$/;" m struct:Config::config_option -values pythonutil/ordered_dict.py /^ def values(self):$/;" m class:OrderedDict -vector_ptr xbraid/braid/_braid.h /^ braid_BaseVector *vector_ptr; \/**< braid_vector being sent\/received *\/$/;" m struct:__anon2 -verbose_adj xbraid/braid/_braid.h /^ braid_Int verbose_adj; \/**< verbosity of the adjoint tape, displays the actions that are pushed \/ popped to the tape*\/$/;" m struct:_braid_Core_struct -viewitems pythonutil/ordered_dict.py /^ def viewitems(self):$/;" m class:OrderedDict -viewkeys pythonutil/ordered_dict.py /^ def viewkeys(self):$/;" m class:OrderedDict -viewvalues pythonutil/ordered_dict.py /^ def viewvalues(self):$/;" m class:OrderedDict -vis_braid_steps xbraid/drivers/braid_mfem.hpp /^ int vis_braid_steps;$/;" m class:MFEMBraidApp -vis_braid_steps xbraid/drivers/braid_mfem_block.hpp /^ int vis_braid_steps;$/;" m class:MFEMBraidApp -vis_screenshots xbraid/drivers/braid_mfem.hpp /^ bool vis_screenshots;$/;" m class:MFEMBraidApp -vis_screenshots xbraid/drivers/braid_mfem_block.hpp /^ bool vis_screenshots;$/;" m class:MFEMBraidApp -vis_time_steps xbraid/drivers/braid_mfem.hpp /^ int vis_time_steps;$/;" m class:MFEMBraidApp -vis_time_steps xbraid/drivers/braid_mfem_block.hpp /^ int vis_time_steps;$/;" m class:MFEMBraidApp -vishost xbraid/drivers/braid_mfem.hpp /^ const char *vishost;$/;" m class:MFEMBraidApp -vishost xbraid/drivers/braid_mfem_block.hpp /^ const char *vishost;$/;" m class:MFEMBraidApp -vishost_default xbraid/drivers/braid_mfem.hpp /^ static const char *vishost_default;$/;" m class:MFEMBraidApp -vishost_default xbraid/drivers/braid_mfem.hpp /^const char *MFEMBraidApp::vishost_default = "localhost";$/;" m class:MFEMBraidApp -vishost_default xbraid/drivers/braid_mfem_block.hpp /^ static const char *vishost_default;$/;" m class:MFEMBraidApp -vishost_default xbraid/drivers/braid_mfem_block.hpp /^const char *MFEMBraidApp::vishost_default = "localhost";$/;" m class:MFEMBraidApp -visport xbraid/drivers/braid_mfem.hpp /^ int visport;$/;" m class:MFEMBraidApp -visport xbraid/drivers/braid_mfem_block.hpp /^ int visport;$/;" m class:MFEMBraidApp -visport_default xbraid/drivers/braid_mfem.hpp /^ static const int visport_default;$/;" m class:MFEMBraidApp -visport_default xbraid/drivers/braid_mfem.hpp /^const int MFEMBraidApp::visport_default = 19916;$/;" m class:MFEMBraidApp -visport_default xbraid/drivers/braid_mfem_block.hpp /^ static const int visport_default;$/;" m class:MFEMBraidApp -visport_default xbraid/drivers/braid_mfem_block.hpp /^const int MFEMBraidApp::visport_default = 19916;$/;" m class:MFEMBraidApp -warm_restart xbraid/braid/_braid.h /^ braid_Int warm_restart; \/**< boolean, indicates whether this is a warm restart of an existing braid_Core *\/$/;" m struct:_braid_Core_struct -weights include/layer.hpp /^ MyReal* weights; \/* Weight matrix, flattened as a vector *\/$/;" m class:Layer -weights_bar include/layer.hpp /^ MyReal* weights_bar; \/* Derivative of the Weight matrix*\/$/;" m class:Layer -weights_class_init include/config.hpp /^ MyReal weights_class_init;$/;" m class:Config -weights_init include/config.hpp /^ MyReal weights_init;$/;" m class:Config -weights_open_init include/config.hpp /^ MyReal weights_open_init;$/;" m class:Config -weightsclassificationfile include/config.hpp /^ const char* weightsclassificationfile;$/;" m class:Config -weightsopenfile include/config.hpp /^ const char* weightsopenfile;$/;" m class:Config -wrapper_test xbraid/braid/_braid.h /^ braid_Int wrapper_test; \/**< boolean describing whether this call is only a wrapper test *\/$/;" m struct:_braid_Core_struct -wrapper_tests xbraid/examples/ex-01-expanded-f.f90 /^ integer max_iter, fmg, wrapper_tests,/;" v program:ex01_f90 -write pythonutil/config.py /^ def write(self,filename=''):$/;" m class:Config -x xbraid/drivers/braid_mfem.hpp /^ Array x; \/\/ auxiliary ParGridFunctions$/;" m class:MFEMBraidApp -x xbraid/drivers/braid_mfem_block.hpp /^ Array x; \/\/ auxiliary ParGridFunctions for block x$/;" m class:MFEMBraidApp -x xbraid/drivers/viz-lorenz.py /^x = data[:,0]$/;" v -xstart xbraid/drivers/viz-burgers-1D.py /^xstart = float(data[4])$/;" v -xstart xbraid/examples/viz-ex-02.py /^xstart = float(data[4])$/;" v -xstop xbraid/drivers/viz-burgers-1D.py /^xstop = float(data[5])$/;" v -xstop xbraid/examples/viz-ex-02.py /^xstop = float(data[5])$/;" v -xticks xbraid/misc/user_utils/cycleplot.py /^ xticks = arange( level.shape[0] )[new_iterations]$/;" v -y include/hessianApprox.hpp /^ MyReal* y; $/;" m class:BFGS -y include/hessianApprox.hpp /^ MyReal** y; \/* storing M (\\nabla f_{k+1} - \\nabla f_k) vectors *\/$/;" m class:L_BFGS -y xbraid/drivers/viz-lorenz.py /^y = data[:,1]$/;" v -yticks xbraid/misc/user_utils/cycleplot.py /^ yticks = [ma, 10**((log10(mi)+log10(ma))*1.\/3.), 10**((log10(mi)+log10(ma))*2.\/3.), mi ]$/;" v -yticks xbraid/misc/user_utils/cycleplot.py /^ yticks = range(int(min(level)), int(max(level)+1))$/;" v -z xbraid/drivers/viz-lorenz.py /^z = data[:,2]$/;" v -~Arnoldi xbraid/drivers/mfem_arnoldi.hpp /^ ~Arnoldi()$/;" f class:Arnoldi -~BraidAccessStatus xbraid/braid/braid.hpp /^ ~BraidAccessStatus() { }$/;" f class:BraidAccessStatus -~BraidApp xbraid/braid/braid.hpp /^ virtual ~BraidApp() { }$/;" f class:BraidApp -~BraidBufferStatus xbraid/braid/braid.hpp /^ ~BraidBufferStatus() {} $/;" f class:BraidBufferStatus -~BraidCoarsenRefStatus xbraid/braid/braid.hpp /^ ~BraidCoarsenRefStatus() { }$/;" f class:BraidCoarsenRefStatus -~BraidCore xbraid/braid/braid.hpp /^ ~BraidCore() { braid_Destroy(core); }$/;" f class:BraidCore -~BraidStepStatus xbraid/braid/braid.hpp /^ ~BraidStepStatus() { }$/;" f class:BraidStepStatus -~BraidUtil xbraid/braid/braid.hpp /^ ~BraidUtil() { }$/;" f class:BraidUtil -~BraidVector xbraid/drivers/braid_mfem_block.hpp /^BraidVector::~BraidVector()$/;" f class:BraidVector -~MFEMBraidApp xbraid/drivers/braid_mfem.hpp /^MFEMBraidApp::~MFEMBraidApp()$/;" f class:MFEMBraidApp -~MFEMBraidApp xbraid/drivers/braid_mfem_block.hpp /^MFEMBraidApp::~MFEMBraidApp()$/;" f class:MFEMBraidApp From 06a3fa83b532b52e6d54e8d65bf853bdc8f644c7 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Wed, 10 Jul 2019 22:17:28 +0200 Subject: [PATCH 10/38] Switch to Google's code style --- include/braid_wrapper.hpp | 12 ++-- include/config.hpp | 5 +- include/dataset.hpp | 9 ++- include/hessianApprox.hpp | 22 +++--- include/layer.hpp | 72 ++++++++++---------- include/linalg.hpp | 2 +- include/network.hpp | 14 ++-- include/util.hpp | 2 +- src/braid_wrapper.cpp | 75 ++++++++++----------- src/config.cpp | 137 +++++++++++++++++++------------------- src/dataset.cpp | 96 ++++++++++++-------------- src/hessianApprox.cpp | 6 +- src/layer.cpp | 132 +++++++++++++++--------------------- src/linalg.cpp | 1 - src/main.cpp | 42 ++++++------ src/network.cpp | 128 ++++++++++++++++------------------- 16 files changed, 346 insertions(+), 409 deletions(-) diff --git a/include/braid_wrapper.hpp b/include/braid_wrapper.hpp index e9c2f1b..91bedb5 100644 --- a/include/braid_wrapper.hpp +++ b/include/braid_wrapper.hpp @@ -13,7 +13,7 @@ * Define the state vector at one time-step */ class myBraidVector { -protected: + protected: int nbatch; /* Number of examples */ int nchannels; /* Number of channels */ @@ -25,7 +25,7 @@ class myBraidVector { * thus should be free'd after usage (flag > 0) */ MyReal sendflag; -public: + public: /* Get dimensions */ int getnBatch(); int getnChannels(); @@ -55,7 +55,7 @@ class myBraidVector { * virtual function are overwritten from the adjoint app class */ class myBraidApp : public BraidApp { -protected: + protected: // BraidApp defines tstart, tstop, ntime and comm_t int myid; /* Processor rank*/ Network *network; /* Pointer to the DNN Network Block (local layer storage) */ @@ -66,7 +66,7 @@ class myBraidApp : public BraidApp { /* Output */ MyReal objective; /* Objective function */ -public: + public: /* Constructor */ myBraidApp(DataSet *Data, Network *Network, Config *Config, MPI_Comm Comm); @@ -138,11 +138,11 @@ class myBraidApp : public BraidApp { * Adjoint braid App for solving adjoint eqations with xbraid. */ class myAdjointBraidApp : public myBraidApp { -protected: + protected: BraidCore *primalcore; /* pointer to primal core for accessing primal states */ -public: + public: myAdjointBraidApp(DataSet *Data, Network *Network, Config *config, BraidCore *Primalcoreptr, MPI_Comm comm); diff --git a/include/config.hpp b/include/config.hpp index 0620427..9eec554 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -22,8 +22,7 @@ enum hessiantype { BFGS_SERIAL, LBFGS, IDENTITY }; enum stepsizetype { FIXED, BACKTRACKINGLS, ONEOVERK }; class Config { - -private: + private: /* Linked list for reading config options */ struct config_option { struct config_option *prev; @@ -35,7 +34,7 @@ class Config { /* Helper function: Parse the config file */ config_option *parsefile(char *path); -public: /* List all configuration options here */ + public: /* List all configuration options here */ /* Data set */ const char *datafolder; const char *ftrain_ex; diff --git a/include/dataset.hpp b/include/dataset.hpp index edebd4f..e2008c2 100644 --- a/include/dataset.hpp +++ b/include/dataset.hpp @@ -1,13 +1,12 @@ +#include +#include #include "config.hpp" #include "defs.hpp" #include "util.hpp" -#include -#include #pragma once class DataSet { - -protected: + protected: int nelements; /* Number of data elements */ int nfeatures; /* Number of features per element */ int nlabels; /* Number of different labels (i.e. classes) per element */ @@ -25,7 +24,7 @@ class DataSet { batch */ int navail; /* Auxilliary: holding number of currently available batchIDs */ -public: + public: /* Default constructor */ DataSet(); diff --git a/include/hessianApprox.hpp b/include/hessianApprox.hpp index 42c0556..356bb61 100644 --- a/include/hessianApprox.hpp +++ b/include/hessianApprox.hpp @@ -1,16 +1,15 @@ +#include #include "defs.hpp" #include "linalg.hpp" -#include #pragma once class HessianApprox { - -protected: + protected: int dimN; /* Dimension of the gradient vector */ MPI_Comm MPIcomm; /* MPI communicator for parallel L-BFGS updates */ -public: + public: HessianApprox(MPI_Comm comm); virtual ~HessianApprox(); @@ -26,8 +25,7 @@ class HessianApprox { }; class L_BFGS : public HessianApprox { - -protected: + protected: int M; /* Length of the l-bfgs memory (stages) */ /* L-BFGS memory */ @@ -38,7 +36,7 @@ class L_BFGS : public HessianApprox { MyReal *design_old; /* Design at previous iteration */ MyReal *gradient_old; /* Gradient at previous iteration */ -public: + public: L_BFGS(MPI_Comm comm, int dimN, /* Local design dimension */ int stage); ~L_BFGS(); @@ -49,13 +47,12 @@ class L_BFGS : public HessianApprox { }; class BFGS : public HessianApprox { - -private: + private: MyReal *A; MyReal *B; MyReal *Hy; -protected: + protected: MyReal *s; MyReal *y; MyReal @@ -63,7 +60,7 @@ class BFGS : public HessianApprox { MyReal *design_old; /* Design at previous iteration */ MyReal *gradient_old; /* Gradient at previous iteration */ -public: + public: BFGS(MPI_Comm comm, int N); ~BFGS(); @@ -78,8 +75,7 @@ class BFGS : public HessianApprox { * No second order: Use Identity for Hessian Approximation */ class Identity : public HessianApprox { - -public: + public: Identity(MPI_Comm comm, int N); ~Identity(); diff --git a/include/layer.hpp b/include/layer.hpp index eefd261..036ead8 100644 --- a/include/layer.hpp +++ b/include/layer.hpp @@ -1,10 +1,10 @@ -#include "config.hpp" -#include "defs.hpp" -#include "linalg.hpp" -#include #include #include #include +#include +#include "config.hpp" +#include "defs.hpp" +#include "linalg.hpp" #pragma once @@ -15,7 +15,7 @@ * - applyBWD: Backward propagation of data */ class Layer { -protected: + protected: int dim_In; /* Dimension of incoming data */ int dim_Out; /* Dimension of outgoing data */ int dim_Bias; /* Dimension of the bias vector */ @@ -40,7 +40,7 @@ class Layer { MyReal *update; /* Auxilliary for computing fwd update */ MyReal *update_bar; /* Auxilliary for computing bwd update */ -public: + public: /* Available layer types */ enum layertype { OPENZERO = 0, @@ -54,7 +54,7 @@ class Layer { Layer(); Layer(int idx, int Type, int dimI, int dimO, int dimB, - int dimW, // number of weights + int dimW, // number of weights MyReal deltaT, int Activ, MyReal gammatik, MyReal gammaddt); virtual ~Layer(); @@ -186,8 +186,7 @@ class Layer { * if not openlayer: requires dimI = dimO ! */ class DenseLayer : public Layer { - -public: + public: DenseLayer(int idx, int dimI, int dimO, MyReal deltaT, int activation, MyReal gammatik, MyReal gammaddt); ~DenseLayer(); @@ -202,11 +201,10 @@ class DenseLayer : public Layer { * Layer transformation: y = sigma(W*y_ex + b) for examples y_ex \in \R^dimI */ class OpenDenseLayer : public DenseLayer { - -protected: + protected: MyReal *example; /* Pointer to the current example data */ -public: + public: OpenDenseLayer(int dimI, int dimO, int activation, MyReal gammatik); ~OpenDenseLayer(); @@ -221,9 +219,9 @@ class OpenDenseLayer : public DenseLayer { * Opening layer that expands the data by zeros */ class OpenExpandZero : public Layer { -protected: + protected: MyReal *example; /* Pointer to the current example data */ -public: + public: OpenExpandZero(int dimI, int dimO); ~OpenExpandZero(); @@ -238,12 +236,12 @@ class OpenExpandZero : public Layer { * Classification layer */ class ClassificationLayer : public Layer { -protected: + protected: MyReal *label; /* Pointer to the current label vector */ MyReal *probability; /* vector of pedicted class probabilities */ -public: + public: ClassificationLayer(int idx, int dimI, int dimO, MyReal gammatik); ~ClassificationLayer(); @@ -290,14 +288,13 @@ class ClassificationLayer : public Layer { * if not openlayer: requires dimI = dimO ! */ class ConvLayer : public Layer { - int csize2; int fcsize; int img_size; int img_size_sqrt; -public: + public: ConvLayer(int idx, int dimI, int dimO, int csize_in, int nconv_in, MyReal deltaT, int Activ, MyReal Gammatik, MyReal Gammaddt); ~ConvLayer(); @@ -306,17 +303,17 @@ class ConvLayer : public Layer { void applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient); - inline MyReal - apply_conv(MyReal *state, // state vector to apply convolution to - int output_conv, // output convolution - int j, // row index - int k); // column index + inline MyReal apply_conv( + MyReal *state, // state vector to apply convolution to + int output_conv, // output convolution + int j, // row index + int k); // column index - inline MyReal - apply_conv_trans(MyReal *state, // state vector to apply convolution to - int output_conv, // output convolution - int j, // row index - int k); // column index + inline MyReal apply_conv_trans( + MyReal *state, // state vector to apply convolution to + int output_conv, // output convolution + int j, // row index + int k); // column index /** * This method is designed to be used only in the applyBWD. It computes the @@ -337,11 +334,12 @@ class ConvLayer : public Layer { * On exit this method modifies weights_bar */ inline MyReal updateWeightDerivative( - MyReal *state, // state vector - MyReal *update_bar, // combines derivative and adjoint info (see comments) - int output_conv, // output convolution - int j, // row index - int k); // column index + MyReal *state, // state vector + MyReal + *update_bar, // combines derivative and adjoint info (see comments) + int output_conv, // output convolution + int j, // row index + int k); // column index }; /** @@ -349,11 +347,10 @@ class ConvLayer : public Layer { * Layer transformation: y = ([I; I; ... I] y_ex) */ class OpenConvLayer : public Layer { - -protected: + protected: MyReal *example; /* Pointer to the current example data */ -public: + public: OpenConvLayer(int dimI, int dimO); ~OpenConvLayer(); @@ -374,8 +371,7 @@ class OpenConvLayer : public Layer { */ class OpenConvLayerMNIST : public OpenConvLayer { - -public: + public: OpenConvLayerMNIST(int dimI, int dimO); ~OpenConvLayerMNIST(); diff --git a/include/linalg.hpp b/include/linalg.hpp index f580e04..873d6bc 100644 --- a/include/linalg.hpp +++ b/include/linalg.hpp @@ -1,7 +1,7 @@ -#include "defs.hpp" #include #include #include +#include "defs.hpp" #pragma once /** diff --git a/include/network.hpp b/include/network.hpp index ec32a6a..3b6996d 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -1,16 +1,16 @@ -#include "config.hpp" -#include "dataset.hpp" -#include "layer.hpp" -#include "util.hpp" -#include #include #include #include #include +#include +#include "config.hpp" +#include "dataset.hpp" +#include "layer.hpp" +#include "util.hpp" #pragma once class Network { -protected: + protected: int nlayers_global; /* Total number of Layers of the network */ int nlayers_local; /* Number of Layers in this network block */ @@ -39,7 +39,7 @@ class Network { MPI_Comm comm; /* MPI communicator */ -public: + public: Network(); ~Network(); diff --git a/include/util.hpp b/include/util.hpp index d05ce0b..2d1793c 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -1,7 +1,7 @@ -#include "defs.hpp" #include #include #include +#include "defs.hpp" #pragma once /** diff --git a/src/braid_wrapper.cpp b/src/braid_wrapper.cpp index dde5e8f..3843242 100644 --- a/src/braid_wrapper.cpp +++ b/src/braid_wrapper.cpp @@ -75,8 +75,7 @@ myBraidApp::myBraidApp(DataSet *Data, Network *Network, Config *config, myBraidApp::~myBraidApp() { /* Delete the core, if drive() has been called */ - if (core->GetWarmRestart()) - delete core; + if (core->GetWarmRestart()) delete core; } MyReal myBraidApp::getObjective() { return objective; } @@ -191,7 +190,7 @@ braid_Int myBraidApp::Init(braid_Real t, braid_Vector *u_ptr) { } /* Set the layer pointer */ - if (t >= 0) // this should always be the case... + if (t >= 0) // this should always be the case... { int ilayer = GetTimeStepIndex(t); u->setLayer(network->getLayer(ilayer)); @@ -372,31 +371,31 @@ braid_Int myBraidApp::BufUnpack(void *buffer, braid_Vector *u_ptr, /* layertype decides on which layer should be created */ switch (layertype) { - case Layer::OPENZERO: - tmplayer = new OpenExpandZero(dimIn, dimOut); - break; - case Layer::OPENDENSE: - tmplayer = new OpenDenseLayer(dimIn, dimOut, activ, gammatik); - break; - case Layer::DENSE: - tmplayer = - new DenseLayer(index, dimIn, dimOut, 1.0, activ, gammatik, gammaddt); - break; - case Layer::CLASSIFICATION: - tmplayer = new ClassificationLayer(index, dimIn, dimOut, gammatik); - break; - case Layer::OPENCONV: - tmplayer = new OpenConvLayer(dimIn, dimOut); - break; - case Layer::OPENCONVMNIST: - tmplayer = new OpenConvLayerMNIST(dimIn, dimOut); - break; - case Layer::CONVOLUTION: - tmplayer = new ConvLayer(index, dimIn, dimOut, csize, nconv, 1.0, activ, - gammatik, gammaddt); - break; - default: - printf("\n\n ERROR while unpacking a buffer: Layertype unknown!!\n\n"); + case Layer::OPENZERO: + tmplayer = new OpenExpandZero(dimIn, dimOut); + break; + case Layer::OPENDENSE: + tmplayer = new OpenDenseLayer(dimIn, dimOut, activ, gammatik); + break; + case Layer::DENSE: + tmplayer = + new DenseLayer(index, dimIn, dimOut, 1.0, activ, gammatik, gammaddt); + break; + case Layer::CLASSIFICATION: + tmplayer = new ClassificationLayer(index, dimIn, dimOut, gammatik); + break; + case Layer::OPENCONV: + tmplayer = new OpenConvLayer(dimIn, dimOut); + break; + case Layer::OPENCONVMNIST: + tmplayer = new OpenConvLayerMNIST(dimIn, dimOut); + break; + case Layer::CONVOLUTION: + tmplayer = new ConvLayer(index, dimIn, dimOut, csize, nconv, 1.0, activ, + gammatik, gammaddt); + break; + default: + printf("\n\n ERROR while unpacking a buffer: Layertype unknown!!\n\n"); } /* Allocate design and gradient */ @@ -433,7 +432,7 @@ braid_Int myBraidApp::SetInitialCondition() { if (core->GetWarmRestart()) { /* Get vector at t == 0 */ _braid_UGetVectorRef(core->GetCore(), 0, 0, &ubase); - if (ubase != NULL) // only true on one first processor ! + if (ubase != NULL) // only true on one first processor ! { u = (myBraidVector *)ubase->userVector; @@ -452,7 +451,6 @@ braid_Int myBraidApp::SetInitialCondition() { } braid_Int myBraidApp::EvaluateObjective() { - braid_BaseVector ubase; myBraidVector *u; Layer *layer; @@ -464,7 +462,7 @@ braid_Int myBraidApp::EvaluateObjective() { int endlayerID = network->getEndLayerID(); if (startlayerID == 0) startlayerID -= - 1; // this includes opening layer (id = -1) at first processor + 1; // this includes opening layer (id = -1) at first processor /* Iterate over the local layers */ regul = 0.0; @@ -568,8 +566,7 @@ braid_Int myAdjointBraidApp::Step(braid_Vector u_, braid_Vector ustop_, uprimal = (myBraidVector *)ubaseprimal->userVector; /* Reset gradient before the update */ - if (compute_gradient) - uprimal->getLayer()->resetBar(); + if (compute_gradient) uprimal->getLayer()->resetBar(); /* Take one step backwards, updates adjoint state and gradient, if desired. */ uprimal->getLayer()->setDt(deltaT); @@ -592,8 +589,7 @@ braid_Int myAdjointBraidApp::Step(braid_Vector u_, braid_Vector ustop_, } /* Derivative of tikhonov */ - if (compute_gradient) - uprimal->getLayer()->evalTikh_diff(1.0); + if (compute_gradient) uprimal->getLayer()->evalTikh_diff(1.0); /* no refinement */ pstatus.SetRFactor(1); @@ -602,7 +598,6 @@ braid_Int myAdjointBraidApp::Step(braid_Vector u_, braid_Vector ustop_, } braid_Int myAdjointBraidApp::Init(braid_Real t, braid_Vector *u_ptr) { - int nchannels = network->getnChannels(); int nbatch = data->getnBatch(); @@ -654,7 +649,6 @@ braid_Int myAdjointBraidApp::BufSize(braid_Int *size_ptr, braid_Int myAdjointBraidApp::BufPack(braid_Vector u_, void *buffer, BraidBufferStatus &bstatus) { - int size; int nchannels = network->getnChannels(); int nbatch = data->getnBatch(); @@ -677,7 +671,6 @@ braid_Int myAdjointBraidApp::BufPack(braid_Vector u_, void *buffer, braid_Int myAdjointBraidApp::BufUnpack(void *buffer, braid_Vector *u_ptr, BraidBufferStatus &bstatus) { - int nchannels = network->getnChannels(); int nbatch = data->getnBatch(); MyReal *dbuffer = (MyReal *)buffer; @@ -718,8 +711,8 @@ braid_Int myAdjointBraidApp::SetInitialCondition() { _braid_UGetVectorRef(core->GetCore(), 0, 0, &ubaseadjoint); if (ubaseprimal != NULL && - ubaseadjoint != - NULL) // this is the case at first primal and last adjoint time step + ubaseadjoint != NULL) // this is the case at first primal and last + // adjoint time step { uprimal = (myBraidVector *)ubaseprimal->userVector; uadjoint = (myBraidVector *)ubaseadjoint->userVector; @@ -752,7 +745,7 @@ braid_Int myAdjointBraidApp::EvaluateObjective() { /* Get \bar y^0 (which is the LAST xbraid vector, stored on proc 0) */ _braid_UGetLast(core->GetCore(), &ubase); - if (ubase != NULL) // This is true only on first processor (reverted ranks!) + if (ubase != NULL) // This is true only on first processor (reverted ranks!) { uadjoint = (myBraidVector *)ubase->userVector; diff --git a/src/config.cpp b/src/config.cpp index 04cb47d..8d7bd4d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -5,7 +5,6 @@ #include Config::Config() { - /* --- Set DEFAULT parameters of the config file options --- */ /* Data st */ @@ -50,7 +49,7 @@ Config::Config() { /* Optimization */ batch_type = DETERMINISTIC; - nbatch = ntraining; // full batch + nbatch = ntraining; // full batch gamma_tik = 1e-07; gamma_ddt = 1e-07; gamma_class = 1e-07; @@ -77,7 +76,6 @@ int Config::readFromFile(char *configfilename) { /* Set the config options */ while (1) { - if (strcmp(co->key, "datafolder") == 0) { datafolder = co->value; } else if (strcmp(co->key, "ftrain_ex") == 0) { @@ -108,9 +106,10 @@ int Config::readFromFile(char *configfilename) { nlayers = atoi(co->value); if (nlayers < 3) { - printf("\n\n ERROR: nlayers=%d too small! Choose minimum three layers " - "(openlayer, one hidden layer, classification layer)!\n\n", - nlayers); + printf( + "\n\n ERROR: nlayers=%d too small! Choose minimum three layers " + "(openlayer, one hidden layer, classification layer)!\n\n", + nlayers); return -1; } } else if (strcmp(co->key, "activation") == 0) { @@ -167,8 +166,9 @@ int Config::readFromFile(char *configfilename) { } else if (strcmp(co->value, "stochastic") == 0) { batch_type = STOCHASTIC; } else { - printf("Invalid optimization type! Should be either 'deterministic' or " - "'stochastic'!"); + printf( + "Invalid optimization type! Should be either 'deterministic' or " + "'stochastic'!"); return -1; } } else if (strcmp(co->key, "nbatch") == 0) { @@ -187,8 +187,9 @@ int Config::readFromFile(char *configfilename) { } else if (strcmp(co->value, "oneoverk") == 0) { stepsize_type = ONEOVERK; } else { - printf("Invalid stepsize type! Should be either 'fixed' or " - "'backtrackingLS' or 'oneoverk' !"); + printf( + "Invalid stepsize type! Should be either 'fixed' or " + "'backtrackingLS' or 'oneoverk' !"); return -1; } } else if (strcmp(co->key, "stepsize") == 0) { @@ -296,63 +297,63 @@ int Config::writeToFile(FILE *outfile) { /* Get names of some int options */ switch (activation) { - case TANH: - activname = "tanh"; - break; - case RELU: - activname = "ReLu"; - break; - case SMRELU: - activname = "SmoothReLU"; - break; - default: - activname = "invalid!"; + case TANH: + activname = "tanh"; + break; + case RELU: + activname = "ReLu"; + break; + case SMRELU: + activname = "SmoothReLU"; + break; + default: + activname = "invalid!"; } switch (network_type) { - case DENSE: - networktypename = "dense"; - break; - case CONVOLUTIONAL: - networktypename = "convolutional"; - break; - default: - networktypename = "invalid!"; + case DENSE: + networktypename = "dense"; + break; + case CONVOLUTIONAL: + networktypename = "convolutional"; + break; + default: + networktypename = "invalid!"; } switch (hessianapprox_type) { - case BFGS_SERIAL: - hessetypename = "BFGS"; - break; - case LBFGS: - hessetypename = "L-BFGS"; - break; - case IDENTITY: - hessetypename = "Identity"; - break; - default: - hessetypename = "invalid!"; + case BFGS_SERIAL: + hessetypename = "BFGS"; + break; + case LBFGS: + hessetypename = "L-BFGS"; + break; + case IDENTITY: + hessetypename = "Identity"; + break; + default: + hessetypename = "invalid!"; } switch (batch_type) { - case DETERMINISTIC: - optimtypename = "deterministic"; - break; - case STOCHASTIC: - optimtypename = "stochastic"; - break; - default: - optimtypename = "invalid!"; + case DETERMINISTIC: + optimtypename = "deterministic"; + break; + case STOCHASTIC: + optimtypename = "stochastic"; + break; + default: + optimtypename = "invalid!"; } switch (stepsize_type) { - case FIXED: - stepsizetypename = "fixed"; - break; - case BACKTRACKINGLS: - stepsizetypename = "backtracking line-search"; - break; - case ONEOVERK: - stepsizetypename = "1/k"; - break; - default: - stepsizetypename = "invalid!"; + case FIXED: + stepsizetypename = "fixed"; + break; + case BACKTRACKINGLS: + stepsizetypename = "backtracking line-search"; + break; + case ONEOVERK: + stepsizetypename = "1/k"; + break; + default: + stepsizetypename = "invalid!"; } /* print config option */ @@ -432,15 +433,15 @@ MyReal Config::getStepsize(int optimiter) { MyReal stepsize = 0.0; switch (stepsize_type) { - case FIXED: - stepsize = stepsize_init; - break; - case BACKTRACKINGLS: - stepsize = stepsize_init; - break; - case ONEOVERK: - stepsize = 1.0 / (MyReal)(optimiter + - 1); // add one because optimiter starts with 0 + case FIXED: + stepsize = stepsize_init; + break; + case BACKTRACKINGLS: + stepsize = stepsize_init; + break; + case ONEOVERK: + stepsize = 1.0 / (MyReal)(optimiter + + 1); // add one because optimiter starts with 0 } return stepsize; diff --git a/src/dataset.cpp b/src/dataset.cpp index 054d502..e9afd77 100644 --- a/src/dataset.cpp +++ b/src/dataset.cpp @@ -17,7 +17,6 @@ DataSet::DataSet() { void DataSet::initialize(int nElements, int nFeatures, int nLabels, int nBatch, MPI_Comm comm) { - nelements = nElements; nfeatures = nFeatures; nlabels = nLabels; @@ -28,8 +27,7 @@ void DataSet::initialize(int nElements, int nFeatures, int nLabels, int nBatch, MPI_Comm_size(comm, &MPIsize); /* Sanity check */ - if (nbatch > nelements) - nbatch = nelements; + if (nbatch > nelements) nbatch = nelements; /* Allocate feature vectors on first processor */ if (MPIrank == 0) { @@ -49,7 +47,7 @@ void DataSet::initialize(int nElements, int nFeatures, int nLabels, int nBatch, /* Allocate and initialize availIDs and batchIDs on first and last processor */ if (MPIrank == 0 || MPIrank == MPIsize - 1) { - availIDs = new int[nelements]; // all elements + availIDs = new int[nelements]; // all elements batchIDs = new int[nbatch]; /* Initialize available ID with identity */ @@ -81,24 +79,20 @@ DataSet::~DataSet() { delete[] labels; } - if (availIDs != NULL) - delete[] availIDs; - if (batchIDs != NULL) - delete[] batchIDs; + if (availIDs != NULL) delete[] availIDs; + if (batchIDs != NULL) delete[] batchIDs; } int DataSet::getnBatch() { return nbatch; } MyReal *DataSet::getExample(int id) { - if (examples == NULL) - return NULL; + if (examples == NULL) return NULL; return examples[batchIDs[id]]; } MyReal *DataSet::getLabel(int id) { - if (labels == NULL) - return NULL; + if (labels == NULL) return NULL; return labels[batchIDs[id]]; } @@ -127,54 +121,52 @@ void DataSet::selectBatch(int batch_type, MPI_Comm comm) { MPI_Status status; switch (batch_type) { - case DETERMINISTIC: - /* Do nothing, keep the batch fixed. */ - break; - - case STOCHASTIC: - - /* Randomly choose a batch on first processor, send to last processor */ - if (MPIrank == 0) { - /* Fill the batchID vector with randomly generated integer */ - rand_range = navail - 1; - for (int ibatch = 0; ibatch < nbatch; ibatch++) { - /* Generate a new random index in [0,range] */ - irand = (int)((((double)rand()) / (double)RAND_MAX) * rand_range); - - /* Set the batchID */ - batchIDs[ibatch] = availIDs[irand]; - - /* Remove the ID from available IDs (by swapping it with the last - * available id and reducing the range) */ - tmp = availIDs[irand]; - availIDs[irand] = availIDs[rand_range]; - availIDs[rand_range] = tmp; - rand_range--; + case DETERMINISTIC: + /* Do nothing, keep the batch fixed. */ + break; + + case STOCHASTIC: + + /* Randomly choose a batch on first processor, send to last processor */ + if (MPIrank == 0) { + /* Fill the batchID vector with randomly generated integer */ + rand_range = navail - 1; + for (int ibatch = 0; ibatch < nbatch; ibatch++) { + /* Generate a new random index in [0,range] */ + irand = (int)((((double)rand()) / (double)RAND_MAX) * rand_range); + + /* Set the batchID */ + batchIDs[ibatch] = availIDs[irand]; + + /* Remove the ID from available IDs (by swapping it with the last + * available id and reducing the range) */ + tmp = availIDs[irand]; + availIDs[irand] = availIDs[rand_range]; + availIDs[rand_range] = tmp; + rand_range--; + } + + /* Send to the last processor */ + int receiver = MPIsize - 1; + MPI_Isend(batchIDs, nbatch, MPI_INT, receiver, 0, comm, &sendreq); } - /* Send to the last processor */ - int receiver = MPIsize - 1; - MPI_Isend(batchIDs, nbatch, MPI_INT, receiver, 0, comm, &sendreq); - } - - /* Receive the batch IDs on last processor */ - if (MPIrank == MPIsize - 1) { - int source = 0; - MPI_Irecv(batchIDs, nbatch, MPI_INT, source, 0, comm, &recvreq); - } + /* Receive the batch IDs on last processor */ + if (MPIrank == MPIsize - 1) { + int source = 0; + MPI_Irecv(batchIDs, nbatch, MPI_INT, source, 0, comm, &recvreq); + } - /* Wait to finish communication */ - if (MPIrank == 0) - MPI_Wait(&sendreq, &status); - if (MPIrank == MPIsize - 1) - MPI_Wait(&recvreq, &status); + /* Wait to finish communication */ + if (MPIrank == 0) MPI_Wait(&sendreq, &status); + if (MPIrank == MPIsize - 1) MPI_Wait(&recvreq, &status); - break; // break switch statement + break; // break switch statement } } void DataSet::printBatch() { - if (batchIDs != NULL) // only first and last processor + if (batchIDs != NULL) // only first and last processor { printf("%d:\n", MPIrank); for (int ibatch = 0; ibatch < nbatch; ibatch++) { diff --git a/src/hessianApprox.cpp b/src/hessianApprox.cpp index 2c8cc9f..5f2a83d 100644 --- a/src/hessianApprox.cpp +++ b/src/hessianApprox.cpp @@ -99,7 +99,6 @@ void L_BFGS::computeAscentDir(int iter, MyReal *gradient, MyReal *ascentdir) { } void L_BFGS::updateMemory(int iter, MyReal *design, MyReal *gradient) { - /* Update lbfgs memory only if iter > 0 */ if (iter > 0) { MyReal yTy, yTs; @@ -154,8 +153,9 @@ BFGS::BFGS(MPI_Comm comm, int N) : HessianApprox(comm) { int size; MPI_Comm_size(MPIcomm, &size); if (size > 1) - printf("\n\n WARNING: Parallel BFGS not implemented.\n BFGS updates will " - "be LOCAL to each processor -> block-BFGS. \n\n"); + printf( + "\n\n WARNING: Parallel BFGS not implemented.\n BFGS updates will " + "be LOCAL to each processor -> block-BFGS. \n\n"); } void BFGS::setIdentity() { diff --git a/src/layer.cpp b/src/layer.cpp index 15ee1e2..4d24770 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -100,20 +100,20 @@ void Layer::print_data(MyReal *data) { MyReal Layer::activation(MyReal x) { MyReal y; switch (activ) { - case TANH: - y = Layer::tanh_act(x); - break; - case RELU: - y = Layer::ReLu_act(x); - break; - case SMRELU: - y = Layer::SmoothReLu_act(x); - break; - default: - y = -1000000.0; - printf("ERROR: You should specify an activation function!\n"); - printf("GO HOME AND GET SOME SLEEP!"); - break; + case TANH: + y = Layer::tanh_act(x); + break; + case RELU: + y = Layer::ReLu_act(x); + break; + case SMRELU: + y = Layer::SmoothReLu_act(x); + break; + default: + y = -1000000.0; + printf("ERROR: You should specify an activation function!\n"); + printf("GO HOME AND GET SOME SLEEP!"); + break; } return y; } @@ -121,20 +121,20 @@ MyReal Layer::activation(MyReal x) { MyReal Layer::dactivation(MyReal x) { MyReal y; switch (activ) { - case TANH: - y = Layer::dtanh_act(x); - break; - case RELU: - y = Layer::dReLu_act(x); - break; - case SMRELU: - y = Layer::dSmoothReLu_act(x); - break; - default: - y = -1000000.0; - printf("ERROR: You should specify an activation function!\n"); - printf("GO HOME AND GET SOME SLEEP!"); - break; + case TANH: + y = Layer::dtanh_act(x); + break; + case RELU: + y = Layer::dReLu_act(x); + break; + case SMRELU: + y = Layer::dSmoothReLu_act(x); + break; + default: + y = -1000000.0; + printf("ERROR: You should specify an activation function!\n"); + printf("GO HOME AND GET SOME SLEEP!"); + break; } return y; } @@ -220,8 +220,7 @@ void Layer::evalTikh_diff(MyReal regul_bar) { } MyReal Layer::evalRegulDDT(Layer *layer_prev, MyReal deltat) { - if (layer_prev == NULL) - return 0.0; // this holds for opening layer + if (layer_prev == NULL) return 0.0; // this holds for opening layer MyReal diff; MyReal regul_ddt = 0.0; @@ -248,11 +247,8 @@ MyReal Layer::evalRegulDDT(Layer *layer_prev, MyReal deltat) { void Layer::evalRegulDDT_diff(Layer *layer_prev, Layer *layer_next, MyReal deltat) { - - if (layer_prev == NULL) - return; - if (layer_next == NULL) - return; + if (layer_prev == NULL) return; + if (layer_next == NULL) return; MyReal diff; int regul_bar = gamma_ddt / (deltat * deltat); @@ -319,7 +315,6 @@ void DenseLayer::applyFWD(MyReal *state) { void DenseLayer::applyBWD(MyReal *state, MyReal *state_bar, int compute_gradient) { - /* state_bar is the adjoint of the state variable, it contains the old time adjoint informationk, and is modified on the way out to contain the update. */ @@ -337,8 +332,7 @@ void DenseLayer::applyBWD(MyReal *state, MyReal *state_bar, /* Derivative of linear transformation */ for (int io = 0; io < dim_Out; io++) { /* Derivative of bias addition */ - if (compute_gradient) - bias_bar[0] += update_bar[io]; + if (compute_gradient) bias_bar[0] += update_bar[io]; /* Derivative of weight application */ for (int ii = 0; ii < dim_In; ii++) { @@ -523,8 +517,9 @@ void ClassificationLayer::applyFWD(MyReal *state) { normalize(update); if (dim_In < dim_Out) { - printf("Error: nchannels < nclasses. Implementation of classification " - "layer doesn't support this setting. Change! \n"); + printf( + "Error: nchannels < nclasses. Implementation of classification " + "layer doesn't support this setting. Change! \n"); exit(1); } @@ -561,8 +556,7 @@ void ClassificationLayer::applyBWD(MyReal *state, MyReal *state_bar, /* Derivatie of affine transformation */ for (int io = 0; io < dim_Out; io++) { /* Derivative of bias addition */ - if (compute_gradient) - bias_bar[io] += update_bar[io]; + if (compute_gradient) bias_bar[io] += update_bar[io]; /* Derivative of weight application */ for (int ii = 0; ii < dim_In; ii++) { @@ -574,7 +568,6 @@ void ClassificationLayer::applyBWD(MyReal *state, MyReal *state_bar, } void ClassificationLayer::normalize(MyReal *data) { - /* Find maximum value */ MyReal max = vecmax(dim_Out, data); /* Shift the data vector */ @@ -673,8 +666,7 @@ int ClassificationLayer::prediction(MyReal *data_Out, int *class_id_ptr) { MyReal Layer::ReLu_act(MyReal x) { MyReal max = 0.0; - if (x > 0.0) - max = x; + if (x > 0.0) max = x; return max; } @@ -763,11 +755,10 @@ ConvLayer::~ConvLayer() {} * Where state_bar _must_ be at the old time. Note that the adjoint variable * state_bar carries withit all the information of the objective derivative. */ -MyReal -ConvLayer::updateWeightDerivative(MyReal *state, MyReal *update_bar, - int output_conv, /* output convolution */ - int j, /* pixel index */ - int k) /* pixel index */ +MyReal ConvLayer::updateWeightDerivative( + MyReal *state, MyReal *update_bar, int output_conv, /* output convolution */ + int j, /* pixel index */ + int k) /* pixel index */ { MyReal val = 0; @@ -778,14 +769,10 @@ ConvLayer::updateWeightDerivative(MyReal *state, MyReal *update_bar, int fcsize_s_l_adj = -fcsize; int fcsize_t_l_adj = -fcsize; - if ((j + fcsize_s_l) < 0) - fcsize_s_l = -j; - if ((k + fcsize_t_l) < 0) - fcsize_t_l = -k; - if ((j + fcsize_s_u) >= img_size_sqrt) - fcsize_s_u = img_size_sqrt - j - 1; - if ((k + fcsize_t_u) >= img_size_sqrt) - fcsize_t_u = img_size_sqrt - k - 1; + if ((j + fcsize_s_l) < 0) fcsize_s_l = -j; + if ((k + fcsize_t_l) < 0) fcsize_t_l = -k; + if ((j + fcsize_s_u) >= img_size_sqrt) fcsize_s_u = img_size_sqrt - j - 1; + if ((k + fcsize_t_u) >= img_size_sqrt) fcsize_t_u = img_size_sqrt - k - 1; if ((j - fcsize_s_l_adj) >= img_size_sqrt) fcsize_s_l_adj = -(img_size_sqrt - j - 1); @@ -848,14 +835,10 @@ MyReal ConvLayer::apply_conv(MyReal *state, int fcsize_t_u = fcsize; // protect indexing at image boundaries - if ((j + fcsize_s_l) < 0) - fcsize_s_l = -j; - if ((k + fcsize_t_l) < 0) - fcsize_t_l = -k; - if ((j + fcsize_s_u) >= img_size_sqrt) - fcsize_s_u = img_size_sqrt - j - 1; - if ((k + fcsize_t_u) >= img_size_sqrt) - fcsize_t_u = img_size_sqrt - k - 1; + if ((j + fcsize_s_l) < 0) fcsize_s_l = -j; + if ((k + fcsize_t_l) < 0) fcsize_t_l = -k; + if ((j + fcsize_s_u) >= img_size_sqrt) fcsize_s_u = img_size_sqrt - j - 1; + if ((k + fcsize_t_u) >= img_size_sqrt) fcsize_t_u = img_size_sqrt - k - 1; const int fcsize_s = fcsize_s_u - fcsize_s_l; const int fcsize_t = fcsize_t_u - fcsize_t_l; @@ -897,14 +880,10 @@ MyReal ConvLayer::apply_conv_trans(MyReal *state, int fcsize_t_l = -fcsize; int fcsize_t_u = fcsize; - if ((j - fcsize_s_u) < 0) - fcsize_s_u = j; - if ((k - fcsize_t_u) < 0) - fcsize_t_u = k; - if ((j - fcsize_s_l) >= img_size_sqrt) - fcsize_s_l = -(img_size_sqrt - j - 1); - if ((k - fcsize_t_l) >= img_size_sqrt) - fcsize_t_l = -(img_size_sqrt - k - 1); + if ((j - fcsize_s_u) < 0) fcsize_s_u = j; + if ((k - fcsize_t_u) < 0) fcsize_t_u = k; + if ((j - fcsize_s_l) >= img_size_sqrt) fcsize_s_l = -(img_size_sqrt - j - 1); + if ((k - fcsize_t_l) >= img_size_sqrt) fcsize_t_l = -(img_size_sqrt - k - 1); const int fcsize_s = fcsize_s_u - fcsize_s_l; const int fcsize_t = fcsize_t_u - fcsize_t_l; @@ -936,8 +915,7 @@ MyReal ConvLayer::apply_conv_trans(MyReal *state, void ConvLayer::applyFWD(MyReal *state) { /* Apply step */ - for (int io = 0; io < dim_Out; io++) - update[io] = state[io]; + for (int io = 0; io < dim_Out; io++) update[io] = state[io]; /* Affine transformation */ for (int i = 0; i < nconv; i++) { @@ -1048,5 +1026,5 @@ void ConvLayer::applyBWD(MyReal *state, MyReal *state_bar, } } - } // end for i + } // end for i } diff --git a/src/linalg.cpp b/src/linalg.cpp index c51b6f5..0345661 100644 --- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -1,7 +1,6 @@ #include "linalg.hpp" MyReal vecdot_par(int dimN, MyReal *x, MyReal *y, MPI_Comm comm) { - MyReal localdot, globaldot; localdot = vecdot(dimN, x, y); diff --git a/src/main.cpp b/src/main.cpp index 1898ea8..bbc654b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) { validationdata->initialize(config->nvalidation, config->nfeatures, config->nclasses, config->nvalidation, - MPI_COMM_WORLD); // full validation set! + MPI_COMM_WORLD); // full validation set! validationdata->readData(config->datafolder, config->fval_ex, config->fval_labels); @@ -121,8 +121,7 @@ int main(int argc, char *argv[]) { /* Print some network information */ int startid = ilower; - if (ilower == 0) - startid = -1; + if (ilower == 0) startid = -1; printf("%d: Layer range: [%d, %d] / %d\n", myid, startid, iupper, config->nlayers); printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, @@ -131,14 +130,14 @@ int main(int argc, char *argv[]) { /* Initialize hessian approximation */ HessianApprox *hessian = 0; switch (config->hessianapprox_type) { - case BFGS_SERIAL: - hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); - break; - case LBFGS: - hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); - break; - case IDENTITY: - hessian = new Identity(MPI_COMM_WORLD, ndesign_local); + case BFGS_SERIAL: + hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); + break; + case LBFGS: + hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); + break; + case IDENTITY: + hessian = new Identity(MPI_COMM_WORLD, ndesign_local); } /* Allocate ascent direction for design updates */ @@ -166,9 +165,10 @@ int main(int argc, char *argv[]) { "Accur_train Accur_val Time(sec)\n"); /* Screen output */ - printf("\n# || r || || r_adj || Objective " - "Loss || grad || Stepsize ls_iter " - "Accur_train Accur_val Time(sec)\n"); + printf( + "\n# || r || || r_adj || Objective " + "Loss || grad || Stepsize ls_iter " + "Accur_train Accur_val Time(sec)\n"); } #if 1 @@ -177,7 +177,6 @@ int main(int argc, char *argv[]) { StopTime = 0.0; UsedTime = 0.0; for (int iter = 0; iter < config->maxoptimiter; iter++) { - /* --- Training data: Get objective and gradient ---*/ /* Set up the current batch */ @@ -220,10 +219,11 @@ int main(int argc, char *argv[]) { StopTime = MPI_Wtime(); UsedTime = StopTime - StartTime; if (myid == MASTER_NODE) { - printf("%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " - "%2.2f%% %2.2f%% %.1f\n", - iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, - ls_iter, accurtrain_out, accurval_out, UsedTime); + printf( + "%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " + "%2.2f%% %2.2f%% %.1f\n", + iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, + ls_iter, accurtrain_out, accurval_out, UsedTime); fprintf(optimfile, "%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " "%2.2f%% %2.2f%% %.1f\n", @@ -268,7 +268,6 @@ int main(int argc, char *argv[]) { ls_stepsize = config->getStepsize(iter); stepsize = ls_stepsize; for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) { - primaltrainapp->getCore()->SetPrintLevel(0); primaltrainapp->run(); ls_objective = primaltrainapp->getObjective(); @@ -304,8 +303,7 @@ int main(int argc, char *argv[]) { /* --- Run final validation and write prediction file --- */ if (config->validationlevel > -1) { - if (myid == MASTER_NODE) - printf("\n --- Run final validation ---\n"); + if (myid == MASTER_NODE) printf("\n --- Run final validation ---\n"); primalvalapp->getCore()->SetPrintLevel(0); primalvalapp->run(); diff --git a/src/network.cpp b/src/network.cpp index 9b85664..3e184a6 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -35,13 +35,14 @@ void Network::createNetworkBlock(int StartLayerID, int EndLayerID, nlayers_local = endlayerID - startlayerID + 1; nlayers_global = config->nlayers; nchannels = config->nchannels; - dt = (config->T) / (MyReal)(config->nlayers - 2); // nlayers-2 = nhiddenlayers + dt = + (config->T) / (MyReal)(config->nlayers - 2); // nlayers-2 = nhiddenlayers comm = Comm; /* --- Create the layers --- */ ndesign_local = 0; - if (startlayerID == 0) // Opening layer + if (startlayerID == 0) // Opening layer { /* Create the opening layer */ int index = -1; @@ -51,7 +52,7 @@ void Network::createNetworkBlock(int StartLayerID, int EndLayerID, // openlayer->getnDesign()); } - layers = new Layer *[nlayers_local]; // Intermediate and classification layer + layers = new Layer *[nlayers_local]; // Intermediate and classification layer for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { /* Create a layer at time step ilayer. Local storage at ilayer - * startlayerID */ @@ -82,13 +83,13 @@ void Network::createNetworkBlock(int StartLayerID, int EndLayerID, /* Set the memory locations for all layers */ int istart = 0; - if (openlayer != NULL) // Openlayer on first processor + if (openlayer != NULL) // Openlayer on first processor { openlayer->setMemory(&(design[istart]), &(gradient[istart])); istart += openlayer->getnDesign(); } for (int ilayer = startlayerID; ilayer <= endlayerID; - ilayer++) // intermediate and hidden layers + ilayer++) // intermediate and hidden layers { layers[getLocalID(ilayer)]->setMemory(&(design[istart]), &(gradient[istart])); @@ -111,8 +112,7 @@ void Network::createNetworkBlock(int StartLayerID, int EndLayerID, Network::~Network() { /* Delete openlayer */ - if (openlayer != NULL) - delete openlayer; + if (openlayer != NULL) delete openlayer; /* Delete intermediate and classification layers */ for (int ilayer = 0; ilayer < nlayers_local; ilayer++) { @@ -168,44 +168,44 @@ MPI_Comm Network::getComm() { return comm; } Layer *Network::createLayer(int index, Config *config) { Layer *layer = 0; - if (index == -1) // Opening layer + if (index == -1) // Opening layer { switch (config->network_type) { - case DENSE: - if (config->weights_open_init == 0.0) { - layer = new OpenExpandZero(config->nfeatures, nchannels); - } else { - layer = new OpenDenseLayer(config->nfeatures, nchannels, - config->activation, config->gamma_tik); - } - break; - case CONVOLUTIONAL: - /**< (Weight_open_init == 0.0) not needed for convolutional layers*/ - if (config->openlayer_type == 0) { - layer = new OpenConvLayer(config->nfeatures, nchannels); - } else if (config->openlayer_type == 1) { - layer = new OpenConvLayerMNIST(config->nfeatures, nchannels); - } - break; + case DENSE: + if (config->weights_open_init == 0.0) { + layer = new OpenExpandZero(config->nfeatures, nchannels); + } else { + layer = new OpenDenseLayer(config->nfeatures, nchannels, + config->activation, config->gamma_tik); + } + break; + case CONVOLUTIONAL: + /**< (Weight_open_init == 0.0) not needed for convolutional layers*/ + if (config->openlayer_type == 0) { + layer = new OpenConvLayer(config->nfeatures, nchannels); + } else if (config->openlayer_type == 1) { + layer = new OpenConvLayerMNIST(config->nfeatures, nchannels); + } + break; } - } else if (0 <= index && index < nlayers_global - 2) // Intermediate layer + } else if (0 <= index && index < nlayers_global - 2) // Intermediate layer { switch (config->network_type) { - case DENSE: - layer = - new DenseLayer(index, nchannels, nchannels, dt, config->activation, - config->gamma_tik, config->gamma_ddt); - break; - case CONVOLUTIONAL: - // TODO: Fix - int convolution_size = 3; - layer = - new ConvLayer(index, nchannels, nchannels, convolution_size, - nchannels / config->nfeatures, dt, config->activation, - config->gamma_tik, config->gamma_ddt); - break; + case DENSE: + layer = + new DenseLayer(index, nchannels, nchannels, dt, config->activation, + config->gamma_tik, config->gamma_ddt); + break; + case CONVOLUTIONAL: + // TODO: Fix + int convolution_size = 3; + layer = + new ConvLayer(index, nchannels, nchannels, convolution_size, + nchannels / config->nfeatures, dt, config->activation, + config->gamma_tik, config->gamma_ddt); + break; } - } else if (index == nlayers_global - 2) // Classification layer + } else if (index == nlayers_global - 2) // Classification layer { layer = new ClassificationLayer(index, nchannels, config->nclasses, config->gamma_class); @@ -219,7 +219,7 @@ Layer *Network::createLayer(int index, Config *config) { Layer *Network::getLayer(int layerindex) { Layer *layer; - if (layerindex == -1) // opening layer + if (layerindex == -1) // opening layer { layer = openlayer; } else if (layerindex == startlayerID - 1) { @@ -243,12 +243,11 @@ int Network::computeLayermax() { /* Loop over all local layers */ for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { - if (ilayer < nlayers_global - 2) // excludes classification layer + if (ilayer < nlayers_global - 2) // excludes classification layer { /* Update maximum */ ndesignlayer = layers[getLocalID(ilayer)]->getnDesign(); - if (ndesignlayer > max) - max = ndesignlayer; + if (ndesignlayer > max) max = ndesignlayer; } } @@ -295,10 +294,10 @@ void Network::setInitialDesign(Config *config) { /* Intermediate (hidden) and classification layers */ for (int ilayer = startlayerID; ilayer <= endlayerID; ilayer++) { - if (ilayer < nlayers_global - 1) // Intermediate layer + if (ilayer < nlayers_global - 1) // Intermediate layer { factor = config->weights_init; - } else // Classification layer + } else // Classification layer { factor = config->weights_class_init; } @@ -321,8 +320,7 @@ void Network::setInitialDesign(Config *config) { /* Communicate the neighbours across processors */ MPI_CommunicateNeighbours(comm); - if (myid == 0) - delete[] design_init; + if (myid == 0) delete[] design_init; } void Network::MPI_CommunicateNeighbours(MPI_Comm comm) { @@ -397,14 +395,10 @@ void Network::MPI_CommunicateNeighbours(MPI_Comm comm) { } /* Wait to finish up communication */ - if (myid > 0) - MPI_Wait(&recvlastreq, &status); - if (myid < comm_size - 1) - MPI_Wait(&sendlastreq, &status); - if (myid < comm_size - 1) - MPI_Wait(&recvfirstreq, &status); - if (myid > 0) - MPI_Wait(&sendfirstreq, &status); + if (myid > 0) MPI_Wait(&recvlastreq, &status); + if (myid < comm_size - 1) MPI_Wait(&sendlastreq, &status); + if (myid < comm_size - 1) MPI_Wait(&recvfirstreq, &status); + if (myid > 0) MPI_Wait(&sendfirstreq, &status); /* Unpack and store the left received layer */ if (myid > 0) { @@ -417,14 +411,10 @@ void Network::MPI_CommunicateNeighbours(MPI_Comm comm) { } /* Free the buffer */ - if (sendlast != 0) - delete[] sendlast; - if (recvlast != 0) - delete[] recvlast; - if (sendfirst != 0) - delete[] sendfirst; - if (recvfirst != 0) - delete[] recvfirst; + if (sendlast != 0) delete[] sendlast; + if (recvlast != 0) delete[] recvlast; + if (sendfirst != 0) delete[] sendfirst; + if (recvfirst != 0) delete[] recvfirst; } void Network::evalClassification(DataSet *data, MyReal **state, int output) { @@ -444,8 +434,7 @@ void Network::evalClassification(DataSet *data, MyReal **state, int output) { } /* open file for printing predicted file */ - if (output) - classfile = fopen("classprediction.dat", "w"); + if (output) classfile = fopen("classprediction.dat", "w"); loss = 0.0; accuracy = 0.0; @@ -463,8 +452,7 @@ void Network::evalClassification(DataSet *data, MyReal **state, int output) { loss += classificationlayer->crossEntropy(tmpstate); success_local = classificationlayer->prediction(tmpstate, &class_id); success += success_local; - if (output) - fprintf(classfile, "%d %d\n", class_id, success_local); + if (output) fprintf(classfile, "%d %d\n", class_id, success_local); } loss = 1. / data->getnBatch() * loss; accuracy = 100.0 * ((MyReal)success) / data->getnBatch(); @@ -472,10 +460,8 @@ void Network::evalClassification(DataSet *data, MyReal **state, int output) { // tmpstate[0] %1.14e\n", getIndex(), loss, weights[0], state[1][1], // tmpstate[0]); - if (output) - fclose(classfile); - if (output) - printf("Prediction file written: classprediction.dat\n"); + if (output) fclose(classfile); + if (output) printf("Prediction file written: classprediction.dat\n"); delete[] tmpstate; } From 788cb0c190f33a8569456132ff79a33ceaccaec7 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Thu, 11 Jul 2019 20:20:18 +0200 Subject: [PATCH 11/38] Add .idea to .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 0cce01a..04905f2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ build/ *run_* *optim.dat main + +.idea From 4c7b8ec1b727fbca88fa9a56542315e780a37aa4 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Thu, 11 Jul 2019 20:25:34 +0200 Subject: [PATCH 12/38] Add comment to explain .idea exclusion to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 04905f2..507ad72 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ build/ *optim.dat main +# Ignore IDE configurations .idea From 2631d3602225be1e958e891ca5e36dea61229e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=87=C9=B9=C7=9Dq=C6=83=C7=9D=E1=B4=89s=20pu=C9=90lo?= =?UTF-8?q?=C9=B9?= Date: Fri, 12 Jul 2019 14:15:40 +0200 Subject: [PATCH 13/38] Fix linebreak according to comments in review --- src/network.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/network.cpp b/src/network.cpp index 3e184a6..82f02d0 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -35,8 +35,7 @@ void Network::createNetworkBlock(int StartLayerID, int EndLayerID, nlayers_local = endlayerID - startlayerID + 1; nlayers_global = config->nlayers; nchannels = config->nchannels; - dt = - (config->T) / (MyReal)(config->nlayers - 2); // nlayers-2 = nhiddenlayers + dt = (config->T) / (MyReal)(config->nlayers - 2); // nlayers-2 = nhiddenlayers comm = Comm; /* --- Create the layers --- */ @@ -512,4 +511,4 @@ void Network::updateDesign(MyReal stepsize, MyReal *direction, MPI_Comm comm) { /* Communicate design across neighbouring processors (ghostlayers) */ MPI_CommunicateNeighbours(comm); -} \ No newline at end of file +} From 71c65db58617eac5f984f73401261ca10121258e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=87=C9=B9=C7=9Dq=C6=83=C7=9D=E1=B4=89s=20pu=C9=90lo?= =?UTF-8?q?=C9=B9?= Date: Fri, 12 Jul 2019 14:35:55 +0200 Subject: [PATCH 14/38] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2d788a2..21e2123 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,4 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold - [ ] Dependency Inversion * [ ] Extract methods and clean up objects * [ ] Comment everything +* [ ] Park old code in separate branches and tag them as deprecated From 0abbaeec5088baa3004bd211b9a2cba39bf19e41 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Wed, 10 Jul 2019 20:08:35 +0200 Subject: [PATCH 15/38] Walk through main and understand / add TODOs --- src/main.cpp | 151 ++++++++++++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 69 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bbc654b..3e019af 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,8 @@ #define MASTER_NODE 0 -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ /* --- Data --- */ Config *config; /**< Storing configurations */ DataSet *trainingdata; /**< Training dataset */ @@ -24,7 +25,7 @@ int main(int argc, char *argv[]) { /* --- Network --- */ Network *network; /**< DNN Network architecture */ int ilower, - iupper; /**< Index of first and last layer stored on this processor */ + iupper; /**< Index of first and last layer stored on this processor */ MyReal accur_train = 0.0; /**< Accuracy on training data */ MyReal accur_val = 0.0; /**< Accuracy on validation data */ MyReal loss_train = 0.0; /**< Loss function on training data */ @@ -40,8 +41,8 @@ int main(int argc, char *argv[]) { myBraidApp *primalvalapp; /**< Braid App for validation data */ /* --- Optimization --- */ - int ndesign_local; /**< Number of local design variables on this processor */ - int ndesign_global; /**< Number of global design variables (sum of local)*/ + int ndesign_local; /**< Number of local design variables on this processor */ + int ndesign_global; /**< Number of global design variables (sum of local)*/ MyReal *ascentdir = 0; /**< Direction for design updates */ MyReal objective; /**< Optimization objective */ MyReal wolfe; /**< Holding the wolfe condition value */ @@ -57,6 +58,7 @@ int main(int argc, char *argv[]) { int ls_iter; /* --- other --- */ + // TODO: What is this? Why do you need it? int myid; int size; struct rusage r_usage; @@ -68,8 +70,6 @@ int main(int argc, char *argv[]) { MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_size(MPI_COMM_WORLD, &size); - /*--- INITIALIZATION ---*/ - /* Instantiate objects */ config = new Config(); trainingdata = new DataSet(); @@ -77,19 +77,22 @@ int main(int argc, char *argv[]) { network = new Network(); /* Read config file */ - if (argc != 2) { - if (myid == MASTER_NODE) { + if (argc != 2) + { + if (myid == MASTER_NODE) + { printf("\n"); printf("USAGE: ./main \n"); } MPI_Finalize(); - return (0); + return 0; } int err = config->readFromFile(argv[1]); - if (err) { - printf("\nError while reading config file!\n"); + if (err) + { + printf("Error while reading config file!\n"); MPI_Finalize(); - return (0); + return 0; } /* Initialize training and validation data */ @@ -100,17 +103,15 @@ int main(int argc, char *argv[]) { validationdata->initialize(config->nvalidation, config->nfeatures, config->nclasses, config->nvalidation, - MPI_COMM_WORLD); // full validation set! + MPI_COMM_WORLD); // full validation set! validationdata->readData(config->datafolder, config->fval_ex, config->fval_labels); /* Initialize XBraid */ - primaltrainapp = - new myBraidApp(trainingdata, network, config, MPI_COMM_WORLD); - adjointtrainapp = new myAdjointBraidApp( - trainingdata, network, config, primaltrainapp->getCore(), MPI_COMM_WORLD); - primalvalapp = - new myBraidApp(validationdata, network, config, MPI_COMM_WORLD); + primaltrainapp = new myBraidApp(trainingdata, network, config, MPI_COMM_WORLD); + adjointtrainapp = new myAdjointBraidApp(trainingdata, network, config, + primaltrainapp->getCore(), MPI_COMM_WORLD); + primalvalapp = new myBraidApp(validationdata, network, config, MPI_COMM_WORLD); /* Initialize the network */ primaltrainapp->GetGridDistribution(&ilower, &iupper); @@ -119,25 +120,26 @@ int main(int argc, char *argv[]) { ndesign_local = network->getnDesignLocal(); ndesign_global = network->getnDesignGlobal(); - /* Print some network information */ - int startid = ilower; - if (ilower == 0) startid = -1; - printf("%d: Layer range: [%d, %d] / %d\n", myid, startid, iupper, - config->nlayers); - printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, - ndesign_global); + /* Print some neural network information */ + printf("%d: Layer range: [%d, %d] / %d\n", myid, ilower, iupper, config->nlayers); + printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, ndesign_global); - /* Initialize hessian approximation */ + /* Initialize Hessian approximation */ HessianApprox *hessian = 0; - switch (config->hessianapprox_type) { - case BFGS_SERIAL: - hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); - break; - case LBFGS: - hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); - break; - case IDENTITY: - hessian = new Identity(MPI_COMM_WORLD, ndesign_local); + switch (config->hessianapprox_type) + { + case BFGS_SERIAL: + hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); + break; + case LBFGS: + hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); + break; + case IDENTITY: + hessian = new Identity(MPI_COMM_WORLD, ndesign_local); + break; + default: + printf("Error: unexpected hessianapprox_type returned"); + return 0; } /* Allocate ascent direction for design updates */ @@ -154,7 +156,8 @@ int main(int argc, char *argv[]) { ls_stepsize = stepsize; /* Open and prepare optimization output file*/ - if (myid == MASTER_NODE) { + if (myid == MASTER_NODE) + { sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); optimfile = fopen(optimfilename, "w"); config->writeToFile(optimfile); @@ -171,12 +174,14 @@ int main(int argc, char *argv[]) { "Accur_train Accur_val Time(sec)\n"); } + // TODO: WTF? This is "enabled"? Looks like testing code to me... #if 1 /* --- OPTIMIZATION --- */ StartTime = MPI_Wtime(); StopTime = 0.0; UsedTime = 0.0; - for (int iter = 0; iter < config->maxoptimiter; iter++) { + for (int iter = 0; iter < config->maxoptimiter; iter++) + { /* --- Training data: Get objective and gradient ---*/ /* Set up the current batch */ @@ -193,7 +198,8 @@ int main(int argc, char *argv[]) { /* --- Validation data: Get accuracy --- */ - if (config->validationlevel > 0) { + if (config->validationlevel > 0) + { primalvalapp->run(); loss_val = network->getLoss(); accur_val = network->getAccuracy(); @@ -206,19 +212,16 @@ int main(int argc, char *argv[]) { /* Communicate loss and accuracy. This is actually only needed for output. * Remove it. */ - MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, - MPI_COMM_WORLD); - MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, - MPI_COMM_WORLD); - MPI_Allreduce(&accur_train, &accurtrain_out, 1, MPI_MyReal, MPI_SUM, - MPI_COMM_WORLD); - MPI_Allreduce(&accur_val, &accurval_out, 1, MPI_MyReal, MPI_SUM, - MPI_COMM_WORLD); + MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&accur_train, &accurtrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&accur_val, &accurval_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); /* Output */ StopTime = MPI_Wtime(); UsedTime = StopTime - StartTime; - if (myid == MASTER_NODE) { + if (myid == MASTER_NODE) + { printf( "%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " "%2.2f%% %2.2f%% %.1f\n", @@ -233,15 +236,19 @@ int main(int argc, char *argv[]) { } /* Check optimization convergence */ - if (gnorm < config->gtol) { - if (myid == MASTER_NODE) { + if (gnorm < config->gtol) + { + if (myid == MASTER_NODE) + { printf("Optimization has converged. \n"); printf("Be happy and go home! \n"); } break; } - if (iter == config->maxoptimiter - 1) { - if (myid == MASTER_NODE) { + if (iter == config->maxoptimiter - 1) + { + if (myid == MASTER_NODE) + { printf("\nMax. optimization iterations reached.\n"); } break; @@ -259,15 +266,16 @@ int main(int argc, char *argv[]) { /* --- Backtracking linesearch --- */ - if (config->stepsize_type == BACKTRACKINGLS) { + if (config->stepsize_type == BACKTRACKINGLS) + { /* Compute wolfe condition */ - wolfe = vecdot_par(ndesign_local, network->getGradient(), ascentdir, - MPI_COMM_WORLD); + wolfe = vecdot_par(ndesign_local, network->getGradient(), ascentdir, MPI_COMM_WORLD); /* Start linesearch iterations */ ls_stepsize = config->getStepsize(iter); stepsize = ls_stepsize; - for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) { + for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) + { primaltrainapp->getCore()->SetPrintLevel(0); primaltrainapp->run(); ls_objective = primaltrainapp->getObjective(); @@ -278,20 +286,23 @@ int main(int argc, char *argv[]) { printf("ls_iter %d: %1.14e %1.14e\n", ls_iter, ls_objective, test_obj); /* Test the wolfe condition */ - if (ls_objective <= test_obj) { + if (ls_objective <= test_obj) + { /* Success, use this new design */ break; - } else { + } + else + { /* Test for line-search failure */ - if (ls_iter == config->ls_maxiter - 1) { + if (ls_iter == config->ls_maxiter - 1) + { if (myid == MASTER_NODE) printf("\n\n WARNING: LINESEARCH FAILED! \n\n"); break; } /* Go back part of the step */ - network->updateDesign((1.0 - config->ls_factor) * stepsize, ascentdir, - MPI_COMM_WORLD); + network->updateDesign((1.0 - config->ls_factor) * stepsize, ascentdir, MPI_COMM_WORLD); /* Decrease the stepsize */ ls_stepsize = ls_stepsize * config->ls_factor; @@ -302,8 +313,10 @@ int main(int argc, char *argv[]) { } /* --- Run final validation and write prediction file --- */ - if (config->validationlevel > -1) { - if (myid == MASTER_NODE) printf("\n --- Run final validation ---\n"); + if (config->validationlevel > -1) + { + if (myid == MASTER_NODE) + printf("\n --- Run final validation ---\n"); primalvalapp->getCore()->SetPrintLevel(0); primalvalapp->run(); @@ -315,13 +328,14 @@ int main(int argc, char *argv[]) { // write_vector("design.dat", design, ndesign); #endif -/** + /** * ================================================================================== * Adjoint dot test xbarTxdot = ybarTydot * where xbar = (dfdx)T ybar * ydot = (dfdx) xdot * choosing xdot to be a vector of all ones, ybar = 1.0; * ==================================================================================*/ + // TODO: Why is this disabled? #if 0 if (size == 1) @@ -352,7 +366,6 @@ int main(int argc, char *argv[]) { braid_Drive(core_adj); braid_evalInitDiff(core_adj, app_train); - MyReal xtx = 0.0; MyReal EPS = 1e-7; for (int i = 0; i < ndesign_global; i++) @@ -363,7 +376,6 @@ int main(int argc, char *argv[]) { network->getDesign()[i] += EPS; } - /* New objective function evaluation */ braid_evalInit(core_train, app_train); braid_Drive(core_train); @@ -372,7 +384,6 @@ int main(int argc, char *argv[]) { /* Finite differences */ MyReal yty = (obj1 - obj0)/EPS; - /* Print adjoint dot test result */ printf(" Dot-test: %1.16e %1.16e\n\n Rel. error %3.6f %%\n\n", xtx, yty, (yty-xtx)/xtx * 100.); printf(" obj0 %1.14e, obj1 %1.14e\n", obj0, obj1); @@ -457,7 +468,8 @@ int main(int argc, char *argv[]) { MPI_Allreduce(&myMB, &globalMB, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); // printf("%d; Memory Usage: %.2f MB\n",myid, myMB); - if (myid == MASTER_NODE) { + if (myid == MASTER_NODE) + { printf("\n"); printf(" Used Time: %.2f seconds\n", UsedTime); printf(" Global Memory: %.2f MB\n", globalMB); @@ -481,7 +493,8 @@ int main(int argc, char *argv[]) { delete validationdata; /* Close optim file */ - if (myid == MASTER_NODE) { + if (myid == MASTER_NODE) + { fclose(optimfile); printf("Optimfile: %s\n", optimfilename); } From f9b8c51d4cd96cff7ad9407b916677059e022875 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Wed, 10 Jul 2019 20:37:06 +0200 Subject: [PATCH 16/38] Add full finite differences as option --- src/main.cpp | 150 +++++++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 71 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3e019af..6f13dc6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,8 +15,12 @@ #define MASTER_NODE 0 -int main(int argc, char *argv[]) -{ +// TODO: Can these truly run separate? +#define ADJOINT_DOT_TEST_ENABLED 0 +#define OPTIMIZATION_ENABLED 1 +#define FULL_FINITE_DIFFERENCES_ENABLED 0 + +int main(int argc, char *argv[]) { /* --- Data --- */ Config *config; /**< Storing configurations */ DataSet *trainingdata; /**< Training dataset */ @@ -175,8 +179,8 @@ int main(int argc, char *argv[]) } // TODO: WTF? This is "enabled"? Looks like testing code to me... -#if 1 - /* --- OPTIMIZATION --- */ +#if OPTIMIZATION_ENABLED + StartTime = MPI_Wtime(); StopTime = 0.0; UsedTime = 0.0; @@ -326,7 +330,7 @@ int main(int argc, char *argv[]) } // write_vector("design.dat", design, ndesign); -#endif +#endif // OPTIMIZATION_ENABLED /** * ================================================================================== @@ -335,8 +339,8 @@ int main(int argc, char *argv[]) * ydot = (dfdx) xdot * choosing xdot to be a vector of all ones, ybar = 1.0; * ==================================================================================*/ - // TODO: Why is this disabled? -#if 0 + // TODO: Why is this disabled? +#if ADJOINT_DOT_TEST_ENABLED if (size == 1) { @@ -390,75 +394,79 @@ int main(int argc, char *argv[]) } -#endif +#endif // ADJOINT_DOT_TEST_ENABLED +// TODO: Can we get rid of this or shall we pack it into a parameter? /** ======================================= * Full finite differences * ======================================= */ - // MyReal* findiff = new MyReal[ndesign]; - // MyReal* relerr = new MyReal[ndesign]; - // MyReal errnorm = 0.0; - // MyReal obj0, obj1, design_store; - // MyReal EPS; - - // printf("\n--------------------------------\n"); - // printf(" FINITE DIFFERENCE TESTING\n\n"); - - // /* Compute baseline objective */ - // // read_vector("design.dat", design, ndesign); - // braid_SetObjectiveOnly(core_train, 0); - // braid_Drive(core_train); - // braid_GetObjective(core_train, &objective); - // obj0 = objective; - - // EPS = 1e-4; - // for (int i = 0; i < ndesign; i++) - // // for (int i = 0; i < 22; i++) - // // int i=21; - // { - // /* Restore design */ - // // read_vector("design.dat", design, ndesign); - - // /* Perturb design */ - // design_store = design[i]; - // design[i] += EPS; - - // /* Recompute objective */ - // _braid_CoreElt(core_train, warm_restart) = 0; - // braid_SetObjectiveOnly(core_train, 1); - // braid_SetPrintLevel(core_train, 0); - // braid_Drive(core_train); - // braid_GetObjective(core_train, &objective); - // obj1 = objective; - - // /* Findiff */ - // findiff[i] = (obj1 - obj0) / EPS; - // relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; - // errnorm += pow(relerr[i],2); - - // printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f",i, findiff[i], - // gradient[i], relerr[i] * 100.0); - - // /* Restore design */ - // design[i] = design_store; - // } - // errnorm = sqrt(errnorm); - // printf("\n FinDiff ErrNorm %1.14e\n", errnorm); - - // write_vector("findiff.dat", findiff, ndesign); - // write_vector("relerr.dat", relerr, ndesign); - - /* ======================================= - * check network implementation - * ======================================= */ - // network->applyFWD(config->ntraining, train_examples, train_labels); - // MyReal accur = network->getAccuracy(); - // MyReal regul = network->evalRegularization(); - // objective = network->getLoss() + regul; - // printf("\n --- \n"); - // printf(" Network: obj %1.14e \n", objective); - // printf(" ---\n"); +#if FULL_FINITE_DIFFERENCES_ENABLED + MyReal* findiff = new MyReal[ndesign]; + MyReal* relerr = new MyReal[ndesign]; + MyReal errnorm = 0.0; + MyReal obj0, obj1, design_store; + MyReal EPS; + + printf("\n--------------------------------\n"); + printf(" FINITE DIFFERENCE TESTING\n\n"); + + /* Compute baseline objective */ + // read_vector("design.dat", design, ndesign); + braid_SetObjectiveOnly(core_train, 0); + braid_Drive(core_train); + braid_GetObjective(core_train, &objective); + obj0 = objective; + + EPS = 1e-4; + for (int i = 0; i < ndesign; i++) + // for (int i = 0; i < 22; i++) + // int i=21; + { + /* Restore design */ + // read_vector("design.dat", design, ndesign); + + /* Perturb design */ + design_store = design[i]; + design[i] += EPS; + + /* Recompute objective */ + _braid_CoreElt(core_train, warm_restart) = 0; + braid_SetObjectiveOnly(core_train, 1); + braid_SetPrintLevel(core_train, 0); + braid_Drive(core_train); + braid_GetObjective(core_train, &objective); + obj1 = objective; + + /* Findiff */ + findiff[i] = (obj1 - obj0) / EPS; + relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; + errnorm += pow(relerr[i],2); + + printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f",i, findiff[i], + gradient[i], relerr[i] * 100.0); + + /* Restore design */ + design[i] = design_store; + } + errnorm = sqrt(errnorm); + printf("\n FinDiff ErrNorm %1.14e\n", errnorm); + + write_vector("findiff.dat", findiff, ndesign); + write_vector("relerr.dat", relerr, ndesign); + + ======================================= + check network implementation + ======================================= */ + network->applyFWD(config->ntraining, train_examples, train_labels); + MyReal accur = network->getAccuracy(); + MyReal regul = network->evalRegularization(); + objective = network->getLoss() + regul; + printf("\n --- \n"); + printf(" Network: obj %1.14e \n", objective); + printf(" ---\n"); + +#endif // FULL_FINITE_DIFFERENCES_ENABLED /* Print some statistics */ StopTime = MPI_Wtime(); From 7f25feba769e032d092b9d07b040688ad6169f21 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Fri, 12 Jul 2019 14:31:49 +0200 Subject: [PATCH 17/38] Revision after code style change in develop --- src/main.cpp | 311 +++++++++++++++++++++++++-------------------------- 1 file changed, 150 insertions(+), 161 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6f13dc6..19d1660 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,7 @@ int main(int argc, char *argv[]) { /* --- Network --- */ Network *network; /**< DNN Network architecture */ int ilower, - iupper; /**< Index of first and last layer stored on this processor */ + iupper; /**< Index of first and last layer stored on this processor */ MyReal accur_train = 0.0; /**< Accuracy on training data */ MyReal accur_val = 0.0; /**< Accuracy on validation data */ MyReal loss_train = 0.0; /**< Loss function on training data */ @@ -45,8 +45,8 @@ int main(int argc, char *argv[]) { myBraidApp *primalvalapp; /**< Braid App for validation data */ /* --- Optimization --- */ - int ndesign_local; /**< Number of local design variables on this processor */ - int ndesign_global; /**< Number of global design variables (sum of local)*/ + int ndesign_local; /**< Number of local design variables on this processor */ + int ndesign_global; /**< Number of global design variables (sum of local)*/ MyReal *ascentdir = 0; /**< Direction for design updates */ MyReal objective; /**< Optimization objective */ MyReal wolfe; /**< Holding the wolfe condition value */ @@ -81,10 +81,8 @@ int main(int argc, char *argv[]) { network = new Network(); /* Read config file */ - if (argc != 2) - { - if (myid == MASTER_NODE) - { + if (argc != 2) { + if (myid == MASTER_NODE) { printf("\n"); printf("USAGE: ./main \n"); } @@ -92,8 +90,7 @@ int main(int argc, char *argv[]) { return 0; } int err = config->readFromFile(argv[1]); - if (err) - { + if (err) { printf("Error while reading config file!\n"); MPI_Finalize(); return 0; @@ -107,15 +104,17 @@ int main(int argc, char *argv[]) { validationdata->initialize(config->nvalidation, config->nfeatures, config->nclasses, config->nvalidation, - MPI_COMM_WORLD); // full validation set! + MPI_COMM_WORLD); // full validation set! validationdata->readData(config->datafolder, config->fval_ex, config->fval_labels); /* Initialize XBraid */ - primaltrainapp = new myBraidApp(trainingdata, network, config, MPI_COMM_WORLD); - adjointtrainapp = new myAdjointBraidApp(trainingdata, network, config, - primaltrainapp->getCore(), MPI_COMM_WORLD); - primalvalapp = new myBraidApp(validationdata, network, config, MPI_COMM_WORLD); + primaltrainapp = + new myBraidApp(trainingdata, network, config, MPI_COMM_WORLD); + adjointtrainapp = new myAdjointBraidApp( + trainingdata, network, config, primaltrainapp->getCore(), MPI_COMM_WORLD); + primalvalapp = + new myBraidApp(validationdata, network, config, MPI_COMM_WORLD); /* Initialize the network */ primaltrainapp->GetGridDistribution(&ilower, &iupper); @@ -125,25 +124,26 @@ int main(int argc, char *argv[]) { ndesign_global = network->getnDesignGlobal(); /* Print some neural network information */ - printf("%d: Layer range: [%d, %d] / %d\n", myid, ilower, iupper, config->nlayers); - printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, ndesign_global); + printf("%d: Layer range: [%d, %d] / %d\n", myid, ilower, iupper, + config->nlayers); + printf("%d: Design variables (local/global): %d/%d\n", myid, ndesign_local, + ndesign_global); /* Initialize Hessian approximation */ HessianApprox *hessian = 0; - switch (config->hessianapprox_type) - { - case BFGS_SERIAL: - hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); - break; - case LBFGS: - hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); - break; - case IDENTITY: - hessian = new Identity(MPI_COMM_WORLD, ndesign_local); - break; - default: - printf("Error: unexpected hessianapprox_type returned"); - return 0; + switch (config->hessianapprox_type) { + case BFGS_SERIAL: + hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); + break; + case LBFGS: + hessian = new L_BFGS(MPI_COMM_WORLD, ndesign_local, config->lbfgs_stages); + break; + case IDENTITY: + hessian = new Identity(MPI_COMM_WORLD, ndesign_local); + break; + default: + printf("Error: unexpected hessianapprox_type returned"); + return 0; } /* Allocate ascent direction for design updates */ @@ -160,8 +160,7 @@ int main(int argc, char *argv[]) { ls_stepsize = stepsize; /* Open and prepare optimization output file*/ - if (myid == MASTER_NODE) - { + if (myid == MASTER_NODE) { sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); optimfile = fopen(optimfilename, "w"); config->writeToFile(optimfile); @@ -184,8 +183,7 @@ int main(int argc, char *argv[]) { StartTime = MPI_Wtime(); StopTime = 0.0; UsedTime = 0.0; - for (int iter = 0; iter < config->maxoptimiter; iter++) - { + for (int iter = 0; iter < config->maxoptimiter; iter++) { /* --- Training data: Get objective and gradient ---*/ /* Set up the current batch */ @@ -202,8 +200,7 @@ int main(int argc, char *argv[]) { /* --- Validation data: Get accuracy --- */ - if (config->validationlevel > 0) - { + if (config->validationlevel > 0) { primalvalapp->run(); loss_val = network->getLoss(); accur_val = network->getAccuracy(); @@ -216,16 +213,19 @@ int main(int argc, char *argv[]) { /* Communicate loss and accuracy. This is actually only needed for output. * Remove it. */ - MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&accur_train, &accurtrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(&accur_val, &accurval_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(&accur_train, &accurtrain_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); + MPI_Allreduce(&accur_val, &accurval_out, 1, MPI_MyReal, MPI_SUM, + MPI_COMM_WORLD); /* Output */ StopTime = MPI_Wtime(); UsedTime = StopTime - StartTime; - if (myid == MASTER_NODE) - { + if (myid == MASTER_NODE) { printf( "%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " "%2.2f%% %2.2f%% %.1f\n", @@ -240,19 +240,15 @@ int main(int argc, char *argv[]) { } /* Check optimization convergence */ - if (gnorm < config->gtol) - { - if (myid == MASTER_NODE) - { + if (gnorm < config->gtol) { + if (myid == MASTER_NODE) { printf("Optimization has converged. \n"); printf("Be happy and go home! \n"); } break; } - if (iter == config->maxoptimiter - 1) - { - if (myid == MASTER_NODE) - { + if (iter == config->maxoptimiter - 1) { + if (myid == MASTER_NODE) { printf("\nMax. optimization iterations reached.\n"); } break; @@ -270,16 +266,15 @@ int main(int argc, char *argv[]) { /* --- Backtracking linesearch --- */ - if (config->stepsize_type == BACKTRACKINGLS) - { + if (config->stepsize_type == BACKTRACKINGLS) { /* Compute wolfe condition */ - wolfe = vecdot_par(ndesign_local, network->getGradient(), ascentdir, MPI_COMM_WORLD); + wolfe = vecdot_par(ndesign_local, network->getGradient(), ascentdir, + MPI_COMM_WORLD); /* Start linesearch iterations */ ls_stepsize = config->getStepsize(iter); stepsize = ls_stepsize; - for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) - { + for (ls_iter = 0; ls_iter < config->ls_maxiter; ls_iter++) { primaltrainapp->getCore()->SetPrintLevel(0); primaltrainapp->run(); ls_objective = primaltrainapp->getObjective(); @@ -290,23 +285,20 @@ int main(int argc, char *argv[]) { printf("ls_iter %d: %1.14e %1.14e\n", ls_iter, ls_objective, test_obj); /* Test the wolfe condition */ - if (ls_objective <= test_obj) - { + if (ls_objective <= test_obj) { /* Success, use this new design */ break; - } - else - { + } else { /* Test for line-search failure */ - if (ls_iter == config->ls_maxiter - 1) - { + if (ls_iter == config->ls_maxiter - 1) { if (myid == MASTER_NODE) printf("\n\n WARNING: LINESEARCH FAILED! \n\n"); break; } /* Go back part of the step */ - network->updateDesign((1.0 - config->ls_factor) * stepsize, ascentdir, MPI_COMM_WORLD); + network->updateDesign((1.0 - config->ls_factor) * stepsize, ascentdir, + MPI_COMM_WORLD); /* Decrease the stepsize */ ls_stepsize = ls_stepsize * config->ls_factor; @@ -317,10 +309,8 @@ int main(int argc, char *argv[]) { } /* --- Run final validation and write prediction file --- */ - if (config->validationlevel > -1) - { - if (myid == MASTER_NODE) - printf("\n --- Run final validation ---\n"); + if (config->validationlevel > -1) { + if (myid == MASTER_NODE) printf("\n --- Run final validation ---\n"); primalvalapp->getCore()->SetPrintLevel(0); primalvalapp->run(); @@ -330,80 +320,81 @@ int main(int argc, char *argv[]) { } // write_vector("design.dat", design, ndesign); -#endif // OPTIMIZATION_ENABLED +#endif // OPTIMIZATION_ENABLED /** - * ================================================================================== - * Adjoint dot test xbarTxdot = ybarTydot - * where xbar = (dfdx)T ybar - * ydot = (dfdx) xdot - * choosing xdot to be a vector of all ones, ybar = 1.0; - * ==================================================================================*/ - // TODO: Why is this disabled? + * ================================================================================== + * Adjoint dot test xbarTxdot = ybarTydot + * where xbar = (dfdx)T ybar + * ydot = (dfdx) xdot + * choosing xdot to be a vector of all ones, ybar = 1.0; + * ==================================================================================*/ + // TODO: Why is this disabled? #if ADJOINT_DOT_TEST_ENABLED - - if (size == 1) - { - MyReal obj1, obj0; - // int nconv_size = 3; - - printf("\n\n ============================ \n"); - printf(" Adjoint dot test: \n\n"); - // printf(" ndesign = %d (calc = %d)\n",ndesign, - // nchannels*config->nclasses+config->nclasses // class layer - // +(nlayers-2)+(nlayers-2)*(nconv_size*nconv_size*(nchannels/config->nfeatures)*(nchannels/config->nfeatures))); // con layers - // printf(" nchannels = %d\n",nchannels); - // printf(" nlayers = %d\n",nlayers); - // printf(" conv_size = %d\n",nconv_size); - // printf(" config->nclasses = %d\n\n",config->nclasses); - - - /* TODO: read some design */ - - /* Propagate through braid */ - braid_evalInit(core_train, app_train); - braid_Drive(core_train); - braid_evalObjective(core_train, app_train, &obj0, &loss_train, &accur_train); - - /* Eval gradient */ - braid_evalObjectiveDiff(core_adj, app_train); - braid_Drive(core_adj); - braid_evalInitDiff(core_adj, app_train); - - MyReal xtx = 0.0; - MyReal EPS = 1e-7; - for (int i = 0; i < ndesign_global; i++) - { - /* Sum up xtx */ - xtx += network->getGradient()[i]; - /* perturb into direction "only ones" */ - network->getDesign()[i] += EPS; - } - /* New objective function evaluation */ - braid_evalInit(core_train, app_train); - braid_Drive(core_train); - braid_evalObjective(core_train, app_train, &obj1, &loss_train, &accur_train); + if (size == 1) { + MyReal obj1, obj0; + // int nconv_size = 3; + + printf("\n\n ============================ \n"); + printf(" Adjoint dot test: \n\n"); + // printf(" ndesign = %d (calc = %d)\n",ndesign, + // nchannels*config->nclasses+config->nclasses + // // class layer + // +(nlayers-2)+(nlayers-2)*(nconv_size*nconv_size*(nchannels/config->nfeatures)*(nchannels/config->nfeatures))); + // // con layers + // printf(" nchannels = %d\n",nchannels); + // printf(" nlayers = %d\n",nlayers); + // printf(" conv_size = %d\n",nconv_size); + // printf(" config->nclasses = %d\n\n",config->nclasses); + + /* TODO: read some design */ + + /* Propagate through braid */ + braid_evalInit(core_train, app_train); + braid_Drive(core_train); + braid_evalObjective(core_train, app_train, &obj0, &loss_train, + &accur_train); + + /* Eval gradient */ + braid_evalObjectiveDiff(core_adj, app_train); + braid_Drive(core_adj); + braid_evalInitDiff(core_adj, app_train); + + MyReal xtx = 0.0; + MyReal EPS = 1e-7; + for (int i = 0; i < ndesign_global; i++) { + /* Sum up xtx */ + xtx += network->getGradient()[i]; + /* perturb into direction "only ones" */ + network->getDesign()[i] += EPS; + } - /* Finite differences */ - MyReal yty = (obj1 - obj0)/EPS; + /* New objective function evaluation */ + braid_evalInit(core_train, app_train); + braid_Drive(core_train); + braid_evalObjective(core_train, app_train, &obj1, &loss_train, + &accur_train); - /* Print adjoint dot test result */ - printf(" Dot-test: %1.16e %1.16e\n\n Rel. error %3.6f %%\n\n", xtx, yty, (yty-xtx)/xtx * 100.); - printf(" obj0 %1.14e, obj1 %1.14e\n", obj0, obj1); + /* Finite differences */ + MyReal yty = (obj1 - obj0) / EPS; - } + /* Print adjoint dot test result */ + printf(" Dot-test: %1.16e %1.16e\n\n Rel. error %3.6f %%\n\n", xtx, yty, + (yty - xtx) / xtx * 100.); + printf(" obj0 %1.14e, obj1 %1.14e\n", obj0, obj1); + } -#endif // ADJOINT_DOT_TEST_ENABLED +#endif // ADJOINT_DOT_TEST_ENABLED -// TODO: Can we get rid of this or shall we pack it into a parameter? + // TODO: Can we get rid of this or shall we pack it into a parameter? /** ======================================= * Full finite differences * ======================================= */ #if FULL_FINITE_DIFFERENCES_ENABLED - MyReal* findiff = new MyReal[ndesign]; - MyReal* relerr = new MyReal[ndesign]; + MyReal *findiff = new MyReal[ndesign]; + MyReal *relerr = new MyReal[ndesign]; MyReal errnorm = 0.0; MyReal obj0, obj1, design_store; MyReal EPS; @@ -423,31 +414,31 @@ int main(int argc, char *argv[]) { // for (int i = 0; i < 22; i++) // int i=21; { - /* Restore design */ - // read_vector("design.dat", design, ndesign); - - /* Perturb design */ - design_store = design[i]; - design[i] += EPS; - - /* Recompute objective */ - _braid_CoreElt(core_train, warm_restart) = 0; - braid_SetObjectiveOnly(core_train, 1); - braid_SetPrintLevel(core_train, 0); - braid_Drive(core_train); - braid_GetObjective(core_train, &objective); - obj1 = objective; - - /* Findiff */ - findiff[i] = (obj1 - obj0) / EPS; - relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; - errnorm += pow(relerr[i],2); - - printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f",i, findiff[i], - gradient[i], relerr[i] * 100.0); - - /* Restore design */ - design[i] = design_store; + /* Restore design */ + // read_vector("design.dat", design, ndesign); + + /* Perturb design */ + design_store = design[i]; + design[i] += EPS; + + /* Recompute objective */ + _braid_CoreElt(core_train, warm_restart) = 0; + braid_SetObjectiveOnly(core_train, 1); + braid_SetPrintLevel(core_train, 0); + braid_Drive(core_train); + braid_GetObjective(core_train, &objective); + obj1 = objective; + + /* Findiff */ + findiff[i] = (obj1 - obj0) / EPS; + relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; + errnorm += pow(relerr[i], 2); + + printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f", i, findiff[i], gradient[i], + relerr[i] * 100.0); + + /* Restore design */ + design[i] = design_store; } errnorm = sqrt(errnorm); printf("\n FinDiff ErrNorm %1.14e\n", errnorm); @@ -455,10 +446,10 @@ int main(int argc, char *argv[]) { write_vector("findiff.dat", findiff, ndesign); write_vector("relerr.dat", relerr, ndesign); - ======================================= - check network implementation - ======================================= */ - network->applyFWD(config->ntraining, train_examples, train_labels); + == == == == == == == == == == == == == == == == == == == + = check network implementation == == == == == == == == == == == == == == + == == == == == + = * / network->applyFWD(config->ntraining, train_examples, train_labels); MyReal accur = network->getAccuracy(); MyReal regul = network->evalRegularization(); objective = network->getLoss() + regul; @@ -466,7 +457,7 @@ int main(int argc, char *argv[]) { printf(" Network: obj %1.14e \n", objective); printf(" ---\n"); -#endif // FULL_FINITE_DIFFERENCES_ENABLED +#endif // FULL_FINITE_DIFFERENCES_ENABLED /* Print some statistics */ StopTime = MPI_Wtime(); @@ -476,8 +467,7 @@ int main(int argc, char *argv[]) { MPI_Allreduce(&myMB, &globalMB, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); // printf("%d; Memory Usage: %.2f MB\n",myid, myMB); - if (myid == MASTER_NODE) - { + if (myid == MASTER_NODE) { printf("\n"); printf(" Used Time: %.2f seconds\n", UsedTime); printf(" Global Memory: %.2f MB\n", globalMB); @@ -501,8 +491,7 @@ int main(int argc, char *argv[]) { delete validationdata; /* Close optim file */ - if (myid == MASTER_NODE) - { + if (myid == MASTER_NODE) { fclose(optimfile); printf("Optimfile: %s\n", optimfilename); } From cf67149f8ebf901281830a1dd25113e8a11ba610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CA=87=C9=B9=C7=9Dq=C6=83=C7=9D=E1=B4=89s=20pu=C9=90lo?= =?UTF-8?q?=C9=B9?= Date: Fri, 12 Jul 2019 14:33:28 +0200 Subject: [PATCH 18/38] Update README.md --- README.md | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 21e2123..294148c 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,45 @@ -# Layer-parallel training of deep residual neural networks +# Layer-parallel training of deep residual neural networks + This code performs layer-parallel training of deep neural networks of residual type. It utilizes the parallel-in-time software library [XBraid](https://github.com/XBraid/xbraid) to distribute layers of the network to different compute units. Instead of sequential forward and backward propagation through the network, iterative multigrid udpates are performed in parallel to solve for the network propagation and the training simultaneously. See the paper [Guenther et al.](https://arxiv.org/pdf/1812.04352.pdf) for a describtion of the method and all details. ## Build -The repository includes XBraid as a submodule. To clone both, use either `git clone --recurse-submodules [...]` for Git version >= 2.13, or `git clone [...]` followed by `cd xbraid`, `git submodule init` and `git submodule update` for older Git versions. -Type `make` in the main directory to build both the code and the XBraid library. +The repository includes XBraid as a submodule. To clone both, use either `git clone --recurse-submodules [...]` for Git version \>= 2.13, or `git clone [...]` followed by `cd xbraid`, `git submodule init` and `git submodule update` for older Git versions. + +Type `make` in the main directory to build both the code and the XBraid library. ## Run -Test cases are located in the 'examples/' subfolder. Each example contains a `*.cfg` that holds configuration options for the current example dataset, the layer-parallelization with XBraid, and the optimization method and parameters. -Run the test cases by callying './main' with the corresponding configuration file, e.g. `./main examples/peaks/peaks.cfg` +Test cases are located in the 'examples/' subfolder. Each example contains a `*.cfg` that holds configuration options for the current example dataset, the layer-parallelization with XBraid, and the optimization method and parameters. + +Run the test cases by callying './main' with the corresponding configuration file, e.g. `./main examples/peaks/peaks.cfg` ## Output -An optimization history file 'optim.dat' will be flushed to the examples subfolder. + +An optimization history file 'optim.dat' will be flushed to the examples subfolder. ## Roland / Stef combo - LEARNING/TODO: ### Overview: -* Xbraid => 3 braid apps know one net -* One NN -* Braid has to be initialized first -> Decides about layers per core -* Tangling with NN is given due to reason above - - create nn - - give nn to braid - - init nn + +- Xbraid =\> 3 braid apps know one net +- One NN +- Braid has to be initialized first -\> Decides about layers per core +- Tangling with NN is given due to reason above + - create nn + - give nn to braid + - init nn ## 2Dos 😊 -* [X] Clean up syntax (google std) -* [ ] Associate code with [paper](https://arxiv.org/pdf/1812.04352.pdf) -* [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles - - [ ] Single Responsibility - - [ ] Open-Closed - - [ ] Liskov Substitution - - [ ] Interface Segregation - - [ ] Dependency Inversion -* [ ] Extract methods and clean up objects -* [ ] Comment everything -* [ ] Park old code in separate branches and tag them as deprecated + +- [x] Clean up syntax (google std) +- [ ] Associate code with [paper](https://arxiv.org/pdf/1812.04352.pdf) +- [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles + - [ ] Single Responsibility + - [ ] Open-Closed + - [ ] Liskov Substitution + - [ ] Interface Segregation + - [ ] Dependency Inversion +- [ ] Extract methods and clean up objects +- [ ] Park old code in separate branches and tag them as deprecated +- [ ] Would this code benefit from an update of XBraid? From 813c5c931ef374b960eed024787b97f3387570c6 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Fri, 12 Jul 2019 16:12:41 +0200 Subject: [PATCH 19/38] Identify Simultaneous Layer-Parallel Training algorithm in main.cpp --- src/main.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 19d1660..172e260 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,27 @@ +// TODO: Copyright +// +// TODO: Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// +// TODO: Authors of this paper are authors of this code. Further help for this +// code came from Roland Siegbert . +// + #include #include #include @@ -177,19 +201,24 @@ int main(int argc, char *argv[]) { "Accur_train Accur_val Time(sec)\n"); } - // TODO: WTF? This is "enabled"? Looks like testing code to me... +// TODO: If this is excluded nothing works: I suggest a removal of the preprocessor directive #if OPTIMIZATION_ENABLED StartTime = MPI_Wtime(); StopTime = 0.0; UsedTime = 0.0; + + + /* The following loop represents the paper's Algorithm (2) */ for (int iter = 0; iter < config->maxoptimiter; iter++) { - /* --- Training data: Get objective and gradient ---*/ /* Set up the current batch */ trainingdata->selectBatch(config->batch_type, MPI_COMM_WORLD); - /* Solve state and adjoint equation */ + /** Solve state and adjoint equations (2.15) and (2.17) + * + * Algorithm (2): Step 1 and 2 + */ rnorm = primaltrainapp->run(); rnorm_adj = adjointtrainapp->run(); @@ -199,7 +228,6 @@ int main(int argc, char *argv[]) { accur_train = network->getAccuracy(); /* --- Validation data: Get accuracy --- */ - if (config->validationlevel > 0) { primalvalapp->run(); loss_val = network->getLoss(); @@ -208,11 +236,14 @@ int main(int argc, char *argv[]) { /* --- Optimization control and output ---*/ - /* Compute global gradient norm */ + /** Compute global gradient norm + * + * Algorithm (2): Step 3 + */ gnorm = vecnorm_par(ndesign_local, network->getGradient(), MPI_COMM_WORLD); /* Communicate loss and accuracy. This is actually only needed for output. - * Remove it. */ + * TODO: Remove it. */ MPI_Allreduce(&loss_train, &losstrain_out, 1, MPI_MyReal, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(&loss_val, &lossval_out, 1, MPI_MyReal, MPI_SUM, @@ -239,7 +270,11 @@ int main(int argc, char *argv[]) { fflush(optimfile); } - /* Check optimization convergence */ + // TODO: Do you want to have the convergence check here? I'd move it after writing some tests actually. + /** Check optimization convergence + * + * Algorithm (2): Step 6 + */ if (gnorm < config->gtol) { if (myid == MASTER_NODE) { printf("Optimization has converged. \n"); @@ -254,17 +289,24 @@ int main(int argc, char *argv[]) { break; } + /* If optimization didn't converge, continue */ + /* --- Design update --- */ - /* Compute search direction */ + /** Compute search direction + * + * Algorithm (2): Step 4 + */ hessian->updateMemory(iter, network->getDesign(), network->getGradient()); hessian->computeAscentDir(iter, network->getGradient(), ascentdir); - - /* Update the design in negative ascent direction */ stepsize = config->getStepsize(iter); - network->updateDesign(-1.0 * stepsize, ascentdir, MPI_COMM_WORLD); - /* --- Backtracking linesearch --- */ + /** Update the design/network control parameter in negative ascent direction + * and perform backtracking linesearch. + * + * Algorithm (2): Step 5 + */ + network->updateDesign(-1.0 * stepsize, ascentdir, MPI_COMM_WORLD); if (config->stepsize_type == BACKTRACKINGLS) { /* Compute wolfe condition */ From b75783b1d4e5ad83ad40e2094f5f51ded096161c Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Thu, 11 Jul 2019 20:20:18 +0200 Subject: [PATCH 20/38] Add .idea to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a28930c..994c73d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ main # Ignore IDE configurations .idea .vscode -tags \ No newline at end of file +tags From 60d270b251e9b15c46879fde25dd114aa956a9fa Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Sat, 13 Jul 2019 08:28:44 +0200 Subject: [PATCH 21/38] Slash adjoint dot test and full finite differences --- src/main.cpp | 150 +-------------------------------------------------- 1 file changed, 2 insertions(+), 148 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 172e260..3f2c050 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,11 +39,6 @@ #define MASTER_NODE 0 -// TODO: Can these truly run separate? -#define ADJOINT_DOT_TEST_ENABLED 0 -#define OPTIMIZATION_ENABLED 1 -#define FULL_FINITE_DIFFERENCES_ENABLED 0 - int main(int argc, char *argv[]) { /* --- Data --- */ Config *config; /**< Storing configurations */ @@ -201,14 +196,11 @@ int main(int argc, char *argv[]) { "Accur_train Accur_val Time(sec)\n"); } -// TODO: If this is excluded nothing works: I suggest a removal of the preprocessor directive -#if OPTIMIZATION_ENABLED - + /* Measure wall time */ StartTime = MPI_Wtime(); StopTime = 0.0; UsedTime = 0.0; - /* The following loop represents the paper's Algorithm (2) */ for (int iter = 0; iter < config->maxoptimiter; iter++) { @@ -216,7 +208,7 @@ int main(int argc, char *argv[]) { trainingdata->selectBatch(config->batch_type, MPI_COMM_WORLD); /** Solve state and adjoint equations (2.15) and (2.17) - * + * * Algorithm (2): Step 1 and 2 */ rnorm = primaltrainapp->run(); @@ -362,144 +354,6 @@ int main(int argc, char *argv[]) { } // write_vector("design.dat", design, ndesign); -#endif // OPTIMIZATION_ENABLED - - /** - * ================================================================================== - * Adjoint dot test xbarTxdot = ybarTydot - * where xbar = (dfdx)T ybar - * ydot = (dfdx) xdot - * choosing xdot to be a vector of all ones, ybar = 1.0; - * ==================================================================================*/ - // TODO: Why is this disabled? -#if ADJOINT_DOT_TEST_ENABLED - - if (size == 1) { - MyReal obj1, obj0; - // int nconv_size = 3; - - printf("\n\n ============================ \n"); - printf(" Adjoint dot test: \n\n"); - // printf(" ndesign = %d (calc = %d)\n",ndesign, - // nchannels*config->nclasses+config->nclasses - // // class layer - // +(nlayers-2)+(nlayers-2)*(nconv_size*nconv_size*(nchannels/config->nfeatures)*(nchannels/config->nfeatures))); - // // con layers - // printf(" nchannels = %d\n",nchannels); - // printf(" nlayers = %d\n",nlayers); - // printf(" conv_size = %d\n",nconv_size); - // printf(" config->nclasses = %d\n\n",config->nclasses); - - /* TODO: read some design */ - - /* Propagate through braid */ - braid_evalInit(core_train, app_train); - braid_Drive(core_train); - braid_evalObjective(core_train, app_train, &obj0, &loss_train, - &accur_train); - - /* Eval gradient */ - braid_evalObjectiveDiff(core_adj, app_train); - braid_Drive(core_adj); - braid_evalInitDiff(core_adj, app_train); - - MyReal xtx = 0.0; - MyReal EPS = 1e-7; - for (int i = 0; i < ndesign_global; i++) { - /* Sum up xtx */ - xtx += network->getGradient()[i]; - /* perturb into direction "only ones" */ - network->getDesign()[i] += EPS; - } - - /* New objective function evaluation */ - braid_evalInit(core_train, app_train); - braid_Drive(core_train); - braid_evalObjective(core_train, app_train, &obj1, &loss_train, - &accur_train); - - /* Finite differences */ - MyReal yty = (obj1 - obj0) / EPS; - - /* Print adjoint dot test result */ - printf(" Dot-test: %1.16e %1.16e\n\n Rel. error %3.6f %%\n\n", xtx, yty, - (yty - xtx) / xtx * 100.); - printf(" obj0 %1.14e, obj1 %1.14e\n", obj0, obj1); - } - -#endif // ADJOINT_DOT_TEST_ENABLED - - // TODO: Can we get rid of this or shall we pack it into a parameter? - /** ======================================= - * Full finite differences - * ======================================= */ - -#if FULL_FINITE_DIFFERENCES_ENABLED - MyReal *findiff = new MyReal[ndesign]; - MyReal *relerr = new MyReal[ndesign]; - MyReal errnorm = 0.0; - MyReal obj0, obj1, design_store; - MyReal EPS; - - printf("\n--------------------------------\n"); - printf(" FINITE DIFFERENCE TESTING\n\n"); - - /* Compute baseline objective */ - // read_vector("design.dat", design, ndesign); - braid_SetObjectiveOnly(core_train, 0); - braid_Drive(core_train); - braid_GetObjective(core_train, &objective); - obj0 = objective; - - EPS = 1e-4; - for (int i = 0; i < ndesign; i++) - // for (int i = 0; i < 22; i++) - // int i=21; - { - /* Restore design */ - // read_vector("design.dat", design, ndesign); - - /* Perturb design */ - design_store = design[i]; - design[i] += EPS; - - /* Recompute objective */ - _braid_CoreElt(core_train, warm_restart) = 0; - braid_SetObjectiveOnly(core_train, 1); - braid_SetPrintLevel(core_train, 0); - braid_Drive(core_train); - braid_GetObjective(core_train, &objective); - obj1 = objective; - - /* Findiff */ - findiff[i] = (obj1 - obj0) / EPS; - relerr[i] = (gradient[i] - findiff[i]) / findiff[i]; - errnorm += pow(relerr[i], 2); - - printf("\n %4d: % 1.14e % 1.14e, error: % 2.4f", i, findiff[i], gradient[i], - relerr[i] * 100.0); - - /* Restore design */ - design[i] = design_store; - } - errnorm = sqrt(errnorm); - printf("\n FinDiff ErrNorm %1.14e\n", errnorm); - - write_vector("findiff.dat", findiff, ndesign); - write_vector("relerr.dat", relerr, ndesign); - - == == == == == == == == == == == == == == == == == == == - = check network implementation == == == == == == == == == == == == == == - == == == == == - = * / network->applyFWD(config->ntraining, train_examples, train_labels); - MyReal accur = network->getAccuracy(); - MyReal regul = network->evalRegularization(); - objective = network->getLoss() + regul; - printf("\n --- \n"); - printf(" Network: obj %1.14e \n", objective); - printf(" ---\n"); - -#endif // FULL_FINITE_DIFFERENCES_ENABLED /* Print some statistics */ StopTime = MPI_Wtime(); From 3ca36925b4fb8ae532d817f17895064526f31d96 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Sun, 14 Jul 2019 10:23:20 +0200 Subject: [PATCH 22/38] Enhance readability of STDOUT --- src/main.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3f2c050..2afd4b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -183,17 +183,10 @@ int main(int argc, char *argv[]) { sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); optimfile = fopen(optimfilename, "w"); config->writeToFile(optimfile); - fprintf(optimfile, "# || r || || r_adj || Objective Loss " " || grad || Stepsize ls_iter " "Accur_train Accur_val Time(sec)\n"); - - /* Screen output */ - printf( - "\n# || r || || r_adj || Objective " - "Loss || grad || Stepsize ls_iter " - "Accur_train Accur_val Time(sec)\n"); } /* Measure wall time */ @@ -203,7 +196,6 @@ int main(int argc, char *argv[]) { /* The following loop represents the paper's Algorithm (2) */ for (int iter = 0; iter < config->maxoptimiter; iter++) { - /* Set up the current batch */ trainingdata->selectBatch(config->batch_type, MPI_COMM_WORLD); @@ -250,8 +242,11 @@ int main(int argc, char *argv[]) { UsedTime = StopTime - StartTime; if (myid == MASTER_NODE) { printf( - "%03d %1.8e %1.8e %1.14e %1.14e %1.14e %5f %2d " - "%2.2f%% %2.2f%% %.1f\n", + "\n|| r ||\t|| r_adj ||\tObjective\tLoss\t\t\t|| grad " + "||\t\tStepsize\t\tls_iter\tAccur_train\tAccur_val\tTime(sec)\n"); + printf( + "%03d\t%1.8e\t%1.8e\t%1.14e\t%1.14e\t%1.14e\t%5f\t%2d\t%2.2f%%\t%2." + "2f%%\t%.1f\n\n", iter, rnorm, rnorm_adj, objective, losstrain_out, gnorm, stepsize, ls_iter, accurtrain_out, accurval_out, UsedTime); fprintf(optimfile, @@ -316,8 +311,8 @@ int main(int argc, char *argv[]) { test_obj = objective - ls_param * ls_stepsize * wolfe; if (myid == MASTER_NODE) - printf("ls_iter %d: %1.14e %1.14e\n", ls_iter, ls_objective, - test_obj); + printf("ls_iter = %d:\tls_objective = %1.14e\ttest_obj = %1.14e\n", + ls_iter, ls_objective, test_obj); /* Test the wolfe condition */ if (ls_objective <= test_obj) { /* Success, use this new design */ From bd265a38f7eaa5b0ebf50be92dfe8b44bf627bc1 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Sun, 14 Jul 2019 10:26:14 +0200 Subject: [PATCH 23/38] Add comment on optimization loop --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 2afd4b0..7fc507a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -194,7 +194,11 @@ int main(int argc, char *argv[]) { StopTime = 0.0; UsedTime = 0.0; - /* The following loop represents the paper's Algorithm (2) */ + /** Main optimization iteration + * + * The following loop represents the paper's Algorithm (2) + * + */ for (int iter = 0; iter < config->maxoptimiter; iter++) { /* Set up the current batch */ trainingdata->selectBatch(config->batch_type, MPI_COMM_WORLD); From af5a0120ed04ae19aca8eb5c8bb0a7fb4d57c2dc Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Sun, 14 Jul 2019 10:30:33 +0200 Subject: [PATCH 24/38] Fix whitespace --- src/main.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7fc507a..37c0b67 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -195,9 +195,9 @@ int main(int argc, char *argv[]) { UsedTime = 0.0; /** Main optimization iteration - * - * The following loop represents the paper's Algorithm (2) - * + * + * The following loop represents the paper's Algorithm (2) + * */ for (int iter = 0; iter < config->maxoptimiter; iter++) { /* Set up the current batch */ @@ -261,7 +261,8 @@ int main(int argc, char *argv[]) { fflush(optimfile); } - // TODO: Do you want to have the convergence check here? I'd move it after writing some tests actually. + // TODO: Do you want to have the convergence check here? I'd move it after + // writing some tests actually. /** Check optimization convergence * * Algorithm (2): Step 6 From 79d54372a00dc500e86ef54e2a35b1373b36f8f7 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Sun, 14 Jul 2019 10:46:15 +0200 Subject: [PATCH 25/38] Fix null pointer constant in HessianApprox --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 37c0b67..0eee9ca 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { ndesign_global); /* Initialize Hessian approximation */ - HessianApprox *hessian = 0; + HessianApprox *hessian; switch (config->hessianapprox_type) { case BFGS_SERIAL: hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); From cf656205def4b614d806d8db045929186cb73e76 Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 22 Jul 2019 21:47:32 -0700 Subject: [PATCH 26/38] Write output file in same folder where main is called. Output file optim.dat is now written in the same directory, where the executable is called from. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 67db8a5..dd811a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -157,7 +157,7 @@ int main (int argc, char *argv[]) /* Open and prepare optimization output file*/ if (myid == MASTER_NODE) { - sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); + sprintf(optimfilename, "%s.dat", "optim"); optimfile = fopen(optimfilename, "w"); config->writeToFile(optimfile); From bfeba5743ee172ca3d3d3af169fcabfb728acece Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 22 Jul 2019 22:07:47 -0700 Subject: [PATCH 27/38] Update testing script and output files. The python testing script runs various test cases and compares the output with the saved optim file (simple vimdiff). By default, maxlevels = 1 and 10 are tested running on 1, 2, and 5 cores each. Only the peaks example is tested so far. --- testing/peaks.cfg | 63 ++++++++++++++++--------------- testing/peaks.npt1.ml1.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt1.ml10.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt2.ml1.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt2.ml10.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt5.ml1.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt5.ml10.optim.dat | 60 ++++++++++++----------------- testing/testing.py | 6 ++- 8 files changed, 187 insertions(+), 242 deletions(-) diff --git a/testing/peaks.cfg b/testing/peaks.cfg index ed67381..842edc5 100644 --- a/testing/peaks.cfg +++ b/testing/peaks.cfg @@ -3,22 +3,22 @@ ################################ # relative data folder location -datafolder = data -# training examples filename -ftrain_ex = Ytrain_orig.dat -# training labels/classes filename -ftrain_labels = Ctrain_orig.dat -# validation examples filename -fval_ex = Yval_orig.dat -# validation labels/classes filename -fval_labels = Cval_orig.dat -# number of training data elements +datafolder = ../examples/peaks/ +# filename of training data feature vectors +ftrain_ex = features_training.dat +# filename of training data labels/classes +ftrain_labels = labels_training.dat +# filename of validation data feature +fval_ex = features_validation.dat +# filename of validation data labels/classes +fval_labels = labels_validation.dat +# number of training data elements (that many lines will be read!) ntraining = 5000 -# number of validation data elements +# number of validation data elements (that many lines will be read!) nvalidation = 200 -# number of features in training and validation examples +# number of features within the training and validation data set nfeatures = 2 -# number of labels/classes +# number of labels/classes within the training and validation data set nclasses = 5 # filename for opening weights and bias (set to NONE if not given) @@ -32,10 +32,10 @@ weightsclassificationfile = NONE # number of channels nchannels = 8 -# number of layers (minimum two, opening layer and classification layer) -nlayers = 30 +# number of layers (including opening layer and classification layer) (nlayer >= 3 !) +nlayers = 32 # final time -T = 5.0 +T = 1.0 # Activation function ("tanh" or "ReLu" or "SmoothReLu") activation = SmoothReLu # Type of network ("dense" the default, or "convolutional") @@ -45,14 +45,14 @@ network_type = dense # "activate": same as replicate, only apply tuned, shifted tanh activation function for MNIST. type_openlayer = activate # factor for scaling initial opening layer weights and bias -weights_open_init = 0e-3 +weights_open_init = 1e-3 # factor for scaling initial weights and bias of intermediate layers -weights_init = 1e-3 +weights_init = 0e-3 # factor for scaling initial classification weights and bias weights_class_init = 1e-3 ################################ -#BRAID +# XBraid ################################ # coarsening factor on level 0 @@ -62,15 +62,15 @@ braid_cfactor0 = 2 # coarsening factor on all other levels braid_cfactor = 2 # maximum number of levels -braid_maxlevels = 10 +braid_maxlevels = 1 # minimum allowed coarse time time grid size (values in 10-30 are usually best) braid_mincoarse = 10 # maximum number of iterations -braid_maxiter = 2 +braid_maxiter = 15 # absolute tolerance -braid_abstol = 1e-15 +braid_abstol = 1e-10 # absolute adjoint tolerance -braid_adjtol = 1e-15 +braid_adjtol = 1e-10 # printlevel braid_printlevel = 1 # access level @@ -85,28 +85,28 @@ braid_nrelax = 1 braid_nrelax0 = 0 #################################### -#Optimization +# Optimization #################################### # Type of batch selection ("deterministic" or "stochastic") batch_type = deterministic # Batch size -nbatch = 5000 +nbatch = 200 # relaxation param for tikhonov term gamma_tik = 1e-7 # relaxation param for time-derivative term -gamma_ddt = 1e-7 +gamma_ddt = 1e-5 # relaxation param for tikhonov term of classification weights gamma_class = 1e-7 # stepsize selection type ("fixed" or "backtrackingLS" or "oneoverk") # determines how to choose alpha in design update x_new = x_old - alpha * direction # fixed : constant alpha being the initial stepsize -# backtrackingLS : find alpha from backtracking linesearch, starting with initial stepsize +# backtrackingLS : find alpha from backtracking linesearch, starting at initial stepsize # oneoverk : alpha = 1/k where k is the current optimization iteration index stepsize_type = backtrackingLS -# initial stepsize for fixed alpha and backtracking linesearch selection +# initial stepsize stepsize = 1.0 # maximum number of optimization iterations -optim_maxiter = 20 +optim_maxiter = 100 # absolute stopping criterion for the gradient norm gtol = 1e-4 # maximum number of linesearch iterations @@ -117,5 +117,8 @@ ls_factor = 0.5 hessian_approx = L-BFGS # number of stages for l-bfgs method lbfgs_stages = 20 -# level for validation computation: 0 - validate only after optimization finishes. 1 - validate in each optimization iteration +# level for validation computation: +# -1 = never validate +# 0 = validate only after optimization finishes. +# 1 = validate in each optimization iteration validationlevel = 1 diff --git a/testing/peaks.npt1.ml1.optim.dat b/testing/peaks.npt1.ml1.optim.dat index 8dfb502..9ab3943 100644 --- a/testing/peaks.npt1.ml1.optim.dat +++ b/testing/peaks.npt1.ml1.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 -1.00000000e+00 -1.00000000e+00 1.60941989767865e+00 1.60941989720218e+00 5.47547521438103e-01 1.000000 0 20.18% 21.00% 0.2 -001 -1.00000000e+00 -1.00000000e+00 1.38071340186225e+00 1.38071338639355e+00 3.06051904945471e-01 1.000000 0 48.00% 46.50% 0.6 -002 -1.00000000e+00 -1.00000000e+00 1.23596247912580e+00 1.23596238748763e+00 1.29397210079374e-01 1.000000 0 50.78% 48.50% 0.9 -003 -1.00000000e+00 -1.00000000e+00 1.20341971297680e+00 1.20341956950837e+00 1.18843456996184e-01 1.000000 0 56.24% 54.50% 1.2 -004 -1.00000000e+00 -1.00000000e+00 1.18418727997486e+00 1.18418706821137e+00 7.57493851234179e-02 1.000000 0 57.00% 54.00% 1.6 -005 -1.00000000e+00 -1.00000000e+00 1.17681154387789e+00 1.17681130238162e+00 4.92897668623518e-02 1.000000 0 58.78% 56.00% 1.9 -006 -1.00000000e+00 -1.00000000e+00 1.16938781109130e+00 1.16938754241913e+00 5.63354947836319e-02 1.000000 0 58.22% 54.00% 2.3 -007 -1.00000000e+00 -1.00000000e+00 1.15847109277098e+00 1.15847078889672e+00 8.74543241159731e-02 1.000000 0 54.00% 50.00% 2.7 -008 -1.00000000e+00 -1.00000000e+00 1.15763751519476e+00 1.15763709061927e+00 2.71593130325443e-01 1.000000 0 56.40% 53.50% 3.0 -009 -1.00000000e+00 -1.00000000e+00 1.14274573639825e+00 1.14274537295253e+00 1.29627926674329e-01 1.000000 0 52.68% 46.00% 3.3 -010 -1.00000000e+00 -1.00000000e+00 1.14122719808983e+00 1.14122681274333e+00 1.55775797203811e-01 1.000000 0 53.10% 48.00% 3.6 -011 -1.00000000e+00 -1.00000000e+00 1.13494201952478e+00 1.13494161706763e+00 6.57957962169811e-02 1.000000 0 55.94% 51.00% 4.0 -012 -1.00000000e+00 -1.00000000e+00 1.13145597537932e+00 1.13145550124762e+00 1.26247044561169e-01 1.000000 0 51.98% 49.50% 4.3 -013 -1.00000000e+00 -1.00000000e+00 1.12368754549753e+00 1.12368705376703e+00 1.10635760888726e-01 1.000000 0 55.82% 54.00% 4.6 -014 -1.00000000e+00 -1.00000000e+00 1.11155460188595e+00 1.11155398029660e+00 1.39385721056845e-01 1.000000 0 57.88% 56.00% 4.9 -015 -1.00000000e+00 -1.00000000e+00 1.10515556053970e+00 1.10515489947227e+00 1.13781734395289e-01 1.000000 0 60.94% 57.00% 5.3 -016 -1.00000000e+00 -1.00000000e+00 1.09562590165864e+00 1.09562515860787e+00 2.52376513334094e-01 1.000000 0 60.68% 57.50% 5.6 -017 -1.00000000e+00 -1.00000000e+00 1.08197155968558e+00 1.08197063660131e+00 5.55013786931782e-01 1.000000 0 59.42% 56.00% 5.9 -018 -1.00000000e+00 -1.00000000e+00 1.07924452229731e+00 1.07924359893069e+00 6.18277564731762e-01 1.000000 0 58.32% 57.00% 6.2 -019 -1.00000000e+00 -1.00000000e+00 1.07415528298030e+00 1.07415447170882e+00 2.75740177515614e-01 0.500000 1 59.28% 55.50% 6.6 +000 -1.00000000e+00 -1.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.0 +001 -1.00000000e+00 -1.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.0 +002 -1.00000000e+00 -1.00000000e+00 1.05036886903368e-03 1.04931297594737e-03 6.51136165937218e-03 1.000000 0 100.00% 20.00% 0.1 +003 -1.00000000e+00 -1.00000000e+00 8.38924054937610e-04 8.37860415154911e-04 5.27459181685681e-03 1.000000 0 100.00% 20.00% 0.1 +004 -1.00000000e+00 -1.00000000e+00 3.09469131150244e-04 3.08370156887922e-04 2.07090184605933e-03 1.000000 0 100.00% 20.00% 0.1 +005 -1.00000000e+00 -1.00000000e+00 1.56742722262840e-04 1.55619105190084e-04 1.09169627784517e-03 1.000000 0 100.00% 20.00% 0.1 +006 -1.00000000e+00 -1.00000000e+00 7.10282645639592e-05 6.98756630906118e-05 5.15099197829775e-04 1.000000 0 100.00% 20.00% 0.1 +007 -1.00000000e+00 -1.00000000e+00 3.41186662095647e-05 3.29388953025643e-05 2.53915778855823e-04 1.000000 0 100.00% 20.00% 0.2 +008 -1.00000000e+00 -1.00000000e+00 1.65032674860585e-05 1.52959730466568e-05 1.23156345893023e-04 1.000000 0 100.00% 20.00% 0.2 +009 -1.00000000e+00 -1.00000000e+00 8.40503071448269e-06 7.17084153786459e-06 6.01241929460480e-05 1.000000 0 100.00% 20.00% 0.2 diff --git a/testing/peaks.npt1.ml10.optim.dat b/testing/peaks.npt1.ml10.optim.dat index 407c132..837f75d 100644 --- a/testing/peaks.npt1.ml10.optim.dat +++ b/testing/peaks.npt1.ml10.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 1.05426534e-05 7.01718976e-13 1.60941989766493e+00 1.60941989718846e+00 5.47547519325756e-01 1.000000 0 20.18% 21.00% 1.2 -001 1.57996193e-17 2.03041298e-10 1.38071340216910e+00 1.38071338670040e+00 3.06050567716981e-01 1.000000 0 48.00% 46.50% 3.0 -002 7.29308604e-13 4.22213509e-10 1.23596253137683e+00 1.23596243974067e+00 1.29391394257781e-01 1.000000 0 50.78% 48.50% 4.8 -003 9.81124600e-13 2.07669782e-10 1.20341417342464e+00 1.20341402994788e+00 1.18831935496275e-01 1.000000 0 56.24% 54.50% 6.5 -004 6.26066790e-12 4.49854737e-10 1.18418442453580e+00 1.18418421274440e+00 7.58416506674437e-02 1.000000 0 56.98% 54.00% 8.3 -005 6.78105919e-12 2.17426183e-10 1.17681138506102e+00 1.17681114353766e+00 4.93204360796171e-02 1.000000 0 58.80% 56.00% 10.0 -006 2.30351731e-11 3.40981732e-10 1.16939416065256e+00 1.16939389207214e+00 5.63229160588530e-02 1.000000 0 58.22% 54.00% 11.9 -007 8.88623265e-11 7.08703623e-10 1.15848320762452e+00 1.15848290381382e+00 8.77505478477174e-02 1.000000 0 54.00% 50.00% 13.6 -008 1.53502187e-09 3.43627498e-09 1.15752458099280e+00 1.15752415760565e+00 2.70258261860996e-01 1.000000 0 56.42% 53.50% 15.3 -009 3.35426627e-10 2.10759273e-09 1.14272215805333e+00 1.14272179436899e+00 1.28969655129404e-01 1.000000 0 52.74% 46.00% 16.9 -010 8.65490676e-11 1.05329993e-09 1.14123385478706e+00 1.14123346978230e+00 1.55750623407490e-01 1.000000 0 53.14% 48.00% 18.6 -011 2.41000293e-10 5.31010337e-10 1.13494612729255e+00 1.13494572513913e+00 6.54530806420039e-02 1.000000 0 55.90% 51.00% 20.3 -012 1.84660098e-09 1.94338217e-09 1.13142768073210e+00 1.13142720629247e+00 1.25443138882351e-01 1.000000 0 51.96% 49.00% 21.9 -013 8.54540924e-10 1.12055818e-09 1.12358278356824e+00 1.12358229180074e+00 1.11310852815511e-01 1.000000 0 55.88% 54.50% 23.6 -014 1.64024146e-08 7.14719084e-09 1.11134576834466e+00 1.11134514381860e+00 1.40185628559086e-01 1.000000 0 57.94% 56.50% 25.2 -015 9.73572966e-09 2.81897201e-09 1.10494151034690e+00 1.10494084600873e+00 1.15680085929700e-01 1.000000 0 60.98% 57.00% 26.9 -016 3.27161110e-08 5.09705006e-09 1.09542616968119e+00 1.09542542799467e+00 2.51017228904287e-01 1.000000 0 60.68% 57.50% 28.5 -017 3.55387932e-07 1.33789499e-08 1.08242275846187e+00 1.08242181907883e+00 5.74669282315359e-01 1.000000 0 59.18% 57.50% 30.2 -018 1.35900404e-08 1.27840638e-08 1.07817898750936e+00 1.07817806809747e+00 3.68508030727317e-01 1.000000 0 58.34% 56.00% 31.8 -019 9.54593730e-08 1.10671022e-08 1.07641618944747e+00 1.07641542511829e+00 5.40433679343467e-01 1.000000 0 58.12% 53.50% 33.4 +000 1.48762021e-18 0.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.1 +001 4.87268972e-19 0.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.2 +002 1.20657289e-16 9.58293526e-11 1.05036886903368e-03 1.04931297594737e-03 6.51137546917077e-03 1.000000 0 100.00% 20.00% 0.3 +003 8.86998023e-17 1.34391587e-13 8.38923640767822e-04 8.37860001146083e-04 5.27458994776971e-03 1.000000 0 100.00% 20.00% 0.4 +004 1.21309331e-16 5.43079170e-13 3.09474514735135e-04 3.08375531427215e-04 2.07093191405256e-03 1.000000 0 100.00% 20.00% 0.6 +005 1.43429471e-16 2.41778398e-13 1.56745527599925e-04 1.55621886721240e-04 1.09171100040307e-03 1.000000 0 100.00% 20.00% 0.7 +006 1.78697630e-16 2.03233182e-13 7.10300937789059e-05 6.98774426357128e-05 5.15108834175264e-04 1.000000 0 100.00% 20.00% 0.8 +007 2.10635379e-16 1.27882822e-13 3.41197750696654e-05 3.29399208824851e-05 2.53921341908186e-04 1.000000 0 100.00% 20.00% 0.9 +008 2.22144503e-16 8.82507913e-14 1.65039906218550e-05 1.52965683800520e-05 1.23159632420279e-04 1.000000 0 100.00% 20.00% 1.1 +009 2.60100400e-16 5.80874925e-14 8.40555413834112e-06 7.17118187402434e-06 6.01261027573695e-05 1.000000 0 100.00% 20.00% 1.2 diff --git a/testing/peaks.npt2.ml1.optim.dat b/testing/peaks.npt2.ml1.optim.dat index f1a8438..11fec9f 100644 --- a/testing/peaks.npt2.ml1.optim.dat +++ b/testing/peaks.npt2.ml1.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 -1.00000000e+00 -1.00000000e+00 1.60941989767865e+00 1.60941989720218e+00 5.47547521438103e-01 1.000000 0 20.18% 21.00% 0.2 -001 -1.00000000e+00 -1.00000000e+00 1.38071340186225e+00 1.38071338639355e+00 3.06051904945471e-01 1.000000 0 48.00% 46.50% 0.6 -002 -1.00000000e+00 -1.00000000e+00 1.23596247912580e+00 1.23596238748763e+00 1.29397210079374e-01 1.000000 0 50.78% 48.50% 0.9 -003 -1.00000000e+00 -1.00000000e+00 1.20341971297680e+00 1.20341956950837e+00 1.18843456996184e-01 1.000000 0 56.24% 54.50% 1.3 -004 -1.00000000e+00 -1.00000000e+00 1.18418727997486e+00 1.18418706821137e+00 7.57493851234181e-02 1.000000 0 57.00% 54.00% 1.6 -005 -1.00000000e+00 -1.00000000e+00 1.17681154387789e+00 1.17681130238162e+00 4.92897668623518e-02 1.000000 0 58.78% 56.00% 2.0 -006 -1.00000000e+00 -1.00000000e+00 1.16938781109130e+00 1.16938754241913e+00 5.63354947836322e-02 1.000000 0 58.22% 54.00% 2.4 -007 -1.00000000e+00 -1.00000000e+00 1.15847109277098e+00 1.15847078889672e+00 8.74543241159725e-02 1.000000 0 54.00% 50.00% 2.8 -008 -1.00000000e+00 -1.00000000e+00 1.15763751519476e+00 1.15763709061927e+00 2.71593130325434e-01 1.000000 0 56.40% 53.50% 3.1 -009 -1.00000000e+00 -1.00000000e+00 1.14274573639825e+00 1.14274537295253e+00 1.29627926674328e-01 1.000000 0 52.68% 46.00% 3.5 -010 -1.00000000e+00 -1.00000000e+00 1.14122719808982e+00 1.14122681274333e+00 1.55775797203806e-01 1.000000 0 53.10% 48.00% 3.8 -011 -1.00000000e+00 -1.00000000e+00 1.13494201952478e+00 1.13494161706763e+00 6.57957962169820e-02 1.000000 0 55.94% 51.00% 4.2 -012 -1.00000000e+00 -1.00000000e+00 1.13145597537932e+00 1.13145550124762e+00 1.26247044561172e-01 1.000000 0 51.98% 49.50% 4.5 -013 -1.00000000e+00 -1.00000000e+00 1.12368754549752e+00 1.12368705376703e+00 1.10635760888722e-01 1.000000 0 55.82% 54.00% 4.8 -014 -1.00000000e+00 -1.00000000e+00 1.11155460188595e+00 1.11155398029660e+00 1.39385721056834e-01 1.000000 0 57.88% 56.00% 5.2 -015 -1.00000000e+00 -1.00000000e+00 1.10515556053969e+00 1.10515489947227e+00 1.13781734395290e-01 1.000000 0 60.94% 57.00% 5.6 -016 -1.00000000e+00 -1.00000000e+00 1.09562590165864e+00 1.09562515860787e+00 2.52376513334136e-01 1.000000 0 60.68% 57.50% 6.0 -017 -1.00000000e+00 -1.00000000e+00 1.08197155968557e+00 1.08197063660131e+00 5.55013786931869e-01 1.000000 0 59.42% 56.00% 6.3 -018 -1.00000000e+00 -1.00000000e+00 1.07924452229731e+00 1.07924359893069e+00 6.18277564731541e-01 1.000000 0 58.32% 57.00% 6.6 -019 -1.00000000e+00 -1.00000000e+00 1.07415528298030e+00 1.07415447170882e+00 2.75740177515749e-01 0.500000 1 59.28% 55.50% 7.0 +000 -1.00000000e+00 -1.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.0 +001 -1.00000000e+00 -1.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.0 +002 -1.00000000e+00 -1.00000000e+00 1.05036886903367e-03 1.04931297594736e-03 6.51136165937214e-03 1.000000 0 100.00% 20.00% 0.1 +003 -1.00000000e+00 -1.00000000e+00 8.38924054937610e-04 8.37860415154911e-04 5.27459181685679e-03 1.000000 0 100.00% 20.00% 0.1 +004 -1.00000000e+00 -1.00000000e+00 3.09469131150244e-04 3.08370156887922e-04 2.07090184605932e-03 1.000000 0 100.00% 20.00% 0.1 +005 -1.00000000e+00 -1.00000000e+00 1.56742722262840e-04 1.55619105190084e-04 1.09169627784516e-03 1.000000 0 100.00% 20.00% 0.1 +006 -1.00000000e+00 -1.00000000e+00 7.10282645639592e-05 6.98756630906118e-05 5.15099197829774e-04 1.000000 0 100.00% 20.00% 0.1 +007 -1.00000000e+00 -1.00000000e+00 3.41186662095647e-05 3.29388953025643e-05 2.53915778855823e-04 1.000000 0 100.00% 20.00% 0.2 +008 -1.00000000e+00 -1.00000000e+00 1.65032674860585e-05 1.52959730466568e-05 1.23156345893023e-04 1.000000 0 100.00% 20.00% 0.2 +009 -1.00000000e+00 -1.00000000e+00 8.40503071448269e-06 7.17084153786459e-06 6.01241929460480e-05 1.000000 0 100.00% 20.00% 0.2 diff --git a/testing/peaks.npt2.ml10.optim.dat b/testing/peaks.npt2.ml10.optim.dat index 96b0352..5c95af9 100644 --- a/testing/peaks.npt2.ml10.optim.dat +++ b/testing/peaks.npt2.ml10.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 1.05426534e-05 7.01718976e-13 1.60941989766493e+00 1.60941989718846e+00 5.47547519325756e-01 1.000000 0 20.18% 21.00% 0.8 -001 1.57996193e-17 2.03041298e-10 1.38071340216910e+00 1.38071338670040e+00 3.06050567716981e-01 1.000000 0 48.00% 46.50% 1.9 -002 7.29308604e-13 4.22213509e-10 1.23596253137683e+00 1.23596243974067e+00 1.29391394257781e-01 1.000000 0 50.78% 48.50% 3.2 -003 9.81124621e-13 2.07669782e-10 1.20341417342464e+00 1.20341402994788e+00 1.18831935496275e-01 1.000000 0 56.24% 54.50% 4.3 -004 6.26066780e-12 4.49854737e-10 1.18418442453580e+00 1.18418421274440e+00 7.58416506674439e-02 1.000000 0 56.98% 54.00% 5.6 -005 6.78105922e-12 2.17426183e-10 1.17681138506102e+00 1.17681114353766e+00 4.93204360796170e-02 1.000000 0 58.80% 56.00% 6.7 -006 2.30351729e-11 3.40981732e-10 1.16939416065256e+00 1.16939389207214e+00 5.63229160588530e-02 1.000000 0 58.22% 54.00% 8.0 -007 8.88623266e-11 7.08703623e-10 1.15848320762452e+00 1.15848290381382e+00 8.77505478477175e-02 1.000000 0 54.00% 50.00% 9.1 -008 1.53502187e-09 3.43627498e-09 1.15752458099280e+00 1.15752415760565e+00 2.70258261860993e-01 1.000000 0 56.42% 53.50% 10.3 -009 3.35426626e-10 2.10759273e-09 1.14272215805333e+00 1.14272179436899e+00 1.28969655129404e-01 1.000000 0 52.74% 46.00% 11.5 -010 8.65490677e-11 1.05329993e-09 1.14123385478706e+00 1.14123346978230e+00 1.55750623407489e-01 1.000000 0 53.14% 48.00% 12.7 -011 2.41000293e-10 5.31010337e-10 1.13494612729255e+00 1.13494572513913e+00 6.54530806420046e-02 1.000000 0 55.90% 51.00% 13.8 -012 1.84660098e-09 1.94338217e-09 1.13142768073210e+00 1.13142720629247e+00 1.25443138882354e-01 1.000000 0 51.96% 49.00% 15.0 -013 8.54540924e-10 1.12055818e-09 1.12358278356824e+00 1.12358229180074e+00 1.11310852815509e-01 1.000000 0 55.88% 54.50% 16.1 -014 1.64024146e-08 7.14719084e-09 1.11134576834466e+00 1.11134514381860e+00 1.40185628559072e-01 1.000000 0 57.94% 56.50% 17.3 -015 9.73572966e-09 2.81897201e-09 1.10494151034690e+00 1.10494084600873e+00 1.15680085929693e-01 1.000000 0 60.98% 57.00% 18.4 -016 3.27161110e-08 5.09705006e-09 1.09542616968119e+00 1.09542542799467e+00 2.51017228904277e-01 1.000000 0 60.68% 57.50% 19.6 -017 3.55387932e-07 1.33789499e-08 1.08242275846187e+00 1.08242181907883e+00 5.74669282315588e-01 1.000000 0 59.18% 57.50% 20.6 -018 1.35900404e-08 1.27840638e-08 1.07817898750937e+00 1.07817806809748e+00 3.68508030728956e-01 1.000000 0 58.34% 56.00% 21.8 -019 9.54593730e-08 1.10671022e-08 1.07641618944750e+00 1.07641542511832e+00 5.40433679341661e-01 1.000000 0 58.12% 53.50% 22.9 +000 1.48762021e-18 0.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.1 +001 4.87268972e-19 0.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.1 +002 1.20416982e-16 9.58293526e-11 1.05036886903367e-03 1.04931297594736e-03 6.51137546917073e-03 1.000000 0 100.00% 20.00% 0.2 +003 8.86650549e-17 1.34391587e-13 8.38923640767822e-04 8.37860001146083e-04 5.27458994776969e-03 1.000000 0 100.00% 20.00% 0.3 +004 1.21304250e-16 5.43079170e-13 3.09474514735135e-04 3.08375531427215e-04 2.07093191405255e-03 1.000000 0 100.00% 20.00% 0.4 +005 1.43171427e-16 2.41778398e-13 1.56745527599925e-04 1.55621886721240e-04 1.09171100040307e-03 1.000000 0 100.00% 20.00% 0.5 +006 1.78721770e-16 2.03233182e-13 7.10300937789059e-05 6.98774426357128e-05 5.15108834175262e-04 1.000000 0 100.00% 20.00% 0.6 +007 2.10562219e-16 1.27882822e-13 3.41197750696654e-05 3.29399208824851e-05 2.53921341908184e-04 1.000000 0 100.00% 20.00% 0.6 +008 2.21803000e-16 8.82507913e-14 1.65039906218550e-05 1.52965683800520e-05 1.23159632420279e-04 1.000000 0 100.00% 20.00% 0.7 +009 2.59882318e-16 5.80874925e-14 8.40555413834112e-06 7.17118187402434e-06 6.01261027573693e-05 1.000000 0 100.00% 20.00% 0.8 diff --git a/testing/peaks.npt5.ml1.optim.dat b/testing/peaks.npt5.ml1.optim.dat index 12a784f..b064fb6 100644 --- a/testing/peaks.npt5.ml1.optim.dat +++ b/testing/peaks.npt5.ml1.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 -1.00000000e+00 -1.00000000e+00 1.60941989767865e+00 1.60941989720218e+00 5.47547521438103e-01 1.000000 0 20.18% 21.00% 0.5 -001 -1.00000000e+00 -1.00000000e+00 1.38071340186225e+00 1.38071338639355e+00 3.06051904945471e-01 1.000000 0 48.00% 46.50% 1.2 -002 -1.00000000e+00 -1.00000000e+00 1.23596247912580e+00 1.23596238748763e+00 1.29397210079374e-01 1.000000 0 50.78% 48.50% 1.8 -003 -1.00000000e+00 -1.00000000e+00 1.20341971297680e+00 1.20341956950837e+00 1.18843456996184e-01 1.000000 0 56.24% 54.50% 2.6 -004 -1.00000000e+00 -1.00000000e+00 1.18418727997486e+00 1.18418706821137e+00 7.57493851234178e-02 1.000000 0 57.00% 54.00% 3.2 -005 -1.00000000e+00 -1.00000000e+00 1.17681154387789e+00 1.17681130238162e+00 4.92897668623518e-02 1.000000 0 58.78% 56.00% 3.8 -006 -1.00000000e+00 -1.00000000e+00 1.16938781109130e+00 1.16938754241913e+00 5.63354947836319e-02 1.000000 0 58.22% 54.00% 4.5 -007 -1.00000000e+00 -1.00000000e+00 1.15847109277098e+00 1.15847078889672e+00 8.74543241159734e-02 1.000000 0 54.00% 50.00% 5.1 -008 -1.00000000e+00 -1.00000000e+00 1.15763751519476e+00 1.15763709061927e+00 2.71593130325441e-01 1.000000 0 56.40% 53.50% 5.9 -009 -1.00000000e+00 -1.00000000e+00 1.14274573639825e+00 1.14274537295253e+00 1.29627926674328e-01 1.000000 0 52.68% 46.00% 6.5 -010 -1.00000000e+00 -1.00000000e+00 1.14122719808983e+00 1.14122681274333e+00 1.55775797203811e-01 1.000000 0 53.10% 48.00% 7.3 -011 -1.00000000e+00 -1.00000000e+00 1.13494201952478e+00 1.13494161706763e+00 6.57957962169811e-02 1.000000 0 55.94% 51.00% 7.9 -012 -1.00000000e+00 -1.00000000e+00 1.13145597537932e+00 1.13145550124762e+00 1.26247044561170e-01 1.000000 0 51.98% 49.50% 8.6 -013 -1.00000000e+00 -1.00000000e+00 1.12368754549753e+00 1.12368705376703e+00 1.10635760888728e-01 1.000000 0 55.82% 54.00% 9.2 -014 -1.00000000e+00 -1.00000000e+00 1.11155460188595e+00 1.11155398029660e+00 1.39385721056834e-01 1.000000 0 57.88% 56.00% 9.8 -015 -1.00000000e+00 -1.00000000e+00 1.10515556053969e+00 1.10515489947227e+00 1.13781734395281e-01 1.000000 0 60.94% 57.00% 10.5 -016 -1.00000000e+00 -1.00000000e+00 1.09562590165864e+00 1.09562515860787e+00 2.52376513334124e-01 1.000000 0 60.68% 57.50% 11.3 -017 -1.00000000e+00 -1.00000000e+00 1.08197155968558e+00 1.08197063660131e+00 5.55013786931906e-01 1.000000 0 59.42% 56.00% 11.9 -018 -1.00000000e+00 -1.00000000e+00 1.07924452229732e+00 1.07924359893070e+00 6.18277564731091e-01 1.000000 0 58.32% 57.00% 12.6 -019 -1.00000000e+00 -1.00000000e+00 1.07415528298029e+00 1.07415447170881e+00 2.75740177515766e-01 0.500000 1 59.28% 55.50% 13.6 +000 -1.00000000e+00 -1.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.0 +001 -1.00000000e+00 -1.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.1 +002 -1.00000000e+00 -1.00000000e+00 1.05036886903367e-03 1.04931297594736e-03 6.51136165937214e-03 1.000000 0 100.00% 20.00% 0.1 +003 -1.00000000e+00 -1.00000000e+00 8.38924054937610e-04 8.37860415154911e-04 5.27459181685679e-03 1.000000 0 100.00% 20.00% 0.1 +004 -1.00000000e+00 -1.00000000e+00 3.09469131150244e-04 3.08370156887922e-04 2.07090184605932e-03 1.000000 0 100.00% 20.00% 0.2 +005 -1.00000000e+00 -1.00000000e+00 1.56742722262840e-04 1.55619105190084e-04 1.09169627784516e-03 1.000000 0 100.00% 20.00% 0.2 +006 -1.00000000e+00 -1.00000000e+00 7.10282645639592e-05 6.98756630906118e-05 5.15099197829773e-04 1.000000 0 100.00% 20.00% 0.2 +007 -1.00000000e+00 -1.00000000e+00 3.41186662095647e-05 3.29388953025643e-05 2.53915778855823e-04 1.000000 0 100.00% 20.00% 0.3 +008 -1.00000000e+00 -1.00000000e+00 1.65032674860585e-05 1.52959730466568e-05 1.23156345893023e-04 1.000000 0 100.00% 20.00% 0.3 +009 -1.00000000e+00 -1.00000000e+00 8.40503071448269e-06 7.17084153786459e-06 6.01241929460479e-05 1.000000 0 100.00% 20.00% 0.3 diff --git a/testing/peaks.npt5.ml10.optim.dat b/testing/peaks.npt5.ml10.optim.dat index cf199f5..1d75665 100644 --- a/testing/peaks.npt5.ml10.optim.dat +++ b/testing/peaks.npt5.ml10.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 1.05426534e-05 7.01718976e-13 1.60941989766493e+00 1.60941989718846e+00 5.47547519325756e-01 1.000000 0 20.18% 21.00% 1.1 -001 1.57996193e-17 2.03041298e-10 1.38071340216910e+00 1.38071338670040e+00 3.06050567716981e-01 1.000000 0 48.00% 46.50% 2.5 -002 7.29308609e-13 4.22213509e-10 1.23596253137683e+00 1.23596243974067e+00 1.29391394257781e-01 1.000000 0 50.78% 48.50% 4.1 -003 9.81124667e-13 2.07669782e-10 1.20341417342464e+00 1.20341402994788e+00 1.18831935496275e-01 1.000000 0 56.24% 54.50% 5.7 -004 6.26066791e-12 4.49854737e-10 1.18418442453580e+00 1.18418421274440e+00 7.58416506674442e-02 1.000000 0 56.98% 54.00% 7.1 -005 6.78105921e-12 2.17426183e-10 1.17681138506102e+00 1.17681114353766e+00 4.93204360796169e-02 1.000000 0 58.80% 56.00% 8.8 -006 2.30351730e-11 3.40981732e-10 1.16939416065256e+00 1.16939389207214e+00 5.63229160588529e-02 1.000000 0 58.22% 54.00% 10.3 -007 8.88623266e-11 7.08703623e-10 1.15848320762452e+00 1.15848290381382e+00 8.77505478477171e-02 1.000000 0 54.00% 50.00% 12.0 -008 1.53502187e-09 3.43627498e-09 1.15752458099280e+00 1.15752415760565e+00 2.70258261860993e-01 1.000000 0 56.42% 53.50% 13.6 -009 3.35426626e-10 2.10759273e-09 1.14272215805333e+00 1.14272179436899e+00 1.28969655129406e-01 1.000000 0 52.74% 46.00% 15.1 -010 8.65490678e-11 1.05329993e-09 1.14123385478706e+00 1.14123346978230e+00 1.55750623407485e-01 1.000000 0 53.14% 48.00% 16.6 -011 2.41000293e-10 5.31010337e-10 1.13494612729255e+00 1.13494572513913e+00 6.54530806420054e-02 1.000000 0 55.90% 51.00% 18.2 -012 1.84660098e-09 1.94338217e-09 1.13142768073210e+00 1.13142720629247e+00 1.25443138882352e-01 1.000000 0 51.96% 49.00% 19.5 -013 8.54540924e-10 1.12055818e-09 1.12358278356824e+00 1.12358229180074e+00 1.11310852815505e-01 1.000000 0 55.88% 54.50% 21.0 -014 1.64024146e-08 7.14719084e-09 1.11134576834466e+00 1.11134514381860e+00 1.40185628559094e-01 1.000000 0 57.94% 56.50% 22.4 -015 9.73572966e-09 2.81897201e-09 1.10494151034690e+00 1.10494084600873e+00 1.15680085929712e-01 1.000000 0 60.98% 57.00% 23.9 -016 3.27161110e-08 5.09705006e-09 1.09542616968119e+00 1.09542542799467e+00 2.51017228904264e-01 1.000000 0 60.68% 57.50% 25.2 -017 3.55387932e-07 1.33789499e-08 1.08242275846186e+00 1.08242181907883e+00 5.74669282315268e-01 1.000000 0 59.18% 57.50% 26.9 -018 1.35900404e-08 1.27840638e-08 1.07817898750936e+00 1.07817806809747e+00 3.68508030725625e-01 1.000000 0 58.34% 56.00% 28.2 -019 9.54593730e-08 1.10671022e-08 1.07641618944743e+00 1.07641542511825e+00 5.40433679344485e-01 1.000000 0 58.12% 53.50% 29.7 +000 1.48762021e-18 0.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.1 +001 4.87268972e-19 0.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.2 +002 1.20416982e-16 9.58293526e-11 1.05036886903367e-03 1.04931297594736e-03 6.51137546917073e-03 1.000000 0 100.00% 20.00% 0.3 +003 8.86302938e-17 1.34391587e-13 8.38923640767822e-04 8.37860001146083e-04 5.27458994776969e-03 1.000000 0 100.00% 20.00% 0.4 +004 1.21324571e-16 5.43079170e-13 3.09474514735135e-04 3.08375531427215e-04 2.07093191405255e-03 1.000000 0 100.00% 20.00% 0.5 +005 1.43184341e-16 2.41778398e-13 1.56745527599925e-04 1.55621886721240e-04 1.09171100040307e-03 1.000000 0 100.00% 20.00% 0.6 +006 1.78707976e-16 2.03233182e-13 7.10300937789059e-05 6.98774426357128e-05 5.15108834175262e-04 1.000000 0 100.00% 20.00% 0.8 +007 2.10521238e-16 1.27882822e-13 3.41197750696654e-05 3.29399208824851e-05 2.53921341908185e-04 1.000000 0 100.00% 20.00% 1.0 +008 2.22294265e-16 8.82507913e-14 1.65039906218550e-05 1.52965683800520e-05 1.23159632420279e-04 1.000000 0 100.00% 20.00% 1.1 +009 2.59851488e-16 5.80874925e-14 8.40555413834112e-06 7.17118187402434e-06 6.01261027573692e-05 1.000000 0 100.00% 20.00% 1.3 diff --git a/testing/testing.py b/testing/testing.py index c944173..a314d1a 100644 --- a/testing/testing.py +++ b/testing/testing.py @@ -6,6 +6,7 @@ import copy import subprocess import string +sys.path.insert(0, '../pythonutil') from config import * from util import * @@ -45,12 +46,13 @@ os.mkdir(testfoldername) # create a link to training and validation data - datafolder = "../" + config.datafolder - make_link(datafolder, testfoldername + "/" + config.datafolder) + datafolder = config.datafolder + make_link(datafolder, testfoldername + "/data" ) # Set the new configuration konfig = copy.deepcopy(config) konfig.braid_maxlevels = ml + konfig.datafolder = "data" # create the config file testconfig = testname + ".cfg" From 63a0d5b50c58436c85d8dde3a135c4fc5bcdde3b Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 22 Jul 2019 22:43:27 -0700 Subject: [PATCH 28/38] Update peaks example config. The peaks example now runs with N=32 layers. Validation accuracy about 90% after 130 iteraions. Uses One-shot, i.e. only 2 xBraid iterations in each optimization cycle. --- examples/peaks/peaks.cfg | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/peaks/peaks.cfg b/examples/peaks/peaks.cfg index fb0af31..9f1d445 100644 --- a/examples/peaks/peaks.cfg +++ b/examples/peaks/peaks.cfg @@ -3,7 +3,7 @@ ################################ # relative data folder location -datafolder = examples/peaks +datafolder = ./ # filename of training data feature vectors ftrain_ex = features_training.dat # filename of training data labels/classes @@ -35,7 +35,7 @@ nchannels = 8 # number of layers (including opening layer and classification layer) (nlayer >= 3 !) nlayers = 32 # final time -T = 5.0 +T = 1.0 # Activation function ("tanh" or "ReLu" or "SmoothReLu") activation = SmoothReLu # Type of network ("dense" the default, or "convolutional") @@ -47,7 +47,7 @@ type_openlayer = activate # factor for scaling initial opening layer weights and bias weights_open_init = 1e-3 # factor for scaling initial weights and bias of intermediate layers -weights_init = 0e-3 +weights_init = 1e-3 # factor for scaling initial classification weights and bias weights_class_init = 1e-3 @@ -66,7 +66,7 @@ braid_maxlevels = 10 # minimum allowed coarse time time grid size (values in 10-30 are usually best) braid_mincoarse = 10 # maximum number of iterations -braid_maxiter = 15 +braid_maxiter = 2 # absolute tolerance braid_abstol = 1e-15 # absolute adjoint tolerance @@ -94,7 +94,7 @@ nbatch = 5000 # relaxation param for tikhonov term gamma_tik = 1e-7 # relaxation param for time-derivative term -gamma_ddt = 1e-7 +gamma_ddt = 1e-5 # relaxation param for tikhonov term of classification weights gamma_class = 1e-7 # stepsize selection type ("fixed" or "backtrackingLS" or "oneoverk") @@ -106,19 +106,19 @@ stepsize_type = backtrackingLS # initial stepsize stepsize = 1.0 # maximum number of optimization iterations -optim_maxiter = 10 +optim_maxiter = 130 # absolute stopping criterion for the gradient norm gtol = 1e-4 # maximum number of linesearch iterations -ls_maxiter = 20 +ls_maxiter = 15 # factor for modifying the stepsize within a linesearch iteration ls_factor = 0.5 # Hessian Approximation ("BFGS", "L-BFGS" or "Identity") hessian_approx = L-BFGS # number of stages for l-bfgs method -lbfgs_stages = 20 +lbfgs_stages = 10 # level for validation computation: # -1 = never validate # 0 = validate only after optimization finishes. # 1 = validate in each optimization iteration -validationlevel = 0 +validationlevel = 1 From 4910a5372a90ff53e1992381cbf504e3bb90f765 Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 22 Jul 2019 22:07:47 -0700 Subject: [PATCH 29/38] Update testing script and output files. The python testing script runs various test cases and compares the output with the saved optim file (simple vimdiff). By default, maxlevels = 1 and 10 are tested running on 1, 2, and 5 cores each. Only the peaks example is tested so far. --- testing/peaks.cfg | 63 ++++++++++++++++--------------- testing/peaks.npt1.ml1.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt1.ml10.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt2.ml1.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt2.ml10.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt5.ml1.optim.dat | 60 ++++++++++++----------------- testing/peaks.npt5.ml10.optim.dat | 60 ++++++++++++----------------- testing/testing.py | 6 ++- 8 files changed, 187 insertions(+), 242 deletions(-) diff --git a/testing/peaks.cfg b/testing/peaks.cfg index ed67381..842edc5 100644 --- a/testing/peaks.cfg +++ b/testing/peaks.cfg @@ -3,22 +3,22 @@ ################################ # relative data folder location -datafolder = data -# training examples filename -ftrain_ex = Ytrain_orig.dat -# training labels/classes filename -ftrain_labels = Ctrain_orig.dat -# validation examples filename -fval_ex = Yval_orig.dat -# validation labels/classes filename -fval_labels = Cval_orig.dat -# number of training data elements +datafolder = ../examples/peaks/ +# filename of training data feature vectors +ftrain_ex = features_training.dat +# filename of training data labels/classes +ftrain_labels = labels_training.dat +# filename of validation data feature +fval_ex = features_validation.dat +# filename of validation data labels/classes +fval_labels = labels_validation.dat +# number of training data elements (that many lines will be read!) ntraining = 5000 -# number of validation data elements +# number of validation data elements (that many lines will be read!) nvalidation = 200 -# number of features in training and validation examples +# number of features within the training and validation data set nfeatures = 2 -# number of labels/classes +# number of labels/classes within the training and validation data set nclasses = 5 # filename for opening weights and bias (set to NONE if not given) @@ -32,10 +32,10 @@ weightsclassificationfile = NONE # number of channels nchannels = 8 -# number of layers (minimum two, opening layer and classification layer) -nlayers = 30 +# number of layers (including opening layer and classification layer) (nlayer >= 3 !) +nlayers = 32 # final time -T = 5.0 +T = 1.0 # Activation function ("tanh" or "ReLu" or "SmoothReLu") activation = SmoothReLu # Type of network ("dense" the default, or "convolutional") @@ -45,14 +45,14 @@ network_type = dense # "activate": same as replicate, only apply tuned, shifted tanh activation function for MNIST. type_openlayer = activate # factor for scaling initial opening layer weights and bias -weights_open_init = 0e-3 +weights_open_init = 1e-3 # factor for scaling initial weights and bias of intermediate layers -weights_init = 1e-3 +weights_init = 0e-3 # factor for scaling initial classification weights and bias weights_class_init = 1e-3 ################################ -#BRAID +# XBraid ################################ # coarsening factor on level 0 @@ -62,15 +62,15 @@ braid_cfactor0 = 2 # coarsening factor on all other levels braid_cfactor = 2 # maximum number of levels -braid_maxlevels = 10 +braid_maxlevels = 1 # minimum allowed coarse time time grid size (values in 10-30 are usually best) braid_mincoarse = 10 # maximum number of iterations -braid_maxiter = 2 +braid_maxiter = 15 # absolute tolerance -braid_abstol = 1e-15 +braid_abstol = 1e-10 # absolute adjoint tolerance -braid_adjtol = 1e-15 +braid_adjtol = 1e-10 # printlevel braid_printlevel = 1 # access level @@ -85,28 +85,28 @@ braid_nrelax = 1 braid_nrelax0 = 0 #################################### -#Optimization +# Optimization #################################### # Type of batch selection ("deterministic" or "stochastic") batch_type = deterministic # Batch size -nbatch = 5000 +nbatch = 200 # relaxation param for tikhonov term gamma_tik = 1e-7 # relaxation param for time-derivative term -gamma_ddt = 1e-7 +gamma_ddt = 1e-5 # relaxation param for tikhonov term of classification weights gamma_class = 1e-7 # stepsize selection type ("fixed" or "backtrackingLS" or "oneoverk") # determines how to choose alpha in design update x_new = x_old - alpha * direction # fixed : constant alpha being the initial stepsize -# backtrackingLS : find alpha from backtracking linesearch, starting with initial stepsize +# backtrackingLS : find alpha from backtracking linesearch, starting at initial stepsize # oneoverk : alpha = 1/k where k is the current optimization iteration index stepsize_type = backtrackingLS -# initial stepsize for fixed alpha and backtracking linesearch selection +# initial stepsize stepsize = 1.0 # maximum number of optimization iterations -optim_maxiter = 20 +optim_maxiter = 100 # absolute stopping criterion for the gradient norm gtol = 1e-4 # maximum number of linesearch iterations @@ -117,5 +117,8 @@ ls_factor = 0.5 hessian_approx = L-BFGS # number of stages for l-bfgs method lbfgs_stages = 20 -# level for validation computation: 0 - validate only after optimization finishes. 1 - validate in each optimization iteration +# level for validation computation: +# -1 = never validate +# 0 = validate only after optimization finishes. +# 1 = validate in each optimization iteration validationlevel = 1 diff --git a/testing/peaks.npt1.ml1.optim.dat b/testing/peaks.npt1.ml1.optim.dat index 8dfb502..9ab3943 100644 --- a/testing/peaks.npt1.ml1.optim.dat +++ b/testing/peaks.npt1.ml1.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 -1.00000000e+00 -1.00000000e+00 1.60941989767865e+00 1.60941989720218e+00 5.47547521438103e-01 1.000000 0 20.18% 21.00% 0.2 -001 -1.00000000e+00 -1.00000000e+00 1.38071340186225e+00 1.38071338639355e+00 3.06051904945471e-01 1.000000 0 48.00% 46.50% 0.6 -002 -1.00000000e+00 -1.00000000e+00 1.23596247912580e+00 1.23596238748763e+00 1.29397210079374e-01 1.000000 0 50.78% 48.50% 0.9 -003 -1.00000000e+00 -1.00000000e+00 1.20341971297680e+00 1.20341956950837e+00 1.18843456996184e-01 1.000000 0 56.24% 54.50% 1.2 -004 -1.00000000e+00 -1.00000000e+00 1.18418727997486e+00 1.18418706821137e+00 7.57493851234179e-02 1.000000 0 57.00% 54.00% 1.6 -005 -1.00000000e+00 -1.00000000e+00 1.17681154387789e+00 1.17681130238162e+00 4.92897668623518e-02 1.000000 0 58.78% 56.00% 1.9 -006 -1.00000000e+00 -1.00000000e+00 1.16938781109130e+00 1.16938754241913e+00 5.63354947836319e-02 1.000000 0 58.22% 54.00% 2.3 -007 -1.00000000e+00 -1.00000000e+00 1.15847109277098e+00 1.15847078889672e+00 8.74543241159731e-02 1.000000 0 54.00% 50.00% 2.7 -008 -1.00000000e+00 -1.00000000e+00 1.15763751519476e+00 1.15763709061927e+00 2.71593130325443e-01 1.000000 0 56.40% 53.50% 3.0 -009 -1.00000000e+00 -1.00000000e+00 1.14274573639825e+00 1.14274537295253e+00 1.29627926674329e-01 1.000000 0 52.68% 46.00% 3.3 -010 -1.00000000e+00 -1.00000000e+00 1.14122719808983e+00 1.14122681274333e+00 1.55775797203811e-01 1.000000 0 53.10% 48.00% 3.6 -011 -1.00000000e+00 -1.00000000e+00 1.13494201952478e+00 1.13494161706763e+00 6.57957962169811e-02 1.000000 0 55.94% 51.00% 4.0 -012 -1.00000000e+00 -1.00000000e+00 1.13145597537932e+00 1.13145550124762e+00 1.26247044561169e-01 1.000000 0 51.98% 49.50% 4.3 -013 -1.00000000e+00 -1.00000000e+00 1.12368754549753e+00 1.12368705376703e+00 1.10635760888726e-01 1.000000 0 55.82% 54.00% 4.6 -014 -1.00000000e+00 -1.00000000e+00 1.11155460188595e+00 1.11155398029660e+00 1.39385721056845e-01 1.000000 0 57.88% 56.00% 4.9 -015 -1.00000000e+00 -1.00000000e+00 1.10515556053970e+00 1.10515489947227e+00 1.13781734395289e-01 1.000000 0 60.94% 57.00% 5.3 -016 -1.00000000e+00 -1.00000000e+00 1.09562590165864e+00 1.09562515860787e+00 2.52376513334094e-01 1.000000 0 60.68% 57.50% 5.6 -017 -1.00000000e+00 -1.00000000e+00 1.08197155968558e+00 1.08197063660131e+00 5.55013786931782e-01 1.000000 0 59.42% 56.00% 5.9 -018 -1.00000000e+00 -1.00000000e+00 1.07924452229731e+00 1.07924359893069e+00 6.18277564731762e-01 1.000000 0 58.32% 57.00% 6.2 -019 -1.00000000e+00 -1.00000000e+00 1.07415528298030e+00 1.07415447170882e+00 2.75740177515614e-01 0.500000 1 59.28% 55.50% 6.6 +000 -1.00000000e+00 -1.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.0 +001 -1.00000000e+00 -1.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.0 +002 -1.00000000e+00 -1.00000000e+00 1.05036886903368e-03 1.04931297594737e-03 6.51136165937218e-03 1.000000 0 100.00% 20.00% 0.1 +003 -1.00000000e+00 -1.00000000e+00 8.38924054937610e-04 8.37860415154911e-04 5.27459181685681e-03 1.000000 0 100.00% 20.00% 0.1 +004 -1.00000000e+00 -1.00000000e+00 3.09469131150244e-04 3.08370156887922e-04 2.07090184605933e-03 1.000000 0 100.00% 20.00% 0.1 +005 -1.00000000e+00 -1.00000000e+00 1.56742722262840e-04 1.55619105190084e-04 1.09169627784517e-03 1.000000 0 100.00% 20.00% 0.1 +006 -1.00000000e+00 -1.00000000e+00 7.10282645639592e-05 6.98756630906118e-05 5.15099197829775e-04 1.000000 0 100.00% 20.00% 0.1 +007 -1.00000000e+00 -1.00000000e+00 3.41186662095647e-05 3.29388953025643e-05 2.53915778855823e-04 1.000000 0 100.00% 20.00% 0.2 +008 -1.00000000e+00 -1.00000000e+00 1.65032674860585e-05 1.52959730466568e-05 1.23156345893023e-04 1.000000 0 100.00% 20.00% 0.2 +009 -1.00000000e+00 -1.00000000e+00 8.40503071448269e-06 7.17084153786459e-06 6.01241929460480e-05 1.000000 0 100.00% 20.00% 0.2 diff --git a/testing/peaks.npt1.ml10.optim.dat b/testing/peaks.npt1.ml10.optim.dat index 407c132..837f75d 100644 --- a/testing/peaks.npt1.ml10.optim.dat +++ b/testing/peaks.npt1.ml10.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 1.05426534e-05 7.01718976e-13 1.60941989766493e+00 1.60941989718846e+00 5.47547519325756e-01 1.000000 0 20.18% 21.00% 1.2 -001 1.57996193e-17 2.03041298e-10 1.38071340216910e+00 1.38071338670040e+00 3.06050567716981e-01 1.000000 0 48.00% 46.50% 3.0 -002 7.29308604e-13 4.22213509e-10 1.23596253137683e+00 1.23596243974067e+00 1.29391394257781e-01 1.000000 0 50.78% 48.50% 4.8 -003 9.81124600e-13 2.07669782e-10 1.20341417342464e+00 1.20341402994788e+00 1.18831935496275e-01 1.000000 0 56.24% 54.50% 6.5 -004 6.26066790e-12 4.49854737e-10 1.18418442453580e+00 1.18418421274440e+00 7.58416506674437e-02 1.000000 0 56.98% 54.00% 8.3 -005 6.78105919e-12 2.17426183e-10 1.17681138506102e+00 1.17681114353766e+00 4.93204360796171e-02 1.000000 0 58.80% 56.00% 10.0 -006 2.30351731e-11 3.40981732e-10 1.16939416065256e+00 1.16939389207214e+00 5.63229160588530e-02 1.000000 0 58.22% 54.00% 11.9 -007 8.88623265e-11 7.08703623e-10 1.15848320762452e+00 1.15848290381382e+00 8.77505478477174e-02 1.000000 0 54.00% 50.00% 13.6 -008 1.53502187e-09 3.43627498e-09 1.15752458099280e+00 1.15752415760565e+00 2.70258261860996e-01 1.000000 0 56.42% 53.50% 15.3 -009 3.35426627e-10 2.10759273e-09 1.14272215805333e+00 1.14272179436899e+00 1.28969655129404e-01 1.000000 0 52.74% 46.00% 16.9 -010 8.65490676e-11 1.05329993e-09 1.14123385478706e+00 1.14123346978230e+00 1.55750623407490e-01 1.000000 0 53.14% 48.00% 18.6 -011 2.41000293e-10 5.31010337e-10 1.13494612729255e+00 1.13494572513913e+00 6.54530806420039e-02 1.000000 0 55.90% 51.00% 20.3 -012 1.84660098e-09 1.94338217e-09 1.13142768073210e+00 1.13142720629247e+00 1.25443138882351e-01 1.000000 0 51.96% 49.00% 21.9 -013 8.54540924e-10 1.12055818e-09 1.12358278356824e+00 1.12358229180074e+00 1.11310852815511e-01 1.000000 0 55.88% 54.50% 23.6 -014 1.64024146e-08 7.14719084e-09 1.11134576834466e+00 1.11134514381860e+00 1.40185628559086e-01 1.000000 0 57.94% 56.50% 25.2 -015 9.73572966e-09 2.81897201e-09 1.10494151034690e+00 1.10494084600873e+00 1.15680085929700e-01 1.000000 0 60.98% 57.00% 26.9 -016 3.27161110e-08 5.09705006e-09 1.09542616968119e+00 1.09542542799467e+00 2.51017228904287e-01 1.000000 0 60.68% 57.50% 28.5 -017 3.55387932e-07 1.33789499e-08 1.08242275846187e+00 1.08242181907883e+00 5.74669282315359e-01 1.000000 0 59.18% 57.50% 30.2 -018 1.35900404e-08 1.27840638e-08 1.07817898750936e+00 1.07817806809747e+00 3.68508030727317e-01 1.000000 0 58.34% 56.00% 31.8 -019 9.54593730e-08 1.10671022e-08 1.07641618944747e+00 1.07641542511829e+00 5.40433679343467e-01 1.000000 0 58.12% 53.50% 33.4 +000 1.48762021e-18 0.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.1 +001 4.87268972e-19 0.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.2 +002 1.20657289e-16 9.58293526e-11 1.05036886903368e-03 1.04931297594737e-03 6.51137546917077e-03 1.000000 0 100.00% 20.00% 0.3 +003 8.86998023e-17 1.34391587e-13 8.38923640767822e-04 8.37860001146083e-04 5.27458994776971e-03 1.000000 0 100.00% 20.00% 0.4 +004 1.21309331e-16 5.43079170e-13 3.09474514735135e-04 3.08375531427215e-04 2.07093191405256e-03 1.000000 0 100.00% 20.00% 0.6 +005 1.43429471e-16 2.41778398e-13 1.56745527599925e-04 1.55621886721240e-04 1.09171100040307e-03 1.000000 0 100.00% 20.00% 0.7 +006 1.78697630e-16 2.03233182e-13 7.10300937789059e-05 6.98774426357128e-05 5.15108834175264e-04 1.000000 0 100.00% 20.00% 0.8 +007 2.10635379e-16 1.27882822e-13 3.41197750696654e-05 3.29399208824851e-05 2.53921341908186e-04 1.000000 0 100.00% 20.00% 0.9 +008 2.22144503e-16 8.82507913e-14 1.65039906218550e-05 1.52965683800520e-05 1.23159632420279e-04 1.000000 0 100.00% 20.00% 1.1 +009 2.60100400e-16 5.80874925e-14 8.40555413834112e-06 7.17118187402434e-06 6.01261027573695e-05 1.000000 0 100.00% 20.00% 1.2 diff --git a/testing/peaks.npt2.ml1.optim.dat b/testing/peaks.npt2.ml1.optim.dat index f1a8438..11fec9f 100644 --- a/testing/peaks.npt2.ml1.optim.dat +++ b/testing/peaks.npt2.ml1.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 -1.00000000e+00 -1.00000000e+00 1.60941989767865e+00 1.60941989720218e+00 5.47547521438103e-01 1.000000 0 20.18% 21.00% 0.2 -001 -1.00000000e+00 -1.00000000e+00 1.38071340186225e+00 1.38071338639355e+00 3.06051904945471e-01 1.000000 0 48.00% 46.50% 0.6 -002 -1.00000000e+00 -1.00000000e+00 1.23596247912580e+00 1.23596238748763e+00 1.29397210079374e-01 1.000000 0 50.78% 48.50% 0.9 -003 -1.00000000e+00 -1.00000000e+00 1.20341971297680e+00 1.20341956950837e+00 1.18843456996184e-01 1.000000 0 56.24% 54.50% 1.3 -004 -1.00000000e+00 -1.00000000e+00 1.18418727997486e+00 1.18418706821137e+00 7.57493851234181e-02 1.000000 0 57.00% 54.00% 1.6 -005 -1.00000000e+00 -1.00000000e+00 1.17681154387789e+00 1.17681130238162e+00 4.92897668623518e-02 1.000000 0 58.78% 56.00% 2.0 -006 -1.00000000e+00 -1.00000000e+00 1.16938781109130e+00 1.16938754241913e+00 5.63354947836322e-02 1.000000 0 58.22% 54.00% 2.4 -007 -1.00000000e+00 -1.00000000e+00 1.15847109277098e+00 1.15847078889672e+00 8.74543241159725e-02 1.000000 0 54.00% 50.00% 2.8 -008 -1.00000000e+00 -1.00000000e+00 1.15763751519476e+00 1.15763709061927e+00 2.71593130325434e-01 1.000000 0 56.40% 53.50% 3.1 -009 -1.00000000e+00 -1.00000000e+00 1.14274573639825e+00 1.14274537295253e+00 1.29627926674328e-01 1.000000 0 52.68% 46.00% 3.5 -010 -1.00000000e+00 -1.00000000e+00 1.14122719808982e+00 1.14122681274333e+00 1.55775797203806e-01 1.000000 0 53.10% 48.00% 3.8 -011 -1.00000000e+00 -1.00000000e+00 1.13494201952478e+00 1.13494161706763e+00 6.57957962169820e-02 1.000000 0 55.94% 51.00% 4.2 -012 -1.00000000e+00 -1.00000000e+00 1.13145597537932e+00 1.13145550124762e+00 1.26247044561172e-01 1.000000 0 51.98% 49.50% 4.5 -013 -1.00000000e+00 -1.00000000e+00 1.12368754549752e+00 1.12368705376703e+00 1.10635760888722e-01 1.000000 0 55.82% 54.00% 4.8 -014 -1.00000000e+00 -1.00000000e+00 1.11155460188595e+00 1.11155398029660e+00 1.39385721056834e-01 1.000000 0 57.88% 56.00% 5.2 -015 -1.00000000e+00 -1.00000000e+00 1.10515556053969e+00 1.10515489947227e+00 1.13781734395290e-01 1.000000 0 60.94% 57.00% 5.6 -016 -1.00000000e+00 -1.00000000e+00 1.09562590165864e+00 1.09562515860787e+00 2.52376513334136e-01 1.000000 0 60.68% 57.50% 6.0 -017 -1.00000000e+00 -1.00000000e+00 1.08197155968557e+00 1.08197063660131e+00 5.55013786931869e-01 1.000000 0 59.42% 56.00% 6.3 -018 -1.00000000e+00 -1.00000000e+00 1.07924452229731e+00 1.07924359893069e+00 6.18277564731541e-01 1.000000 0 58.32% 57.00% 6.6 -019 -1.00000000e+00 -1.00000000e+00 1.07415528298030e+00 1.07415447170882e+00 2.75740177515749e-01 0.500000 1 59.28% 55.50% 7.0 +000 -1.00000000e+00 -1.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.0 +001 -1.00000000e+00 -1.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.0 +002 -1.00000000e+00 -1.00000000e+00 1.05036886903367e-03 1.04931297594736e-03 6.51136165937214e-03 1.000000 0 100.00% 20.00% 0.1 +003 -1.00000000e+00 -1.00000000e+00 8.38924054937610e-04 8.37860415154911e-04 5.27459181685679e-03 1.000000 0 100.00% 20.00% 0.1 +004 -1.00000000e+00 -1.00000000e+00 3.09469131150244e-04 3.08370156887922e-04 2.07090184605932e-03 1.000000 0 100.00% 20.00% 0.1 +005 -1.00000000e+00 -1.00000000e+00 1.56742722262840e-04 1.55619105190084e-04 1.09169627784516e-03 1.000000 0 100.00% 20.00% 0.1 +006 -1.00000000e+00 -1.00000000e+00 7.10282645639592e-05 6.98756630906118e-05 5.15099197829774e-04 1.000000 0 100.00% 20.00% 0.1 +007 -1.00000000e+00 -1.00000000e+00 3.41186662095647e-05 3.29388953025643e-05 2.53915778855823e-04 1.000000 0 100.00% 20.00% 0.2 +008 -1.00000000e+00 -1.00000000e+00 1.65032674860585e-05 1.52959730466568e-05 1.23156345893023e-04 1.000000 0 100.00% 20.00% 0.2 +009 -1.00000000e+00 -1.00000000e+00 8.40503071448269e-06 7.17084153786459e-06 6.01241929460480e-05 1.000000 0 100.00% 20.00% 0.2 diff --git a/testing/peaks.npt2.ml10.optim.dat b/testing/peaks.npt2.ml10.optim.dat index 96b0352..5c95af9 100644 --- a/testing/peaks.npt2.ml10.optim.dat +++ b/testing/peaks.npt2.ml10.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 1.05426534e-05 7.01718976e-13 1.60941989766493e+00 1.60941989718846e+00 5.47547519325756e-01 1.000000 0 20.18% 21.00% 0.8 -001 1.57996193e-17 2.03041298e-10 1.38071340216910e+00 1.38071338670040e+00 3.06050567716981e-01 1.000000 0 48.00% 46.50% 1.9 -002 7.29308604e-13 4.22213509e-10 1.23596253137683e+00 1.23596243974067e+00 1.29391394257781e-01 1.000000 0 50.78% 48.50% 3.2 -003 9.81124621e-13 2.07669782e-10 1.20341417342464e+00 1.20341402994788e+00 1.18831935496275e-01 1.000000 0 56.24% 54.50% 4.3 -004 6.26066780e-12 4.49854737e-10 1.18418442453580e+00 1.18418421274440e+00 7.58416506674439e-02 1.000000 0 56.98% 54.00% 5.6 -005 6.78105922e-12 2.17426183e-10 1.17681138506102e+00 1.17681114353766e+00 4.93204360796170e-02 1.000000 0 58.80% 56.00% 6.7 -006 2.30351729e-11 3.40981732e-10 1.16939416065256e+00 1.16939389207214e+00 5.63229160588530e-02 1.000000 0 58.22% 54.00% 8.0 -007 8.88623266e-11 7.08703623e-10 1.15848320762452e+00 1.15848290381382e+00 8.77505478477175e-02 1.000000 0 54.00% 50.00% 9.1 -008 1.53502187e-09 3.43627498e-09 1.15752458099280e+00 1.15752415760565e+00 2.70258261860993e-01 1.000000 0 56.42% 53.50% 10.3 -009 3.35426626e-10 2.10759273e-09 1.14272215805333e+00 1.14272179436899e+00 1.28969655129404e-01 1.000000 0 52.74% 46.00% 11.5 -010 8.65490677e-11 1.05329993e-09 1.14123385478706e+00 1.14123346978230e+00 1.55750623407489e-01 1.000000 0 53.14% 48.00% 12.7 -011 2.41000293e-10 5.31010337e-10 1.13494612729255e+00 1.13494572513913e+00 6.54530806420046e-02 1.000000 0 55.90% 51.00% 13.8 -012 1.84660098e-09 1.94338217e-09 1.13142768073210e+00 1.13142720629247e+00 1.25443138882354e-01 1.000000 0 51.96% 49.00% 15.0 -013 8.54540924e-10 1.12055818e-09 1.12358278356824e+00 1.12358229180074e+00 1.11310852815509e-01 1.000000 0 55.88% 54.50% 16.1 -014 1.64024146e-08 7.14719084e-09 1.11134576834466e+00 1.11134514381860e+00 1.40185628559072e-01 1.000000 0 57.94% 56.50% 17.3 -015 9.73572966e-09 2.81897201e-09 1.10494151034690e+00 1.10494084600873e+00 1.15680085929693e-01 1.000000 0 60.98% 57.00% 18.4 -016 3.27161110e-08 5.09705006e-09 1.09542616968119e+00 1.09542542799467e+00 2.51017228904277e-01 1.000000 0 60.68% 57.50% 19.6 -017 3.55387932e-07 1.33789499e-08 1.08242275846187e+00 1.08242181907883e+00 5.74669282315588e-01 1.000000 0 59.18% 57.50% 20.6 -018 1.35900404e-08 1.27840638e-08 1.07817898750937e+00 1.07817806809748e+00 3.68508030728956e-01 1.000000 0 58.34% 56.00% 21.8 -019 9.54593730e-08 1.10671022e-08 1.07641618944750e+00 1.07641542511832e+00 5.40433679341661e-01 1.000000 0 58.12% 53.50% 22.9 +000 1.48762021e-18 0.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.1 +001 4.87268972e-19 0.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.1 +002 1.20416982e-16 9.58293526e-11 1.05036886903367e-03 1.04931297594736e-03 6.51137546917073e-03 1.000000 0 100.00% 20.00% 0.2 +003 8.86650549e-17 1.34391587e-13 8.38923640767822e-04 8.37860001146083e-04 5.27458994776969e-03 1.000000 0 100.00% 20.00% 0.3 +004 1.21304250e-16 5.43079170e-13 3.09474514735135e-04 3.08375531427215e-04 2.07093191405255e-03 1.000000 0 100.00% 20.00% 0.4 +005 1.43171427e-16 2.41778398e-13 1.56745527599925e-04 1.55621886721240e-04 1.09171100040307e-03 1.000000 0 100.00% 20.00% 0.5 +006 1.78721770e-16 2.03233182e-13 7.10300937789059e-05 6.98774426357128e-05 5.15108834175262e-04 1.000000 0 100.00% 20.00% 0.6 +007 2.10562219e-16 1.27882822e-13 3.41197750696654e-05 3.29399208824851e-05 2.53921341908184e-04 1.000000 0 100.00% 20.00% 0.6 +008 2.21803000e-16 8.82507913e-14 1.65039906218550e-05 1.52965683800520e-05 1.23159632420279e-04 1.000000 0 100.00% 20.00% 0.7 +009 2.59882318e-16 5.80874925e-14 8.40555413834112e-06 7.17118187402434e-06 6.01261027573693e-05 1.000000 0 100.00% 20.00% 0.8 diff --git a/testing/peaks.npt5.ml1.optim.dat b/testing/peaks.npt5.ml1.optim.dat index 12a784f..b064fb6 100644 --- a/testing/peaks.npt5.ml1.optim.dat +++ b/testing/peaks.npt5.ml1.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 -1.00000000e+00 -1.00000000e+00 1.60941989767865e+00 1.60941989720218e+00 5.47547521438103e-01 1.000000 0 20.18% 21.00% 0.5 -001 -1.00000000e+00 -1.00000000e+00 1.38071340186225e+00 1.38071338639355e+00 3.06051904945471e-01 1.000000 0 48.00% 46.50% 1.2 -002 -1.00000000e+00 -1.00000000e+00 1.23596247912580e+00 1.23596238748763e+00 1.29397210079374e-01 1.000000 0 50.78% 48.50% 1.8 -003 -1.00000000e+00 -1.00000000e+00 1.20341971297680e+00 1.20341956950837e+00 1.18843456996184e-01 1.000000 0 56.24% 54.50% 2.6 -004 -1.00000000e+00 -1.00000000e+00 1.18418727997486e+00 1.18418706821137e+00 7.57493851234178e-02 1.000000 0 57.00% 54.00% 3.2 -005 -1.00000000e+00 -1.00000000e+00 1.17681154387789e+00 1.17681130238162e+00 4.92897668623518e-02 1.000000 0 58.78% 56.00% 3.8 -006 -1.00000000e+00 -1.00000000e+00 1.16938781109130e+00 1.16938754241913e+00 5.63354947836319e-02 1.000000 0 58.22% 54.00% 4.5 -007 -1.00000000e+00 -1.00000000e+00 1.15847109277098e+00 1.15847078889672e+00 8.74543241159734e-02 1.000000 0 54.00% 50.00% 5.1 -008 -1.00000000e+00 -1.00000000e+00 1.15763751519476e+00 1.15763709061927e+00 2.71593130325441e-01 1.000000 0 56.40% 53.50% 5.9 -009 -1.00000000e+00 -1.00000000e+00 1.14274573639825e+00 1.14274537295253e+00 1.29627926674328e-01 1.000000 0 52.68% 46.00% 6.5 -010 -1.00000000e+00 -1.00000000e+00 1.14122719808983e+00 1.14122681274333e+00 1.55775797203811e-01 1.000000 0 53.10% 48.00% 7.3 -011 -1.00000000e+00 -1.00000000e+00 1.13494201952478e+00 1.13494161706763e+00 6.57957962169811e-02 1.000000 0 55.94% 51.00% 7.9 -012 -1.00000000e+00 -1.00000000e+00 1.13145597537932e+00 1.13145550124762e+00 1.26247044561170e-01 1.000000 0 51.98% 49.50% 8.6 -013 -1.00000000e+00 -1.00000000e+00 1.12368754549753e+00 1.12368705376703e+00 1.10635760888728e-01 1.000000 0 55.82% 54.00% 9.2 -014 -1.00000000e+00 -1.00000000e+00 1.11155460188595e+00 1.11155398029660e+00 1.39385721056834e-01 1.000000 0 57.88% 56.00% 9.8 -015 -1.00000000e+00 -1.00000000e+00 1.10515556053969e+00 1.10515489947227e+00 1.13781734395281e-01 1.000000 0 60.94% 57.00% 10.5 -016 -1.00000000e+00 -1.00000000e+00 1.09562590165864e+00 1.09562515860787e+00 2.52376513334124e-01 1.000000 0 60.68% 57.50% 11.3 -017 -1.00000000e+00 -1.00000000e+00 1.08197155968558e+00 1.08197063660131e+00 5.55013786931906e-01 1.000000 0 59.42% 56.00% 11.9 -018 -1.00000000e+00 -1.00000000e+00 1.07924452229732e+00 1.07924359893070e+00 6.18277564731091e-01 1.000000 0 58.32% 57.00% 12.6 -019 -1.00000000e+00 -1.00000000e+00 1.07415528298029e+00 1.07415447170881e+00 2.75740177515766e-01 0.500000 1 59.28% 55.50% 13.6 +000 -1.00000000e+00 -1.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.0 +001 -1.00000000e+00 -1.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.1 +002 -1.00000000e+00 -1.00000000e+00 1.05036886903367e-03 1.04931297594736e-03 6.51136165937214e-03 1.000000 0 100.00% 20.00% 0.1 +003 -1.00000000e+00 -1.00000000e+00 8.38924054937610e-04 8.37860415154911e-04 5.27459181685679e-03 1.000000 0 100.00% 20.00% 0.1 +004 -1.00000000e+00 -1.00000000e+00 3.09469131150244e-04 3.08370156887922e-04 2.07090184605932e-03 1.000000 0 100.00% 20.00% 0.2 +005 -1.00000000e+00 -1.00000000e+00 1.56742722262840e-04 1.55619105190084e-04 1.09169627784516e-03 1.000000 0 100.00% 20.00% 0.2 +006 -1.00000000e+00 -1.00000000e+00 7.10282645639592e-05 6.98756630906118e-05 5.15099197829773e-04 1.000000 0 100.00% 20.00% 0.2 +007 -1.00000000e+00 -1.00000000e+00 3.41186662095647e-05 3.29388953025643e-05 2.53915778855823e-04 1.000000 0 100.00% 20.00% 0.3 +008 -1.00000000e+00 -1.00000000e+00 1.65032674860585e-05 1.52959730466568e-05 1.23156345893023e-04 1.000000 0 100.00% 20.00% 0.3 +009 -1.00000000e+00 -1.00000000e+00 8.40503071448269e-06 7.17084153786459e-06 6.01241929460479e-05 1.000000 0 100.00% 20.00% 0.3 diff --git a/testing/peaks.npt5.ml10.optim.dat b/testing/peaks.npt5.ml10.optim.dat index cf199f5..1d75665 100644 --- a/testing/peaks.npt5.ml10.optim.dat +++ b/testing/peaks.npt5.ml10.optim.dat @@ -1,15 +1,15 @@ -# Problem setup: datafolder data -# training examples Ytrain_orig.dat -# training labels Ctrain_orig.dat -# validation examples Yval_orig.dat -# validation labels Cval_orig.dat +# Problem setup: datafolder ../examples/peaks/ +# training examples features_training.dat +# training labels labels_training.dat +# validation examples features_validation.dat +# validation labels labels_validation.dat # ntraining 5000 # nvalidation 200 # nfeatures 2 # nclasses 5 # nchannels 8 -# nlayers 30 -# T 5.000000 +# nlayers 32 +# T 1.000000 # network type dense # Activation SmoothReLU # openlayer type 1 @@ -17,9 +17,9 @@ # min coarse 10 # coasening 2 # coasening (level 0) 2 -# max. braid iter 2 -# abs. tol 1e-15 -# abs. toladj 1e-15 +# max. braid iter 15 +# abs. tol 1e-10 +# abs. toladj 1e-10 # print level 1 # access level 0 # skip? 0 @@ -27,41 +27,31 @@ # nrelax (level 0) 0 # nrelax 1 # Optimization: optimization type deterministic -# nbatch 5000 +# nbatch 200 # gamma_tik 1e-07 -# gamma_ddt 1e-07 +# gamma_ddt 1e-05 # gamma_class 1e-07 # stepsize type backtracking line-search # stepsize 1.000000 -# max. optim iter 20 +# max. optim iter 100 # gtol 1e-04 # max. ls iter 20 # ls factor 0.500000 -# weights_init 0.001000 -# weights_open_init 0.000000 +# weights_init 0.000000 +# weights_open_init 0.001000 # weights_class_init 0.001000 # hessianapprox_type L-BFGS # lbfgs_stages 20 # validationlevel 1 # || r || || r_adj || Objective Loss || grad || Stepsize ls_iter Accur_train Accur_val Time(sec) -000 1.05426534e-05 7.01718976e-13 1.60941989766493e+00 1.60941989718846e+00 5.47547519325756e-01 1.000000 0 20.18% 21.00% 1.1 -001 1.57996193e-17 2.03041298e-10 1.38071340216910e+00 1.38071338670040e+00 3.06050567716981e-01 1.000000 0 48.00% 46.50% 2.5 -002 7.29308609e-13 4.22213509e-10 1.23596253137683e+00 1.23596243974067e+00 1.29391394257781e-01 1.000000 0 50.78% 48.50% 4.1 -003 9.81124667e-13 2.07669782e-10 1.20341417342464e+00 1.20341402994788e+00 1.18831935496275e-01 1.000000 0 56.24% 54.50% 5.7 -004 6.26066791e-12 4.49854737e-10 1.18418442453580e+00 1.18418421274440e+00 7.58416506674442e-02 1.000000 0 56.98% 54.00% 7.1 -005 6.78105921e-12 2.17426183e-10 1.17681138506102e+00 1.17681114353766e+00 4.93204360796169e-02 1.000000 0 58.80% 56.00% 8.8 -006 2.30351730e-11 3.40981732e-10 1.16939416065256e+00 1.16939389207214e+00 5.63229160588529e-02 1.000000 0 58.22% 54.00% 10.3 -007 8.88623266e-11 7.08703623e-10 1.15848320762452e+00 1.15848290381382e+00 8.77505478477171e-02 1.000000 0 54.00% 50.00% 12.0 -008 1.53502187e-09 3.43627498e-09 1.15752458099280e+00 1.15752415760565e+00 2.70258261860993e-01 1.000000 0 56.42% 53.50% 13.6 -009 3.35426626e-10 2.10759273e-09 1.14272215805333e+00 1.14272179436899e+00 1.28969655129406e-01 1.000000 0 52.74% 46.00% 15.1 -010 8.65490678e-11 1.05329993e-09 1.14123385478706e+00 1.14123346978230e+00 1.55750623407485e-01 1.000000 0 53.14% 48.00% 16.6 -011 2.41000293e-10 5.31010337e-10 1.13494612729255e+00 1.13494572513913e+00 6.54530806420054e-02 1.000000 0 55.90% 51.00% 18.2 -012 1.84660098e-09 1.94338217e-09 1.13142768073210e+00 1.13142720629247e+00 1.25443138882352e-01 1.000000 0 51.96% 49.00% 19.5 -013 8.54540924e-10 1.12055818e-09 1.12358278356824e+00 1.12358229180074e+00 1.11310852815505e-01 1.000000 0 55.88% 54.50% 21.0 -014 1.64024146e-08 7.14719084e-09 1.11134576834466e+00 1.11134514381860e+00 1.40185628559094e-01 1.000000 0 57.94% 56.50% 22.4 -015 9.73572966e-09 2.81897201e-09 1.10494151034690e+00 1.10494084600873e+00 1.15680085929712e-01 1.000000 0 60.98% 57.00% 23.9 -016 3.27161110e-08 5.09705006e-09 1.09542616968119e+00 1.09542542799467e+00 2.51017228904264e-01 1.000000 0 60.68% 57.50% 25.2 -017 3.55387932e-07 1.33789499e-08 1.08242275846186e+00 1.08242181907883e+00 5.74669282315268e-01 1.000000 0 59.18% 57.50% 26.9 -018 1.35900404e-08 1.27840638e-08 1.07817898750936e+00 1.07817806809747e+00 3.68508030725625e-01 1.000000 0 58.34% 56.00% 28.2 -019 9.54593730e-08 1.10671022e-08 1.07641618944743e+00 1.07641542511825e+00 5.40433679344485e-01 1.000000 0 58.12% 53.50% 29.7 +000 1.48762021e-18 0.00000000e+00 1.60943791243446e+00 1.60943791243409e+00 9.03286343783022e-01 1.000000 0 100.00% 20.00% 0.1 +001 4.87268972e-19 0.00000000e+00 8.93027383470424e-01 8.93027342673751e-01 6.81237374674309e-01 1.000000 0 100.00% 20.00% 0.2 +002 1.20416982e-16 9.58293526e-11 1.05036886903367e-03 1.04931297594736e-03 6.51137546917073e-03 1.000000 0 100.00% 20.00% 0.3 +003 8.86302938e-17 1.34391587e-13 8.38923640767822e-04 8.37860001146083e-04 5.27458994776969e-03 1.000000 0 100.00% 20.00% 0.4 +004 1.21324571e-16 5.43079170e-13 3.09474514735135e-04 3.08375531427215e-04 2.07093191405255e-03 1.000000 0 100.00% 20.00% 0.5 +005 1.43184341e-16 2.41778398e-13 1.56745527599925e-04 1.55621886721240e-04 1.09171100040307e-03 1.000000 0 100.00% 20.00% 0.6 +006 1.78707976e-16 2.03233182e-13 7.10300937789059e-05 6.98774426357128e-05 5.15108834175262e-04 1.000000 0 100.00% 20.00% 0.8 +007 2.10521238e-16 1.27882822e-13 3.41197750696654e-05 3.29399208824851e-05 2.53921341908185e-04 1.000000 0 100.00% 20.00% 1.0 +008 2.22294265e-16 8.82507913e-14 1.65039906218550e-05 1.52965683800520e-05 1.23159632420279e-04 1.000000 0 100.00% 20.00% 1.1 +009 2.59851488e-16 5.80874925e-14 8.40555413834112e-06 7.17118187402434e-06 6.01261027573692e-05 1.000000 0 100.00% 20.00% 1.3 diff --git a/testing/testing.py b/testing/testing.py index c944173..a314d1a 100644 --- a/testing/testing.py +++ b/testing/testing.py @@ -6,6 +6,7 @@ import copy import subprocess import string +sys.path.insert(0, '../pythonutil') from config import * from util import * @@ -45,12 +46,13 @@ os.mkdir(testfoldername) # create a link to training and validation data - datafolder = "../" + config.datafolder - make_link(datafolder, testfoldername + "/" + config.datafolder) + datafolder = config.datafolder + make_link(datafolder, testfoldername + "/data" ) # Set the new configuration konfig = copy.deepcopy(config) konfig.braid_maxlevels = ml + konfig.datafolder = "data" # create the config file testconfig = testname + ".cfg" From e4f4582931ccf9fd4c0168de6b30e389568c79e5 Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 22 Jul 2019 21:47:32 -0700 Subject: [PATCH 30/38] Write output file in same folder where main is called. Output file optim.dat is now written in the same directory, where the executable is called from. --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 37c0b67..aea2e72 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) { /* Open and prepare optimization output file*/ if (myid == MASTER_NODE) { - sprintf(optimfilename, "%s/%s.dat", config->datafolder, "optim"); + sprintf(optimfilename, "%s.dat", "optim"); optimfile = fopen(optimfilename, "w"); config->writeToFile(optimfile); fprintf(optimfile, From 5822b85c02efa6b600b37a9df01e0b980ebcb02e Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 23 Jul 2019 15:02:58 +0200 Subject: [PATCH 31/38] Add list of contributors to README --- README.md | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 294148c..e7803d6 100644 --- a/README.md +++ b/README.md @@ -18,28 +18,9 @@ Run the test cases by callying './main' with the corresponding configuration fil An optimization history file 'optim.dat' will be flushed to the examples subfolder. -## Roland / Stef combo - LEARNING/TODO: - -### Overview: - -- Xbraid =\> 3 braid apps know one net -- One NN -- Braid has to be initialized first -\> Decides about layers per core -- Tangling with NN is given due to reason above - - create nn - - give nn to braid - - init nn - -## 2Dos 😊 - -- [x] Clean up syntax (google std) -- [ ] Associate code with [paper](https://arxiv.org/pdf/1812.04352.pdf) -- [ ] Refactoring (data(ste)) = Make code more readable by applying [SOLID](https://en.wikipedia.org/wiki/SOLID) principles - - [ ] Single Responsibility - - [ ] Open-Closed - - [ ] Liskov Substitution - - [ ] Interface Segregation - - [ ] Dependency Inversion -- [ ] Extract methods and clean up objects -- [ ] Park old code in separate branches and tag them as deprecated -- [ ] Would this code benefit from an update of XBraid? +## Contributors + +* Stefanie Guenther +* Eric C. Cyr +* J.B. Schroder +* Roland A. Siegbert From f76f63ffc33fb77bad87e294f30132f22317dffa Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 23 Jul 2019 15:05:30 +0200 Subject: [PATCH 32/38] Add license and paper header --- src/braid_wrapper.cpp | 23 ++++++++++++++++++++++- src/config.cpp | 21 +++++++++++++++++++++ src/dataset.cpp | 21 +++++++++++++++++++++ src/hessianApprox.cpp | 21 +++++++++++++++++++++ src/layer.cpp | 21 +++++++++++++++++++++ src/linalg.cpp | 21 +++++++++++++++++++++ src/main.cpp | 9 +++------ src/network.cpp | 21 +++++++++++++++++++++ 8 files changed, 151 insertions(+), 7 deletions(-) diff --git a/src/braid_wrapper.cpp b/src/braid_wrapper.cpp index 3843242..6bc8fb4 100644 --- a/src/braid_wrapper.cpp +++ b/src/braid_wrapper.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "braid_wrapper.hpp" /* ========================================================= */ @@ -768,4 +789,4 @@ braid_Int myAdjointBraidApp::EvaluateObjective() { } return 0; -} \ No newline at end of file +} diff --git a/src/config.cpp b/src/config.cpp index 8d7bd4d..76c6830 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "config.hpp" #include diff --git a/src/dataset.cpp b/src/dataset.cpp index e9afd77..08adcf7 100644 --- a/src/dataset.cpp +++ b/src/dataset.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "dataset.hpp" DataSet::DataSet() { diff --git a/src/hessianApprox.cpp b/src/hessianApprox.cpp index 5f2a83d..7c04961 100644 --- a/src/hessianApprox.cpp +++ b/src/hessianApprox.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "hessianApprox.hpp" HessianApprox::HessianApprox(MPI_Comm comm) { diff --git a/src/layer.cpp b/src/layer.cpp index 4d24770..74bf641 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "layer.hpp" #include #include diff --git a/src/linalg.cpp b/src/linalg.cpp index 0345661..32924cc 100644 --- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "linalg.hpp" MyReal vecdot_par(int dimN, MyReal *x, MyReal *y, MPI_Comm comm) { diff --git a/src/main.cpp b/src/main.cpp index aea2e72..5d296f3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ -// TODO: Copyright +// Copyright // -// TODO: Licensed under the Apache License, Version 2.0 (the "License"); +// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // @@ -12,16 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. // +// Underlying paper: // // Layer-Parallel Training of Deep Residual Neural Networks // S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger // // Download: https://arxiv.org/pdf/1812.04352.pdf // -// TODO: Authors of this paper are authors of this code. Further help for this -// code came from Roland Siegbert . -// - #include #include #include diff --git a/src/network.cpp b/src/network.cpp index 82f02d0..a177195 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -1,3 +1,24 @@ +// Copyright +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Underlying paper: +// +// Layer-Parallel Training of Deep Residual Neural Networks +// S. Guenther, L. Ruthotto, J.B. Schroder, E.C. Czr, and N.R. Gauger +// +// Download: https://arxiv.org/pdf/1812.04352.pdf +// #include "network.hpp" #include From 85f6622556b109681944b8f5858492a95d0e2e00 Mon Sep 17 00:00:00 2001 From: Roland Siegbert Date: Tue, 23 Jul 2019 15:12:25 +0200 Subject: [PATCH 33/38] Initialize hessian with NULL --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 0eee9ca..c370df5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { ndesign_global); /* Initialize Hessian approximation */ - HessianApprox *hessian; + HessianApprox *hessian = NULL; switch (config->hessianapprox_type) { case BFGS_SERIAL: hessian = new BFGS(MPI_COMM_WORLD, ndesign_local); From 9be5dd6bb78ee6ded78478a5efe1f11e43edbc01 Mon Sep 17 00:00:00 2001 From: steffi7574 Date: Tue, 23 Jul 2019 10:00:25 -0700 Subject: [PATCH 34/38] Update email address in Readme.me Contributors --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7803d6..e7765df 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ An optimization history file 'optim.dat' will be flushed to the examples subfold ## Contributors -* Stefanie Guenther +* Stefanie Guenther * Eric C. Cyr * J.B. Schroder * Roland A. Siegbert From 969d65c32b770004e3a942baa891fcda90ad152f Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Wed, 24 Jul 2019 22:23:39 -0700 Subject: [PATCH 35/38] Minor comment changes in main --- src/main.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ceafb6a..68965f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -77,15 +77,14 @@ int main(int argc, char *argv[]) { MyReal ls_objective, test_obj; int ls_iter; - /* --- other --- */ - // TODO: What is this? Why do you need it? - int myid; - int size; + /* --- Time measurements --- */ struct rusage r_usage; MyReal StartTime, StopTime, myMB, globalMB; MyReal UsedTime = 0.0; /* Initialize MPI */ + int myid; + int size; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Comm_size(MPI_COMM_WORLD, &size); @@ -162,8 +161,6 @@ int main(int argc, char *argv[]) { return 0; } - /* Allocate ascent direction for design updates */ - /* Initialize optimization parameters */ ascentdir = new MyReal[ndesign_local]; stepsize = config->getStepsize(0); From d7c0fbfb8e99391fd03305d66e99e57be414f33d Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 19 Aug 2019 22:03:48 -0700 Subject: [PATCH 36/38] Adding some comments for Network and Layer headers. Not very much though... Sorry. --- include/layer.hpp | 7 ++++--- include/network.hpp | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/layer.hpp b/include/layer.hpp index 036ead8..bc0ea6c 100644 --- a/include/layer.hpp +++ b/include/layer.hpp @@ -62,7 +62,8 @@ class Layer { /* Set time step size */ void setDt(MyReal DT); - /* Set design and gradient memory location */ + /* Set design and gradient memory location. + * The design vector is allocated within the Network block. For each layer in the block, the local memory location within the network's design vector is passed here to the layer, and stored as *weights and *bias (and their derivatives weights_bar and bias_bar). */ void setMemory(MyReal *design_memloc, MyReal *gradient_memloc); /* Some Get..() functions */ @@ -90,13 +91,13 @@ class Layer { int getnConv(); int getCSize(); - /* Get the layer index (i.e. the time step) */ + /* Get the layers ID (i.e. the time step number) */ int getIndex(); /* Prints to screen */ void print_data(MyReal *data_Out); - /* Activation function and derivative */ + /* Applies the activation function and derivative */ MyReal activation(MyReal x); MyReal dactivation(MyReal x); diff --git a/include/network.hpp b/include/network.hpp index 3b6996d..2337263 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -9,13 +9,20 @@ #include "util.hpp" #pragma once +/* + * The Network class logically connects the layers. + * Each processor instantiates one object of this class containing + * a sub-block of layers from [startlayerID, endlayerID], where those ID's are anything between -1 (being the opening layer) and nlayers_global-1 (being the classification layer). The distribution for the actual startlayerIDs and endlayerIDs at each processor come from Xbraid. + * All layers are stored in the vector **layer, except for the opening layer, which is in *openlayer. + * Each network block contains (and allocates!) the *design and *gradient vector, which are the vectorized weights and biases at each layer (see createNetworkBlock). + */ class Network { protected: int nlayers_global; /* Total number of Layers of the network */ int nlayers_local; /* Number of Layers in this network block */ int nchannels; /* Width of the network */ - MyReal dt; /* Time step size */ + MyReal dt; /* Time step size (distance between two layers).*/ MyReal loss; /* Value of the loss function */ MyReal accuracy; /* Accuracy of the network prediction (percentage of successfully predicted classes) */ @@ -44,6 +51,10 @@ class Network { ~Network(); + /* + * This calls the layer's constructor for all layers in [StartlayerID, EndLayerID]. + * + * */ void createNetworkBlock(int StartLayerID, int EndLayerID, Config *config, MPI_Comm Comm); @@ -105,6 +116,8 @@ class Network { */ void setInitialDesign(Config *config); + /* Helper function for createNetworkBlock. It basically checks what kind of layer is required at this index and calls the corresponding layer constructor. + */ Layer *createLayer(int index, Config *config); /* Replace the layer with one that is received from the left neighbouring @@ -113,6 +126,8 @@ class Network { /** * Applies the classification and evaluates loss/accuracy + * This routine should only be called at the last processor, which contains the classification layer. + * Maybe this one should not be inside the Network class? Don't know. */ void evalClassification(DataSet *data, MyReal **state, int output); @@ -125,6 +140,7 @@ class Network { /** * Update the network design parameters: new_design = old_design + stepsize * * direction + * I guess this might rather be a routine for the optimizer... */ void updateDesign(MyReal stepsize, MyReal *direction, MPI_Comm comm); }; From 16f3fc50b095179788c01d5cfe0c0fe2d0dfebf4 Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 19 Aug 2019 22:21:16 -0700 Subject: [PATCH 37/38] more comments --- include/braid_wrapper.hpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/braid_wrapper.hpp b/include/braid_wrapper.hpp index 91bedb5..cf461d8 100644 --- a/include/braid_wrapper.hpp +++ b/include/braid_wrapper.hpp @@ -10,15 +10,14 @@ #pragma once /** - * Define the state vector at one time-step + * Define the network state one layer. It contains the transformed data batch in the vector **state, and a pointer to the actual layer. */ class myBraidVector { protected: int nbatch; /* Number of examples */ int nchannels; /* Number of channels */ - MyReal * - *state; /* Network state at one layer, dimensions: nbatch * nchannels */ + MyReal **state; /* Network state at one layer, dimensions: nbatch * nchannels */ Layer *layer; /* Pointer to layer information */ /* Flag that determines if the layer and state have just been received and @@ -51,7 +50,7 @@ class myBraidVector { }; /** - * Wrapper for the primal braid app. + * Wrapper for the primal braid app. Most important routines are the Step function, which applies the layer transformation (and hence steps forward to the next layer) and the EvaluateObjective function, which (surprise!) evaluates the loss function and adds the regularization terms to get the objective funcioon value. * virtual function are overwritten from the adjoint app class */ class myBraidApp : public BraidApp { From 6978cdd28adfbe3db208ed3f66f6f79235683354 Mon Sep 17 00:00:00 2001 From: Stefanie Guenther Date: Mon, 19 Aug 2019 22:22:01 -0700 Subject: [PATCH 38/38] more comments --- include/braid_wrapper.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/braid_wrapper.hpp b/include/braid_wrapper.hpp index cf461d8..5af32a3 100644 --- a/include/braid_wrapper.hpp +++ b/include/braid_wrapper.hpp @@ -50,8 +50,9 @@ class myBraidVector { }; /** - * Wrapper for the primal braid app. Most important routines are the Step function, which applies the layer transformation (and hence steps forward to the next layer) and the EvaluateObjective function, which (surprise!) evaluates the loss function and adds the regularization terms to get the objective funcioon value. - * virtual function are overwritten from the adjoint app class + * Wrapper for the primal braid app. Most important routines are the Step function, which applies the layer transformations (and hence steps forward to the next layer), the SetInitialCondition, which applies the opening layer and the EvaluateObjective function, which (surprise!) evaluates the loss function and adds the regularization terms to get the objective function value. + * + * The adjoint braid app inherits from this class, and overwrites those with the corresponding derivatives. */ class myBraidApp : public BraidApp { protected: