Skip to content

Commit 05536af

Browse files
committed
o Fix pre-commit
1 parent a8db1e3 commit 05536af

File tree

9 files changed

+105
-131
lines changed

9 files changed

+105
-131
lines changed

Pilot1/NT3/nt3_baseline_keras2_tensorrt.py

+65-66
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import candle
2626
import nt3 as bmk
2727

28-
""" Import Tensorflow Modules """
28+
# Import Tensorflow Modules
2929
import tensorflow as tf
3030
from tensorflow.core.protobuf import saver_pb2
3131
from tensorflow.python.framework import graph_io
@@ -44,71 +44,70 @@
4444
# P = 60483 # 60483
4545
# DR = 0.1 # Dropout rate
4646

47-
"""
48-
def common_parser(parser):
49-
50-
parser.add_argument("--config_file", dest='config_file', type=str,
51-
default=os.path.join(file_path, 'nt3_default_model.txt'),
52-
help="specify model configuration file")
53-
54-
# Parse has been split between arguments that are common with the default neon parser
55-
# and all the other options
56-
parser = p1_common.get_default_neon_parse(parser)
57-
parser = p1_common.get_p1_common_parser(parser)
58-
59-
return parser
60-
61-
def get_nt3_parser():
62-
63-
parser = argparse.ArgumentParser(prog='nt3_baseline', formatter_class=argparse.ArgumentDefaultsHelpFormatter,
64-
description='Train Autoencoder - Pilot 1 Benchmark NT3')
65-
66-
return common_parser(parser)
67-
68-
def read_config_file(file):
69-
config = configparser.ConfigParser()
70-
config.read(file)
71-
section = config.sections()
72-
fileParams = {}
73-
74-
fileParams['data_url'] = eval(config.get(section[0],'data_url'))
75-
fileParams['train_data'] = eval(config.get(section[0],'train_data'))
76-
fileParams['test_data'] = eval(config.get(section[0],'test_data'))
77-
fileParams['model_name'] = eval(config.get(section[0],'model_name'))
78-
fileParams['conv'] = eval(config.get(section[0],'conv'))
79-
fileParams['dense'] = eval(config.get(section[0],'dense'))
80-
fileParams['activation'] = eval(config.get(section[0],'activation'))
81-
fileParams['out_activation'] = eval(config.get(section[0],'out_activation'))
82-
fileParams['loss'] = eval(config.get(section[0],'loss'))
83-
fileParams['optimizer'] = eval(config.get(section[0],'optimizer'))
84-
fileParams['metrics'] = eval(config.get(section[0],'metrics'))
85-
fileParams['epochs'] = eval(config.get(section[0],'epochs'))
86-
fileParams['batch_size'] = eval(config.get(section[0],'batch_size'))
87-
fileParams['learning_rate'] = eval(config.get(section[0], 'learning_rate'))
88-
fileParams['dropout'] = eval(config.get(section[0],'dropout'))
89-
fileParams['classes'] = eval(config.get(section[0],'classes'))
90-
fileParams['pool'] = eval(config.get(section[0],'pool'))
91-
fileParams['save_path'] = eval(config.get(section[0], 'save_path'))
92-
93-
# parse the remaining values
94-
for k,v in config.items(section[0]):
95-
if not k in fileParams:
96-
fileParams[k] = eval(v)
97-
98-
return fileParams
99-
100-
def initialize_parameters():
101-
# Get command-line parameters
102-
parser = get_nt3_parser()
103-
args = parser.parse_args()
104-
#print('Args:', args)
105-
# Get parameters from configuration file
106-
fileParameters = read_config_file(args.config_file)
107-
#print ('Params:', fileParameters)
108-
# Consolidate parameter set. Command-line parameters overwrite file configuration
109-
gParameters = p1_common.args_overwrite_config(args, fileParameters)
110-
return gParameters
111-
"""
47+
48+
# def common_parser(parser):
49+
50+
# parser.add_argument("--config_file", dest='config_file', type=str,
51+
# default=os.path.join(file_path, 'nt3_default_model.txt'),
52+
# help="specify model configuration file")
53+
54+
# # Parse has been split between arguments that are common with the default neon parser
55+
# # and all the other options
56+
# parser = p1_common.get_default_neon_parse(parser)
57+
# parser = p1_common.get_p1_common_parser(parser)
58+
59+
# return parser
60+
61+
# def get_nt3_parser():
62+
63+
# parser = argparse.ArgumentParser(prog='nt3_baseline', formatter_class=argparse.ArgumentDefaultsHelpFormatter,
64+
# description='Train Autoencoder - Pilot 1 Benchmark NT3')
65+
66+
# return common_parser(parser)
67+
68+
# def read_config_file(file):
69+
# config = configparser.ConfigParser()
70+
# config.read(file)
71+
# section = config.sections()
72+
# fileParams = {}
73+
74+
# fileParams['data_url'] = eval(config.get(section[0],'data_url'))
75+
# fileParams['train_data'] = eval(config.get(section[0],'train_data'))
76+
# fileParams['test_data'] = eval(config.get(section[0],'test_data'))
77+
# fileParams['model_name'] = eval(config.get(section[0],'model_name'))
78+
# fileParams['conv'] = eval(config.get(section[0],'conv'))
79+
# fileParams['dense'] = eval(config.get(section[0],'dense'))
80+
# fileParams['activation'] = eval(config.get(section[0],'activation'))
81+
# fileParams['out_activation'] = eval(config.get(section[0],'out_activation'))
82+
# fileParams['loss'] = eval(config.get(section[0],'loss'))
83+
# fileParams['optimizer'] = eval(config.get(section[0],'optimizer'))
84+
# fileParams['metrics'] = eval(config.get(section[0],'metrics'))
85+
# fileParams['epochs'] = eval(config.get(section[0],'epochs'))
86+
# fileParams['batch_size'] = eval(config.get(section[0],'batch_size'))
87+
# fileParams['learning_rate'] = eval(config.get(section[0], 'learning_rate'))
88+
# fileParams['dropout'] = eval(config.get(section[0],'dropout'))
89+
# fileParams['classes'] = eval(config.get(section[0],'classes'))
90+
# fileParams['pool'] = eval(config.get(section[0],'pool'))
91+
# fileParams['save_path'] = eval(config.get(section[0], 'save_path'))
92+
93+
# # parse the remaining values
94+
# for k,v in config.items(section[0]):
95+
# if not k in fileParams:
96+
# fileParams[k] = eval(v)
97+
98+
# return fileParams
99+
100+
# def initialize_parameters():
101+
# # Get command-line parameters
102+
# parser = get_nt3_parser()
103+
# args = parser.parse_args()
104+
# #print('Args:', args)
105+
# # Get parameters from configuration file
106+
# fileParameters = read_config_file(args.config_file)
107+
# #print ('Params:', fileParameters)
108+
# # Consolidate parameter set. Command-line parameters overwrite file configuration
109+
# gParameters = p1_common.args_overwrite_config(args, fileParameters)
110+
# return gParameters
112111

113112

114113
def initialize_parameters(default_model="nt3_default_model.txt"):

Pilot1/Uno/unoUQ_data.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# import pandas as pd
66

77

8-
98
def find_columns_with_str(df, substr):
109
col_indices = [df.columns.get_loc(col) for col in df.columns if substr in col]
1110

Pilot3/P3B3/p3b3_baseline_keras2.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
from __future__ import print_function
22

3+
import candle
4+
import keras_mt_shared_cnn
35
import numpy as np
6+
import p3b3 as bmk
47
from tensorflow.keras import backend as K
58

6-
"""
7-
from tensorflow.keras.layers import Input, Dense, Dropout, Activation
8-
from tensorflow.keras.optimizers import SGD, Adam, RMSprop
9-
from tensorflow.keras.models import Model
10-
from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger, ReduceLROnPlateau
9+
# from tensorflow.keras.layers import Input, Dense, Dropout, Activation
10+
# from tensorflow.keras.optimizers import SGD, Adam, RMSprop
11+
# from tensorflow.keras.models import Model
12+
# from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger, ReduceLROnPlateau
1113

12-
from sklearn.metrics import f1_score
13-
"""
14+
# from sklearn.metrics import f1_score
1415

15-
# import keras
1616

17-
import candle
18-
import keras_mt_shared_cnn
19-
import p3b3 as bmk
17+
# import keras
2018

2119

2220
def initialize_parameters(default_model="p3b3_default_model.txt"):

Pilot3/P3B6/hvd.py

-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
# import p3b6 as bmk
1515

1616

17-
18-
19-
20-
2117
hvd.init()
2218

2319

common/candle/__init__.py

-14
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,6 @@
101101
# __version__ = '0.0.0'
102102

103103

104-
105-
106-
107-
108-
109-
110-
111-
112-
113-
114-
115-
116-
117-
118104
if "tensorflow.keras" in sys.modules:
119105
print("Importing candle utils for keras")
120106
# import from keras_utils

examples/ADRP/adrp.py

+26-28
Original file line numberDiff line numberDiff line change
@@ -274,39 +274,37 @@ def load_data(params, seed):
274274
return X_train, Y_train, X_test, Y_test, X_train.shape[1], histogram
275275

276276

277-
"""
278-
def load_data(params, seed):
277+
# def load_data(params, seed):
279278

280-
# start change #
281-
if params["train_data"].endswith("csv") or params["train_data"].endswith("csv"):
282-
print("processing csv in file {}".format(params["train_data"]))
279+
# # start change #
280+
# if params["train_data"].endswith("csv") or params["train_data"].endswith("csv"):
281+
# print("processing csv in file {}".format(params["train_data"]))
283282

284-
url = params["data_url"]
285-
file_train = params["train_data"]
286-
train_file = candle.get_file(
287-
file_train, url + file_train, cache_subdir="Pilot1"
288-
)
289-
df = (pd.read_csv(train_file, skiprows=1).values).astype("float32")
283+
# url = params["data_url"]
284+
# file_train = params["train_data"]
285+
# train_file = candle.get_file(
286+
# file_train, url + file_train, cache_subdir="Pilot1"
287+
# )
288+
# df = (pd.read_csv(train_file, skiprows=1).values).astype("float32")
290289

291-
PL = df.shape[1]
292-
print("PL=", PL)
290+
# PL = df.shape[1]
291+
# print("PL=", PL)
293292

294-
PS = PL - 1
293+
# PS = PL - 1
295294

296-
df_y = df[:, 0].astype("float32")
297-
df_x = df[:, 1:PL].astype(np.float32)
295+
# df_y = df[:, 0].astype("float32")
296+
# df_x = df[:, 1:PL].astype(np.float32)
298297

299-
df_y.shape
300-
df_x.shape
301-
scaler = StandardScaler()
302-
df_x = scaler.fit_transform(df_x)
298+
# df_y.shape
299+
# df_x.shape
300+
# scaler = StandardScaler()
301+
# df_x = scaler.fit_transform(df_x)
303302

304-
X_train, X_test, Y_train, Y_test = train_test_split(
305-
df_x, df_y, test_size=0.20, random_state=42
306-
)
307-
else:
308-
print("expecting in file file suffix csv")
309-
sys.exit()
303+
# X_train, X_test, Y_train, Y_test = train_test_split(
304+
# df_x, df_y, test_size=0.20, random_state=42
305+
# )
306+
# else:
307+
# print("expecting in file file suffix csv")
308+
# sys.exit()
310309

311-
return X_train, Y_train, X_test, Y_test, PS
312-
"""
310+
# return X_train, Y_train, X_test, Y_test, PS

examples/darts/advanced/operations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import torch.nn as nn
22
import torch.nn.functional as F
33

4-
""" DARTS operations contstructor """
4+
# DARTS operations contstructor
55
OPS = {
66
"none": lambda c, stride, affine: Identity(),
77
"conv_3": lambda c, stride, affine: ConvBlock(c, c, 3, stride),

examples/image-vae/extra_uts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def sample_from_discretized_mix_logistic(m, nr_mix):
259259
return out
260260

261261

262-
""" utilities for shifting the image around, efficient alternative to masking convolutions """
262+
# utilities for shifting the image around, efficient alternative to masking convolutions
263263

264264

265265
def down_shift(x, pad=None):

examples/image-vae/model.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,9 @@ def forward(self, x):
213213
return x
214214

215215

216-
"""
217-
skip connection parameter : 0 = no skip connection
218-
1 = skip connection where skip input size === input size
219-
2 = skip connection where skip input size === 2 * input size
220-
"""
216+
# skip connection parameter : 0 = no skip connection
217+
# 1 = skip connection where skip input size === input size
218+
# 2 = skip connection where skip input size === 2 * input size
221219

222220

223221
class gated_resnet(nn.Module):

0 commit comments

Comments
 (0)