MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / train

Function train

code/cnn_1D_segm/train_fcn1D.py:83–343  ·  view source on GitHub ↗
(dataset, learning_rate=0.0005,
          weight_decay=0.001, num_epochs=500,
          max_patience=25, data_augmentation={},
          savepath=None, loadpath=None,
          batch_size=None, resume=False)

Source from the content-addressed store, hash-verified

81
82
83def train(dataset, learning_rate=0.0005,
84 weight_decay=0.001, num_epochs=500,
85 max_patience=25, data_augmentation={},
86 savepath=None, loadpath=None,
87 batch_size=None, resume=False):
88
89 if savepath is None:
90 raise ValueError('A saving directory must be specified')
91
92 if batch_size is None:
93 batch_size = [1024, 1024, 1]
94
95 # Model hyperparameters
96 n_filters = 64
97 filter_size = 25
98 depth = 8
99 block = 'bn_relu_conv'
100
101 # Hyperparameters for the dataset loader
102 smooth_or_raw = 'both' # use both input channels
103 shuffle_at_each_epoch = True
104
105 #
106 # Prepare load/save directories
107 #
108
109 exp_name = 'fcn1D'
110 exp_name += '_lrate=' + str(learning_rate)
111 exp_name += '_fil=' + str(n_filters)
112 exp_name += '_fsizes=' + str(filter_size)
113 exp_name += '_depth=' + str(depth)
114 exp_name += '_data=' + smooth_or_raw
115 exp_name += '_decay=' + str(weight_decay)
116 exp_name += '_pat=' + str(max_patience)
117
118 savepath = os.path.join(savepath, dataset, exp_name)
119 loadpath = os.path.join(loadpath, dataset, exp_name)
120 print('Savepath : ')
121 print(savepath)
122 print('Loadpath : ')
123 print(loadpath)
124
125 if not os.path.exists(savepath):
126 os.makedirs(savepath)
127 else:
128 print('\033[93m The following folder already exists {}. '
129 'It will be overwritten in a few seconds...\033[0m'.format(
130 savepath))
131
132 print('Saving directory : ' + savepath)
133 with open(os.path.join(savepath, "config.txt"), "w") as f:
134 for key, value in locals().items():
135 f.write('{} = {}\n'.format(key, value))
136
137 #
138 # Define symbolic variables
139 #
140 input_var = T.tensor3('input_var') # n_example*nb_in_channels*ray_size

Callers 1

mainFunction · 0.70

Calls 5

build_modelFunction · 0.90
jaccardFunction · 0.85
train_fnFunction · 0.85
accuracy_metricFunction · 0.70

Tested by

no test coverage detected