Newer
Older
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
def masktraining_skip_2chan_1enc():
# initializing
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import ctypes
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '1'
os.environ['TF_ENABLE_XLA'] = '1'
os.environ['TF_ENABLE_AUTO_MIXED_PRECISION'] = '1'
os.environ['TF_ENABLE_CUDNN_RNN_TENSOR_OP_MATH_FP32'] = '1'
os.environ['TF_DISABLE_CUDNN_TENSOR_OP_MATH'] = '1'
os.environ['TF_ENABLE_CUBLAS_TENSOR_OP_MATH_FP32'] = '1'
import numpy as np
import tensorflow as tf
from tensorflow import keras
from keras.layers import Add, Multiply, Input, Dense, Flatten, Dropout, Conv2D, MaxPooling2D, Conv2DTranspose, LeakyReLU, Reshape, Activation, BatchNormalization, UpSampling2D
from keras.models import Model
from keras.constraints import max_norm
from keras.optimizers import Adam, SGD
from keras.utils import to_categorical, normalize
from keras.callbacks import ModelCheckpoint
from keras import losses
from keras import backend as K
import matplotlib.pyplot as plt
import random
# checking for gpus and using it/them
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
try:
tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=4096)])
except RuntimeError as e:
print(e)
# custom generator import
from Generators.MaskGenerator3_realimag_1enc import DataGenerator
len_train = glob(path_train + '/**/*.npz', recursive=True)
len_train = len(len_train)
len_valid = glob(path_valid + '/**/*.npz', recursive=True)
len_valid = len(len_valid)
# generators for train and validation data
train_generator = DataGenerator(path_train, option, reduction_divisor, len_train, framelength, batch_size, True)
valid_generator = DataGenerator(path_valid, option, reduction_divisor, len_valid, framelength, batch_size, True)