-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* testing readme * testing readme * testing readme * testing readme * adding surrogate construction files * updating * updating * updating dino art * updating dino art * updating dino art * some modifications * rank to proc in data loader * adding the compat_layer * updating evaluation printing * refactoring these methods somewhat * another missing case regarding test_dict is None * updating the training drivers
- Loading branch information
Showing
12 changed files
with
1,038 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
applications/hyperelasticity/dino_paper/dino_training.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# This file is part of the dino package | ||
# | ||
# dino is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or any later version. | ||
# | ||
# dino is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Author: Tom O'Leary-Roseberry | ||
# Contact: tom.olearyroseberry@utexas.edu | ||
import os, sys | ||
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' | ||
os.environ['KMP_DUPLICATE_LIB_OK']='True' | ||
os.environ["KMP_WARNINGS"] = "FALSE" | ||
import numpy as np | ||
import tensorflow as tf | ||
if int(tf.__version__[0]) > 1: | ||
import tensorflow.compat.v1 as tf | ||
tf.disable_v2_behavior() | ||
|
||
import time | ||
import pickle | ||
|
||
sys.path.append( os.environ.get('DINO_PATH')) | ||
from dino import * | ||
|
||
# Import hyperelasticity problem specifics | ||
sys.path.append('../') | ||
from hyperelasticityModelSettings import hyperelasticity_problem_settings | ||
|
||
try: | ||
tf.random.set_seed(0) | ||
except: | ||
tf.set_random_seed(0) | ||
|
||
from argparse import ArgumentParser | ||
|
||
# Arguments to be parsed from the command line execution | ||
parser = ArgumentParser(add_help=True) | ||
# Architectural parameters | ||
parser.add_argument("-architecture", dest='architecture',required=False, default = 'as_dense', help="architecture type: as_dense or generic_dense",type=str) | ||
parser.add_argument("-fixed_input_rank", dest='fixed_input_rank',required=False, default = 50, help="rank for input of AS network",type=int) | ||
parser.add_argument("-fixed_output_rank", dest='fixed_output_rank',required=False, default = 50, help="rank for output of AS network",type=int) | ||
parser.add_argument("-network_name", dest='network_name',required=True, help="out name for the saved weights",type=str) | ||
|
||
# Optimization parameters | ||
parser.add_argument("-total_epochs", dest='total_epochs',required=False, default = 1, help="total epochs for training",type=int) | ||
|
||
# Loss function parameters | ||
parser.add_argument("-target_rank", dest='target_rank',required=False, default = 50, help="target rank to be learned for Jacobian information",type=int) | ||
parser.add_argument("-batch_rank", dest='batch_rank',required=False, default = 50, help="batch rank parameter used in sketching of Jacobian information",type=int) | ||
parser.add_argument("-l2_weight", dest='l2_weight',required=False, default = 1., help="weight for l2 term",type=float) | ||
parser.add_argument("-h1_weight", dest='h1_weight',required=False, default = 1., help="weight for h1 term",type=float) | ||
|
||
# Full J training | ||
parser.add_argument("-train_full_jacobian", dest='train_full_jacobian',required=False, default = 1, help="full J",type=int) | ||
|
||
|
||
parser.add_argument("-train_data_size", dest='train_data_size',required=False, default = 1*1024, help="training data size",type=int) | ||
parser.add_argument("-test_data_size", dest='test_data_size',required=False, default = 1024, help="testing data size",type=int) | ||
|
||
args = parser.parse_args() | ||
|
||
# jacobian_network = None | ||
problem_settings = hyperelasticity_problem_settings() | ||
|
||
|
||
settings = jacobian_network_settings(problem_settings) | ||
|
||
n_obs = 50 | ||
correlation_length = 0.3 | ||
nx = 64 | ||
settings['data_dir'] = '../data/hyperelasticity_n_obs_'+str(n_obs)+'_correlation_length'+str(correlation_length)+'_nx'+str(nx)+'/' | ||
|
||
settings['target_rank'] = args.target_rank | ||
settings['batch_rank'] = args.batch_rank | ||
|
||
settings['train_data_size'] = args.train_data_size | ||
settings['test_data_size'] = args.test_data_size | ||
|
||
settings['architecture'] = args.architecture | ||
settings['depth'] = 6 | ||
|
||
settings['fixed_input_rank'] = args.fixed_input_rank | ||
settings['fixed_output_rank'] = args.fixed_output_rank | ||
settings['truncation_dimension'] = args.fixed_input_rank | ||
|
||
settings['train_full_jacobian'] = args.train_full_jacobian | ||
|
||
|
||
if (settings['batch_rank'] == settings['target_rank']): | ||
settings['outer_epochs'] = 1 | ||
settings['opt_parameters']['keras_epochs'] = args.total_epochs | ||
else: | ||
settings['shuffle_every_epoch'] = True | ||
settings['outer_epochs'] = args.total_epochs | ||
settings['opt_parameters']['keras_epochs'] = 1 | ||
settings['opt_parameters']['keras_verbose'] = True | ||
|
||
settings['opt_parameters']['loss_weights'] = [args.l2_weight,args.h1_weight] | ||
|
||
settings['network_name'] = args.network_name | ||
|
||
if args.l2_weight != 1.0: | ||
settings['network_name'] += 'l2_weight_'+str(args.l2_weight) | ||
|
||
|
||
jacobian_network = jacobian_training_driver(settings) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This file is part of the dino package | ||
# | ||
# dino is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or any later version. | ||
# | ||
# dino is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Author: Tom O'Leary-Roseberry | ||
# Contact: tom.olearyroseberry@utexas.edu | ||
|
||
import os | ||
import numpy as np | ||
|
||
corrs = [0.3] | ||
|
||
nxnys = [(64,64)] | ||
|
||
for correlation_length in corrs: | ||
for nx,ny in nxnys: | ||
print(80*'#') | ||
print(('Running for corr = '+str(correlation_length)+' nx,ny = '+str((nx,ny))).center(80)) | ||
os.system('mpirun -n 1 python hyperelasticityProblemSetup.py -ninstance 1 -correlation_length '+str(correlation_length)+' -nx '+str(nx)+' -ny '+str(ny)) | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
applications/hyperelasticity/hyperelasticityModelSettings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# This file is part of the dino package | ||
# | ||
# dino is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or any later version. | ||
# | ||
# dino is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# Author: Tom O'Leary-Roseberry | ||
# Contact: tom.olearyroseberry@utexas.edu | ||
|
||
import math | ||
|
||
def hyperelasticity_problem_settings(settings = {}): | ||
""" | ||
""" | ||
|
||
settings['ntargets'] = 100 | ||
settings['nx_targets'] = 10 | ||
settings['ny_targets'] = 10 | ||
settings['correlation_length'] = 0.3 | ||
settings['nx'] = 64 | ||
settings['ny'] = 64 | ||
settings['ndim'] = 2 | ||
settings['jacobian_full_rank'] = 50 | ||
settings['formulation'] = 'hyperelasticity' | ||
settings['rel_noise'] = 0.01 | ||
|
||
# For prior anisotropic tensor | ||
settings['prior_theta0'] = 2.0 | ||
settings['prior_theta1'] = 0.5 | ||
settings['prior_alpha'] = math.pi/4 | ||
|
||
# For sampling | ||
settings['seed'] = 1 | ||
|
||
|
||
return settings |
Oops, something went wrong.