-
Notifications
You must be signed in to change notification settings - Fork 1
/
training.html
744 lines (541 loc) · 31.8 KB
/
training.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<!DOCTYPE html>
<html >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1"><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>Training</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/theme.css " type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<link rel="stylesheet" href="_static/css/waveform-list.css" type="text/css" />
<!-- sphinx script_files -->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<!-- bundled in js (rollup iife) -->
<!-- <script src="_static/theme-vendors.js"></script> -->
<script src="_static/theme.js" defer></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Base Classes" href="base.html" />
<link rel="prev" title="Models" href="models.html" />
</head>
<body>
<div id="app">
<div class="theme-container" :class="pageClasses"><navbar @toggle-sidebar="toggleSidebar">
<router-link to="index.html" class="home-link">
<span class="site-name">omnizart</span>
</router-link>
<div class="links">
<navlinks class="can-hide">
<div class="nav-item">
<a href="index.html#sound-samples"
class="nav-link ">
Contents
</a>
</div>
<div class="nav-item">
<a href="index.html#sound-samples"
class="nav-link ">
Command Line Interface
</a>
</div>
<div class="nav-item">
<a href="index.html#sound-samples"
class="nav-link router-link-active">
API Reference
</a>
</div>
</navlinks>
</div>
</navbar>
<div class="sidebar-mask" @click="toggleSidebar(false)">
</div>
<sidebar @toggle-sidebar="toggleSidebar">
<navlinks>
<div class="nav-item">
<a href="index.html#sound-samples"
class="nav-link ">
Contents
</a>
</div>
<div class="nav-item">
<a href="index.html#sound-samples"
class="nav-link ">
Command Line Interface
</a>
</div>
<div class="nav-item">
<a href="index.html#sound-samples"
class="nav-link router-link-active">
API Reference
</a>
</div>
</navlinks><div id="searchbox" class="searchbox" role="search">
<div class="caption"><span class="caption-text">Quick search</span>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Search" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div><div class="sidebar-links" role="navigation" aria-label="main navigation">
<div class="sidebar-group">
<p class="caption">
<span class="caption-text"><a href="index.html#sound-samples">Contents</a></span>
</p>
<ul class="">
<li class="toctree-l1 ">
<a href="quick-start.html" class="reference internal ">Quick Start</a>
</li>
<li class="toctree-l1 ">
<a href="tutorial.html" class="reference internal ">Tutorial</a>
</li>
<li class="toctree-l1 ">
<a href="demo.html" class="reference internal ">Demonstration</a>
</li>
</ul>
</div>
<div class="sidebar-group">
<p class="caption">
<span class="caption-text"><a href="index.html#sound-samples">Command Line Interface</a></span>
</p>
<ul class="">
<li class="toctree-l1 ">
<a href="music/cli.html" class="reference internal ">omnizart music</a>
</li>
<li class="toctree-l1 ">
<a href="drum/cli.html" class="reference internal ">omnizart drum</a>
</li>
<li class="toctree-l1 ">
<a href="chord/cli.html" class="reference internal ">omnizart chord</a>
</li>
<li class="toctree-l1 ">
<a href="vocal/cli.html" class="reference internal ">omnizart vocal</a>
</li>
<li class="toctree-l1 ">
<a href="vocal-contour/cli.html" class="reference internal ">omnizart vocal-contour</a>
</li>
<li class="toctree-l1 ">
<a href="beat/cli.html" class="reference internal ">omnizart beat</a>
</li>
<li class="toctree-l1 ">
<a href="patch-cnn/cli.html" class="reference internal ">omnizart patch-cnn</a>
</li>
</ul>
</div>
<div class="sidebar-group">
<p class="caption">
<span class="caption-text"><a href="index.html#sound-samples">API Reference</a></span>
</p>
<ul class="current">
<li class="toctree-l1 ">
<a href="music/api.html" class="reference internal ">Music Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="drum/api.html" class="reference internal ">Drum Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="chord/api.html" class="reference internal ">Chord Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="vocal/api.html" class="reference internal ">Vocal Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="vocal-contour/api.html" class="reference internal ">Vocal-Contour Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="patch-cnn/api.html" class="reference internal ">Patch-CNN Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="beat/api.html" class="reference internal ">Beat Transcription</a>
</li>
<li class="toctree-l1 ">
<a href="feature.html" class="reference internal ">Feature</a>
</li>
<li class="toctree-l1 ">
<a href="models.html" class="reference internal ">Models</a>
</li>
<li class="toctree-l1 current">
<a href="#" class="reference internal current">Training</a>
<ul>
<li class="toctree-l2"><a href="#id1" class="reference internal">Training</a></li>
<li class="toctree-l2"><a href="#module-omnizart.callbacks" class="reference internal">Callbacks</a></li>
</ul>
</li>
<li class="toctree-l1 ">
<a href="base.html" class="reference internal ">Base Classes</a>
</li>
<li class="toctree-l1 ">
<a href="constants.html" class="reference internal ">Constants</a>
</li>
<li class="toctree-l1 ">
<a href="utils.html" class="reference internal ">Utilities</a>
</li>
</ul>
</div>
</div>
</sidebar>
<page>
<div class="body-header" role="navigation" aria-label="navigation">
<ul class="breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>Training</li>
</ul>
<ul class="page-nav">
<li class="prev">
<a href="models.html"
title="previous chapter">← Models</a>
</li>
<li class="next">
<a href="base.html"
title="next chapter">Base Classes →</a>
</li>
</ul>
</div>
<hr>
<div class="content" role="main" v-pre>
<section id="training">
<h1>Training<a class="headerlink" href="#training" title="Permalink to this headline">¶</a></h1>
<p>Including logics of main training loop, progress visualization, and callback
functions.</p>
<section id="id1">
<h2>Training<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<dl class="py data">
<dt class="sig sig-object py" id="omnizart.train.PROGRESS_BAR_FORMAT">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">PROGRESS_BAR_FORMAT</span></span><em class="property"><span class="w"> </span><span class="pre">=</span> <span class="pre">Format</span> <span class="pre">of</span> <span class="pre">the</span> <span class="pre">training</span> <span class="pre">progress</span> <span class="pre">bar</span></em><a class="headerlink" href="#omnizart.train.PROGRESS_BAR_FORMAT" title="Permalink to this definition">¶</a></dt>
<dd><p>str(object=’’) -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str</p>
<p>Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to ‘strict’.</p>
</dd></dl>
<span class="target" id="module-omnizart.train"></span><dl class="py function">
<dt class="sig sig-object py" id="omnizart.train.execute_callbacks">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">execute_callbacks</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callbacks</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">func_name</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.train.execute_callbacks" title="Permalink to this definition">¶</a></dt>
<dd><p>Execute callbacks at different training stage.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="omnizart.train.format_num">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">format_num</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">num</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">digit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">4</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.train.format_num" title="Permalink to this definition">¶</a></dt>
<dd><p>Formatting the float values as string.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="omnizart.train.gen_bar_postfix">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">gen_bar_postfix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">history</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">targets</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">['loss',</span> <span class="pre">'accuracy']</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name_transform</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">['loss',</span> <span class="pre">'acc']</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.train.gen_bar_postfix" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate string of metrics status to be appended to the end of the progress bar.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>history: dict</strong></dt><dd><p>History records generated by <code class="docutils literal notranslate"><span class="pre">train_steps</span></code>.</p>
</dd>
<dt><strong>targets: list[str]</strong></dt><dd><p>List of metric’s names to be extracted as the postfix.</p>
</dd>
<dt><strong>name_transform: list[str]</strong></dt><dd><p>The alias metric name that will be showed on the bar.
Should be the same length, same order as <code class="docutils literal notranslate"><span class="pre">targets</span></code>.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>postfix: str</dt><dd><p>The extracted metrics information.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="omnizart.train.get_train_val_feat_file_list">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">get_train_val_feat_file_list</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">feature_folder</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">split</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.9</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.train.get_train_val_feat_file_list" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="omnizart.train.train_epochs">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">train_epochs</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">train_dataset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">validate_dataset</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">epochs</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">10</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">val_steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">100</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callbacks</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.train.train_epochs" title="Permalink to this definition">¶</a></dt>
<dd><p>Logic of training loop.</p>
<p>The main loop of the training, with events-based life-cycle management
that triggers different events for all callbacks. Event types are the
same as the original tensorflow implementation.</p>
<p>Event types and their order:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span><start training>
|
|-on_train_begin
T| |-on_epoch_begin
R| |
A| L|-on_train_batch_begin
I| O|-on_train_batch_end
N| O|
I| P|-on_test_batch_begin
N| |-on_test_batch_end
G| |
| |-on_epoch_end
|-on_train_end
|
<finished training>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>model:</strong></dt><dd><p>Compiled tensorflow keras model.</p>
</dd>
<dt><strong>train_dataset:</strong></dt><dd><p>The tf.data.Dataset instance for training.</p>
</dd>
<dt><strong>validate_dataset:</strong></dt><dd><p>The tf.data.Dataset instance for validation. If not given, validation
stage will be skipped.</p>
</dd>
<dt><strong>epochs: int</strong></dt><dd><p>Number of maximum training epochs.</p>
</dd>
<dt><strong>steps: int</strong></dt><dd><p>Number of training steps for each epoch. Should be the same as
when initiating the dataset instance.</p>
</dd>
<dt><strong>val_steps: int</strong></dt><dd><p>Number of validation steps for each epoch.Should be the same as
when initiating the dataset instance.</p>
</dd>
<dt><strong>callbacks:</strong></dt><dd><p>List of callback instances.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>history: dict</dt><dd><p>Score history of each metrics during each epoch of both training
and validation.</p>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="#module-omnizart.callbacks" title="omnizart.callbacks"><code class="xref py py-obj docutils literal notranslate"><span class="pre">omnizart.callbacks</span></code></a></dt><dd><p>Implementation and available callbacks for training.</p>
</dd>
</dl>
</div>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="omnizart.train.train_steps">
<span class="sig-prename descclassname"><span class="pre">omnizart.train.</span></span><span class="sig-name descname"><span class="pre">train_steps</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">model</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dataset</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">steps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bar_title</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">validate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.train.train_steps" title="Permalink to this definition">¶</a></dt>
<dd><p>A single training epoch with multiple steps.</p>
<p>Customized training epoch compared to the built-in <code class="docutils literal notranslate"><span class="pre">.fit(...)</span></code> function
of tensorflow keras model. The major difference is that the <code class="docutils literal notranslate"><span class="pre">.fit()</span></code>
requires the dataset to yield either (feature, target) or
(feature, target, weight) pairs, which losses the flexibility of yielding
different numbers of elements for each iteration. And thus we’d decide to
implement our own training logic and relevant utilities same as provided
in tensorflow like <cite>callbacks</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>model:</strong></dt><dd><p>Compiled tf.keras model.</p>
</dd>
<dt><strong>dataset:</strong></dt><dd><p>The loaded tf.data.Dataset object that yields (feature, target) pairs
at the first two elements, indicating that you can yields more than
two elements for each iteration, but only the first two will be used
for training.</p>
</dd>
<dt><strong>steps: int</strong></dt><dd><p>Total number of steps that the dataset object will yield. This is used
for visualizing the training progress.</p>
</dd>
<dt><strong>bar_title: str</strong></dt><dd><p>Additional title to be printed at the start of the progress bar.</p>
</dd>
<dt><strong>validate: bool</strong></dt><dd><p>Indicating whether it is now in validation stage or it is within
training loop that should update the weights of the model.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>history: dict</dt><dd><p>The history of scores for each metric during each epoch.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</section>
<section id="module-omnizart.callbacks">
<span id="callbacks"></span><h2>Callbacks<a class="headerlink" href="#module-omnizart.callbacks" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="omnizart.callbacks.Callback">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">omnizart.callbacks.</span></span><span class="sig-name descname"><span class="pre">Callback</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">monitor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.callbacks.Callback" title="Permalink to this definition">¶</a></dt>
<dd><p>Base class of all callback classes</p>
<p class="rubric">Methods</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 71%" />
<col style="width: 29%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>on_epoch_begin</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>on_epoch_end</strong></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><strong>on_test_batch_begin</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>on_test_batch_end</strong></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><strong>on_train_batch_begin</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>on_train_batch_end</strong></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><strong>on_train_begin</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>on_train_end</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="omnizart.callbacks.EarlyStopping">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">omnizart.callbacks.</span></span><span class="sig-name descname"><span class="pre">EarlyStopping</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">patience</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">monitor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'val_acc'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.callbacks.EarlyStopping" title="Permalink to this definition">¶</a></dt>
<dd><p>Early stop the training after no improvement on the monitor for a certain period.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>patience: int</strong></dt><dd><p>Longeset period of epochs for waiting the target metrics showing improvement.</p>
</dd>
<dt><strong>monitor: str</strong></dt><dd><p>Metric name for the observation.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 64%" />
<col style="width: 36%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>on_epoch_end</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>on_train_begin</strong></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><strong>on_train_end</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="omnizart.callbacks.ModelCheckpoint">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">omnizart.callbacks.</span></span><span class="sig-name descname"><span class="pre">ModelCheckpoint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filepath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">monitor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'val_acc'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_best_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_weights_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.callbacks.ModelCheckpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Saving the model during training.</p>
<p>The newest checkpoint will override the original checkpoint during a single
training period.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>filepath: Path</strong></dt><dd><p>Path for saving the checkpoint.</p>
</dd>
<dt><strong>monitor: str</strong></dt><dd><p>Metric name for the observation. No effect if <cite>save_bset_only</cite> is set to false.</p>
</dd>
<dt><strong>save_best_only: bool</strong></dt><dd><p>Whether to save the model having the best performance on the metric only.</p>
</dd>
<dt><strong>save_weights_only: bool</strong></dt><dd><p>Save the model’s weight only, without architecture.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 64%" />
<col style="width: 36%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>on_epoch_end</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>on_train_begin</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="omnizart.callbacks.TFModelCheckpoint">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">omnizart.callbacks.</span></span><span class="sig-name descname"><span class="pre">TFModelCheckpoint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filepath</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">monitor</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'val_loss'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbose</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_best_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_weights_only</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'auto'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">save_freq</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'epoch'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.callbacks.TFModelCheckpoint" title="Permalink to this definition">¶</a></dt>
<dd><p>Re-implementation of Tensorflow ModelCheckpoint.</p>
<p>Customize the behaviour of saving the checkpoints.
When specify save_weights_only to ‘True’, save the weights only during training, and save
the whole model including architecture using model.save() at the end of training.</p>
<p>This callback is mainly designed for saving customized models that is unable to
use model.to_yaml() function.</p>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#omnizart.callbacks.TFModelCheckpoint.on_train_end" title="omnizart.callbacks.TFModelCheckpoint.on_train_end"><code class="xref py py-obj docutils literal notranslate"><span class="pre">on_train_end</span></code></a>(logs)</p></td>
<td><p>Called at the end of training.</p></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 57%" />
<col style="width: 43%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>set_model</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt class="sig sig-object py" id="omnizart.callbacks.TFModelCheckpoint.on_train_end">
<span class="sig-name descname"><span class="pre">on_train_end</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#omnizart.callbacks.TFModelCheckpoint.on_train_end" title="Permalink to this definition">¶</a></dt>
<dd><p>Called at the end of training.</p>
<p>Subclasses should override for any actions to run.</p>
<dl class="simple">
<dt>Args:</dt><dd><dl class="simple">
<dt>logs: Dict. Currently the output of the last call to <cite>on_epoch_end()</cite></dt><dd><p>is passed to this argument for this method but that may change in
the future.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</dd></dl>
</section>
</section>
</div>
<div class="page-nav">
<div class="inner"><ul class="page-nav">
<li class="prev">
<a href="models.html"
title="previous chapter">← Models</a>
</li>
<li class="next">
<a href="base.html"
title="next chapter">Base Classes →</a>
</li>
</ul><div class="footer" role="contentinfo">
© Copyright 2020, MCTLab.
<br>
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 4.3.1 with <a href="https://github.com/schettino72/sphinx_press_theme">Press Theme</a> 0.8.0.
</div>
</div>
</div>
</page>
</div></div>
</body>
</html>