MCPcopy Index your code
hub / github.com/MoonInTheRiver/DiffSinger / start

Method start

tasks/base_task.py:220–258  ·  view source on GitHub ↗
(cls)

Source from the content-addressed store, hash-verified

218
219 @classmethod
220 def start(cls):
221 set_hparams()
222 os.environ['MASTER_PORT'] = str(random.randint(15000, 30000))
223 random.seed(hparams['seed'])
224 np.random.seed(hparams['seed'])
225 task = cls()
226 work_dir = hparams['work_dir']
227 trainer = BaseTrainer(checkpoint_callback=LatestModelCheckpoint(
228 filepath=work_dir,
229 verbose=True,
230 monitor='val_loss',
231 mode='min',
232 num_ckpt_keep=hparams['num_ckpt_keep'],
233 save_best=hparams['save_best'],
234 period=1 if hparams['save_ckpt'] else 100000
235 ),
236 logger=TensorBoardLogger(
237 save_dir=work_dir,
238 name='lightning_logs',
239 version='lastest'
240 ),
241 gradient_clip_val=hparams['clip_grad_norm'],
242 val_check_interval=hparams['val_check_interval'],
243 row_log_interval=hparams['log_interval'],
244 max_updates=hparams['max_updates'],
245 num_sanity_val_steps=hparams['num_sanity_val_steps'] if not hparams[
246 'validate'] else 10000,
247 accumulate_grad_batches=hparams['accumulate_grad_batches'])
248 if not hparams['infer']: # train
249 t = datetime.now().strftime('%Y%m%d%H%M%S')
250 code_dir = f'{work_dir}/codes/{t}'
251 subprocess.check_call(f'mkdir -p "{code_dir}"', shell=True)
252 for c in hparams['save_codes']:
253 subprocess.check_call(f'cp -r "{c}" "{code_dir}/"', shell=True)
254 print(f"| Copied codes to {code_dir}.")
255 trainer.checkpoint_callback.task = task
256 trainer.fit(task)
257 else:
258 trainer.test(task)
259
260 def configure_ddp(self, model, device_ids):
261 model = DDP(

Callers 5

parallel_applyFunction · 0.80
chunked_multiprocess_runFunction · 0.80
run_taskFunction · 0.80
tts.pyFile · 0.80
fs2.pyFile · 0.80

Calls 5

fitMethod · 0.95
testMethod · 0.95
set_hparamsFunction · 0.90
BaseTrainerClass · 0.90

Tested by

no test coverage detected