-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmodels.py
25 lines (21 loc) · 855 Bytes
/
models.py
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
# -*- coding: utf-8 -*-
import numpy as np
#import tensorflow as tf
from keras.models import *
from keras.layers import Input,Conv2D,BatchNormalization,Activation,Lambda,Subtract
#from keras import backend as K
def DnCNN():
inpt = Input(shape=(None,None,1))
# 1st layer, Conv+relu
x = Conv2D(filters=64, kernel_size=(3,3), strides=(1,1), padding='same')(inpt)
x = Activation('relu')(x)
# 15 layers, Conv+BN+relu
for i in range(15):
x = Conv2D(filters=64, kernel_size=(3,3), strides=(1,1), padding='same')(x)
x = BatchNormalization(axis=-1, epsilon=1e-3)(x)
x = Activation('relu')(x)
# last layer, Conv
x = Conv2D(filters=1, kernel_size=(3,3), strides=(1,1), padding='same')(x)
x = Subtract()([inpt, x]) # input - noise
model = Model(inputs=inpt, outputs=x)
return model