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

Function train

code/fcn_2D_segm/train_fcn8.py:111–370  ·  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

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

Callers 1

mainFunction · 0.70

Calls 6

buildFCN8Function · 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