File size: 771 Bytes
0f09377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import numpy as np
import tensorflow as tf


class Parameters:
    # data level
    image_count = 3670
    image_size = 384
    batch_size = 12
    num_grad_accumulation = 8
    label_smooth = 0.05
    class_number = 5
    val_split = 0.2
    autotune = tf.data.AUTOTUNE

    # hparams
    epochs = 10
    lr_sched = "cosine_restart"
    lr_base = 0.016
    lr_min = 0
    lr_decay_epoch = 2.4
    lr_warmup_epoch = 5
    lr_decay_factor = 0.97

    scaled_lr = lr_base * (batch_size / 256.0)
    scaled_lr_min = lr_min * (batch_size / 256.0)
    num_validation_sample = int(image_count * val_split)
    num_training_sample = image_count - num_validation_sample
    train_step = int(np.ceil(num_training_sample / float(batch_size)))
    total_steps = train_step * epochs