Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- class LeakyRelu(cv2.dnn_Layer):
- def __init__(self, params, blobs):
- self._alpha = np.float32(params['alpha'])
- self._one = np.float32(1)
- def getMemoryShapes(self, inputs):
- return inputs
- def _forward_elem(self, x):
- m = (x < 0) * self._alpha + (x >= 0) * self._one
- return np.multiply(x, m)
- def forward(self, inputs):
- return [self._forward_elem(x) for x in inputs]
- cv2.dnn_registerLayer('LeakyRelu', LeakyRelu)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement