# coding:utf-8
import time
import torch
import torch.nn as nn
import torch.nn.functional as F
class conv_bn_relu6(nn.Module):
def __init__(self, nin, nout, kernel_size, stride, padding, bias=False):
super(conv_bn_relu6, self).__init__()
self.conv = nn.Conv2d(nin, nout, kernel_size=kernel_size, stride=stride, padding=padding, bias=bias)
self.batch_norm = nn.BatchNorm2d(nout)
self.relu = nn.ReLU6(True)
# self.relu = mish.Mish()
def forward(self, x):
out = self.conv(x)
out = self.batch_norm(out)
out = self.relu(out)
return out
def conv_bn_relu(in_channels, out_channels, kernel_size, stride=1, padding=0):
m0 = nn.Conv2d(in_channels, out_channels, kernel_size=kernel_size, padding=padding, stride=stride)
m1 = nn.BatchNorm2d(out_channels)
return nn.Sequential(m0, m1, nn.ReLU6(True))