carm5333's picture
S206: vendor AP-BWE as SIDON replacement in ihya v4 cascade
225a147 verified
Raw
History Blame Contribute Delete
828 Bytes
"""Vendored from yxlu-0102/AP-BWE (MIT license), TRIMMED.
Original utils.py imports matplotlib at module level for plot_spectrogram(),
which our wrapper never calls. Dropping that import entirely rather than
adding matplotlib as a new production dependency just to satisfy an unused
import. Only init_weights/get_padding (actually needed by models/model.py)
are kept.
"""
def init_weights(m, mean=0.0, std=0.01):
classname = m.__class__.__name__
if classname.find("Conv") != -1:
m.weight.data.normal_(mean, std)
def get_padding(kernel_size, dilation=1):
return int((kernel_size * dilation - dilation) / 2)
def get_padding_2d(kernel_size, dilation=(1, 1)):
return (
int((kernel_size[0] * dilation[0] - dilation[0]) / 2),
int((kernel_size[1] * dilation[1] - dilation[1]) / 2),
)