Ejemplo n.º 1
0
### mixed precision
if MIXED_PRECISION:
    policy = mixed_precision.Policy(MIXED_PRECISION_DTYPE)
    mixed_precision.set_policy(policy)

    print('mixed precision 적용됨')
    print('Compute dtype: %s' % policy.compute_dtype)
    print('Variable dtype: %s' % policy.variable_dtype)
''' ============================================================================= data load '''
'''-------------- train '''
meta = pd.read_csv('meta.csv', index_col=0)
cond = meta['data_type'].isin(['tile']) & \
       meta['ttg_type'].isin(['train'])
meta_tr = meta.loc[cond]

sq_tr = train_sequence(meta_tr, IMAGE_SIZE, PAD_SIZE, BATCH_SIZE)
sq_tr.on_epoch_end()
tr_queuer = keras.utils.OrderedEnqueuer(sequence=sq_tr,
                                        use_multiprocessing=False,
                                        shuffle=True)
tr_queuer.start(workers=4, max_queue_size=16)
tr_loader = tr_queuer.get()
'''-------------- valid '''
cond = meta['data_type'].isin(['tile']) & \
       meta['ttg_type'].isin(['test']) & \
       ~meta['error_type'].isin(['good'])
meta_vl = meta.loc[cond]

sq_vl = train_sequence(meta_vl, IMAGE_SIZE, PAD_SIZE, BATCH_SIZE)
''' ============================================================================= model '''
Ejemplo n.º 2
0
if MIXED_PRECISION:
    policy = mixed_precision.Policy(MIXED_PRECISION_DTYPE)
    mixed_precision.set_policy(policy)

    print('mixed precision 적용됨')
    print('Compute dtype: %s' % policy.compute_dtype)
    print('Variable dtype: %s' % policy.variable_dtype)
''' ============================================================================= data load '''

meta = pd.read_csv('/work/data/meta.csv', index_col=None)
cond = meta['orig_tr_te'].isin(['train'])  # & \
#         ((meta['class_number']=='414') | (meta['class_number']=='48'))

meta_tr = meta.loc[cond]

sq_tr = train_sequence(meta_tr, IMAGE_SIZE, '/work/data/', PAD_SIZE,
                       BATCH_SIZE)
sq_tr.on_epoch_end()
tr_queuer = keras.utils.OrderedEnqueuer(sequence=sq_tr,
                                        use_multiprocessing=False,
                                        shuffle=True)
tr_queuer.start(workers=4, max_queue_size=16)
tr_loader = tr_queuer.get()
''' ============================================================================= model '''
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import backend as K
from tensorflow.keras import layers
import tensorflow_addons as tfa
from tensorflow.keras.layers import (
    Dense,
    Dropout,