More cosmetic changes
This commit is contained in:
parent
f80d9648c3
commit
4158586cb9
@ -8,9 +8,10 @@ ACTIVATIONS = dict()
|
|||||||
# def register_activation(scriptf):
|
# def register_activation(scriptf):
|
||||||
# ACTIVATIONS[scriptf.name] = scriptf
|
# ACTIVATIONS[scriptf.name] = scriptf
|
||||||
# return scriptf
|
# return scriptf
|
||||||
def register_activation(f):
|
def register_activation(function):
|
||||||
ACTIVATIONS[f.__name__] = f
|
"""Add the activation function to the registry."""
|
||||||
return f
|
ACTIVATIONS[function.__name__] = function
|
||||||
|
return function
|
||||||
|
|
||||||
|
|
||||||
@register_activation
|
@register_activation
|
||||||
@ -55,6 +56,7 @@ def swish_beta(x, beta=torch.tensor([10])):
|
|||||||
|
|
||||||
|
|
||||||
def get_activation(funcname):
|
def get_activation(funcname):
|
||||||
|
"""Deserialize the activation function."""
|
||||||
if callable(funcname):
|
if callable(funcname):
|
||||||
return funcname
|
return funcname
|
||||||
if funcname in ACTIVATIONS:
|
if funcname in ACTIVATIONS:
|
||||||
|
@ -4,8 +4,7 @@ import torch
|
|||||||
|
|
||||||
|
|
||||||
def squared_euclidean_distance(x, y):
|
def squared_euclidean_distance(x, y):
|
||||||
"""
|
"""Compute the squared Euclidean distance between :math:`x` and :math:`y`.
|
||||||
Compute the squared Euclidean distance between :math:`x` and :math:`y`.
|
|
||||||
|
|
||||||
Expected dimension of x is 2.
|
Expected dimension of x is 2.
|
||||||
Expected dimension of y is 2.
|
Expected dimension of y is 2.
|
||||||
@ -18,8 +17,7 @@ def squared_euclidean_distance(x, y):
|
|||||||
|
|
||||||
|
|
||||||
def euclidean_distance(x, y):
|
def euclidean_distance(x, y):
|
||||||
"""
|
"""Compute the Euclidean distance between :math:`x` and :math:`y`.
|
||||||
Compute the Euclidean distance between :math:`x` and :math:`y`.
|
|
||||||
|
|
||||||
Expected dimension of x is 2.
|
Expected dimension of x is 2.
|
||||||
Expected dimension of y is 2.
|
Expected dimension of y is 2.
|
||||||
@ -30,8 +28,7 @@ def euclidean_distance(x, y):
|
|||||||
|
|
||||||
|
|
||||||
def lpnorm_distance(x, y, p):
|
def lpnorm_distance(x, y, p):
|
||||||
r"""
|
r"""Compute :math:`{\langle x, y \rangle}_p`.
|
||||||
Compute :math:`{\langle x, y \rangle}_p`.
|
|
||||||
|
|
||||||
Expected dimension of x is 2.
|
Expected dimension of x is 2.
|
||||||
Expected dimension of y is 2.
|
Expected dimension of y is 2.
|
||||||
@ -41,8 +38,7 @@ def lpnorm_distance(x, y, p):
|
|||||||
|
|
||||||
|
|
||||||
def omega_distance(x, y, omega):
|
def omega_distance(x, y, omega):
|
||||||
r"""
|
r"""Omega distance.
|
||||||
Omega distance.
|
|
||||||
|
|
||||||
Compute :math:`{\langle \Omega x, \Omega y \rangle}_p`
|
Compute :math:`{\langle \Omega x, \Omega y \rangle}_p`
|
||||||
|
|
||||||
@ -57,8 +53,7 @@ def omega_distance(x, y, omega):
|
|||||||
|
|
||||||
|
|
||||||
def lomega_distance(x, y, omegas):
|
def lomega_distance(x, y, omegas):
|
||||||
r"""
|
r"""Localized Omega distance.
|
||||||
Localized Omega distance.
|
|
||||||
|
|
||||||
Compute :math:`{\langle \Omega_k x, \Omega_k y_k \rangle}_p`
|
Compute :math:`{\langle \Omega_k x, \Omega_k y_k \rangle}_p`
|
||||||
|
|
||||||
|
@ -7,9 +7,10 @@ import torch
|
|||||||
INITIALIZERS = dict()
|
INITIALIZERS = dict()
|
||||||
|
|
||||||
|
|
||||||
def register_initializer(func):
|
def register_initializer(function):
|
||||||
INITIALIZERS[func.__name__] = func
|
"""Add the initializer to the registry."""
|
||||||
return func
|
INITIALIZERS[function.__name__] = function
|
||||||
|
return function
|
||||||
|
|
||||||
|
|
||||||
def labels_from(distribution):
|
def labels_from(distribution):
|
||||||
@ -84,6 +85,7 @@ def stratified_random(x_train, y_train, prototype_distribution):
|
|||||||
|
|
||||||
|
|
||||||
def get_initializer(funcname):
|
def get_initializer(funcname):
|
||||||
|
"""Deserialize the initializer."""
|
||||||
if callable(funcname):
|
if callable(funcname):
|
||||||
return funcname
|
return funcname
|
||||||
if funcname in INITIALIZERS:
|
if funcname in INITIALIZERS:
|
||||||
|
Loading…
Reference in New Issue
Block a user