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

Function train

code/unet/train_unet.py:114–361  ·  view source on GitHub ↗
(dataset, learn_step=0.005,
          weight_decay=1e-4, num_epochs=500,
          max_patience=100, data_augmentation={},
          savepath=None, loadpath=None,
          early_stop_class=None,
          batch_size=None,
          resume=False,
          train_from_0_255=False)

Source from the content-addressed store, hash-verified

112
113
114def train(dataset, learn_step=0.005,
115 weight_decay=1e-4, num_epochs=500,
116 max_patience=100, data_augmentation={},
117 savepath=None, loadpath=None,
118 early_stop_class=None,
119 batch_size=None,
120 resume=False,
121 train_from_0_255=False):
122
123 #
124 # Prepare load/save directories
125 #
126 exp_name = 'unet_' + 'data_aug' if bool(data_augmentation) else ''
127
128 if savepath is None:
129 raise ValueError('A saving directory must be specified')
130
131 savepath = os.path.join(savepath, dataset, exp_name)
132 # loadpath = os.path.join(loadpath, dataset, exp_name)
133 print(savepath)
134 # print loadpath
135
136 if not os.path.exists(savepath):
137 os.makedirs(savepath)
138 else:
139 print('\033[93m The following folder already exists {}. '
140 'It will be overwritten in a few seconds...\033[0m'.format(
141 savepath))
142
143 print('Saving directory : ' + savepath)
144 with open(os.path.join(savepath, "config.txt"), "w") as f:
145 for key, value in locals().items():
146 f.write('{} = {}\n'.format(key, value))
147
148 #
149 # Define symbolic variables
150 #
151 input_var = T.tensor4('input_var')
152 target_var = T.ivector('target_var')
153
154 #
155 # Build dataset iterator
156 #
157 if batch_size is not None:
158 bs = batch_size
159 else:
160 bs = [10, 1, 1]
161
162
163 train_iter = IsbiEmStacksDataset(which_set='train',
164 batch_size=batch_size[0],
165 seq_per_subset=0,
166 seq_length=0,
167 data_augm_kwargs=data_augmentation,
168 return_one_hot=False,
169 return_01c=False,
170 overlap=0,
171 use_threads=True,

Callers 1

mainFunction · 0.70

Calls 6

build_UNetFunction · 0.90
train_fnFunction · 0.85
loadMethod · 0.80
crossentropy_metricFunction · 0.70
accuracy_metricFunction · 0.70
jaccard_metricFunction · 0.70

Tested by

no test coverage detected