code stringlengths 17 6.64M |
|---|
class InnerProductParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _INNERPRODUCTPARAMETER
|
class LRNParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LRNPARAMETER
|
class MemoryDataParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _MEMORYDATAPARAMETER
|
class MVNParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _MVNPARAMETER
|
class PoolingParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _POOLINGPARAMETER
|
class PowerParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _POWERPARAMETER
|
class PythonParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _PYTHONPARAMETER
|
class ReLUParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _RELUPARAMETER
|
class ROIPoolingParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _ROIPOOLINGPARAMETER
|
class SigmoidParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SIGMOIDPARAMETER
|
class SliceParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SLICEPARAMETER
|
class SoftmaxParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOFTMAXPARAMETER
|
class TanHParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _TANHPARAMETER
|
class ThresholdParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _THRESHOLDPARAMETER
|
class WindowDataParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _WINDOWDATAPARAMETER
|
class V1LayerParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _V1LAYERPARAMETER
|
class V0LayerParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _V0LAYERPARAMETER
|
class PReLUParameter(_message.Message):
__metaclass__ = _reflection.GeneratedProtocolMessageType
DESCRIPTOR = _PRELUPARAMETER
|
class BlobProto(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _BLOBPROTO
|
class BlobProtoVector(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _BLOBPROTOVECTOR
|
class Datum(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DATUM
|
class FillerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _FILLERPARAMETER
|
class LayerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LAYERPARAMETER
|
class LayerConnection(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LAYERCONNECTION
|
class NetParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _NETPARAMETER
|
class SolverParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOLVERPARAMETER
|
class SolverState(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOLVERSTATE
|
class BlobProto(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _BLOBPROTO
|
class BlobProtoVector(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _BLOBPROTOVECTOR
|
class Datum(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DATUM
|
class FillerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _FILLERPARAMETER
|
class NetParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _NETPARAMETER
|
class SolverParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOLVERPARAMETER
|
class SolverState(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOLVERSTATE
|
class LayerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LAYERPARAMETER
|
class ConcatParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _CONCATPARAMETER
|
class ConvolutionParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _CONVOLUTIONPARAMETER
|
class DataParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DATAPARAMETER
|
class DropoutParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DROPOUTPARAMETER
|
class HDF5DataParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _HDF5DATAPARAMETER
|
class HDF5OutputParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _HDF5OUTPUTPARAMETER
|
class ImageDataParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _IMAGEDATAPARAMETER
|
class InfogainLossParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _INFOGAINLOSSPARAMETER
|
class InnerProductParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _INNERPRODUCTPARAMETER
|
class LRNParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LRNPARAMETER
|
class MemoryDataParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _MEMORYDATAPARAMETER
|
class PoolingParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _POOLINGPARAMETER
|
class PowerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _POWERPARAMETER
|
class WindowDataParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _WINDOWDATAPARAMETER
|
class V0LayerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _V0LAYERPARAMETER
|
class BlobProto(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _BLOBPROTO
|
class BlobProtoVector(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _BLOBPROTOVECTOR
|
class Datum(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DATUM
|
class FillerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _FILLERPARAMETER
|
class LayerParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LAYERPARAMETER
|
class LayerConnection(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _LAYERCONNECTION
|
class NetParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _NETPARAMETER
|
class SolverParameter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOLVERPARAMETER
|
class EvalHistoryIter(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _EVALHISTORYITER
|
class EvalHistory(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _EVALHISTORY
|
class SolverState(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _SOLVERSTATE
|
def remove_urls(text):
return URLS_RE.sub('', text)
|
def replace_multi_whitespaces(line):
return ' '.join(line.split())
|
def remove_listing(line):
return LISTING_RE.sub('', line)
|
def main():
with open(sys.argv[1], 'r') as input_file:
for line in input_file:
if (line is '\n'):
print('')
else:
line = line.lower()
line = remove_urls(line)
line = remove_listing(line)
line = replace_... |
def _is_punctuation(char):
'Checks whether `chars` is a punctuation character.'
cp = ord(char)
if (((cp >= 33) and (cp <= 47)) or ((cp >= 58) and (cp <= 64)) or ((cp >= 91) and (cp <= 96)) or ((cp >= 123) and (cp <= 126))):
return True
cat = unicodedata.category(char)
if cat.startswith('P'... |
def _run_split_on_punc(text):
'Splits punctuation on a piece of text.'
chars = list(text)
i = 0
start_new_word = True
output = []
while (i < len(chars)):
char = chars[i]
if _is_punctuation(char):
output.append([char])
start_new_word = True
else:
... |
def replace_multi_whitespaces(line):
return ' '.join(line.split())
|
def main():
with open(sys.argv[1], 'r') as input_file:
for line in input_file:
if (line is '\n'):
print('')
else:
line = _run_split_on_punc(line)
line = replace_multi_whitespaces(line)
if (line is not ''):
... |
class OneCycleLR(Callback):
def __init__(self, max_lr, end_percentage=0.1, scale_percentage=None, maximum_momentum=0.95, minimum_momentum=0.85, verbose=True):
' This callback implements a cyclical learning rate policy (CLR).\n This is a special case of Cyclic Learning Rates, where we have only 1 c... |
class LRFinder(Callback):
def __init__(self, num_samples, batch_size, minimum_lr=1e-05, maximum_lr=10.0, lr_scale='exp', validation_data=None, validation_sample_rate=5, stopping_criterion_factor=4.0, loss_smoothing_beta=0.98, save_dir=None, verbose=True):
"\n This class uses the Cyclic Learning Ra... |
class CosineAnnealingScheduler(Callback):
'Cosine annealing scheduler.\n '
def __init__(self, T_max, eta_max, eta_min=0, verbose=0, epoch_start=80, restart_epochs=None, gamma=1, expansion=1, flat_end=False):
super(CosineAnnealingScheduler, self).__init__()
self.epoch_start = epoch_start
... |
class CyclicLR(Callback):
'This callback implements a cyclical learning rate policy (CLR).\n The method cycles the learning rate between two boundaries with\n some constant frequency, as detailed in this paper (https://arxiv.org/abs/1506.01186).\n The amplitude of the cycle can be scaled on a per-iterati... |
class LRFinder(Callback):
def __init__(self, num_samples, batch_size, minimum_lr=1e-05, maximum_lr=10.0, lr_scale='exp', validation_data=None, validation_sample_rate=5, stopping_criterion_factor=4.0, loss_smoothing_beta=0.98, save_dir=None, verbose=True):
"\n This class uses the Cyclic Learning Ra... |
class History(object):
'\n Custom class to help get log data from keras.callbacks.History objects.\n :param history: a ``keras.callbacks.History object`` or ``None``.\n '
def __init__(self, history=None):
if (history is not None):
self.epoch = history.epoch
self.histo... |
def concatenate_history(hlist, reindex_epoch=False):
'\n A helper function to concatenate training history object (``keras.callbacks.History``) into a single one, with a help ``History`` class.\n :param hlist: a list of ``keras.callbacks.History`` objects to concatenate.\n :param reindex_epoch: True or F... |
def plot_from_history(history):
"\n Plot losses in training history.\n :param history: a ``keras.callbacks.History`` or (this module's) ``History`` object.\n "
assert isinstance(history, (keras.callbacks.History, History)), "history must be a ``keras.callbacks.History`` or (this module's) ``History``... |
def save_history_to_csv(history, filepath):
'\n Save a training history into a csv file.\n :param history: a ``History`` callback instance from ``Model`` instance.\n :param filepath: a string filepath.\n '
hist = history.history
hist['epoch'] = history.epoch
df = pd.DataFrame.from_dict(his... |
def reset_keras(per_process_gpu_memory_fraction=1.0):
"\n Reset Keras session and set GPU configuration as well as collect unused memory.\n This is adapted from [jaycangel's post on fastai forum](https://forums.fast.ai/t/how-could-i-release-gpu-memory-of-keras/2023/18).\n Calling this before any training... |
def cuda_release_memory():
"\n Force cuda to release GPU memory by closing it.\n :return cuda: numba's cuda module.\n "
spec = importlib.util.find_spec('numba')
if (spec is None):
raise Exception("numba module cannot be found. Can't function before numba module is installed.")
else:
... |
def moving_window_avg(x, window=5):
'\n Return a moving-window average.\n :param x: a numpy array\n :param window: an integer, number of data points for window size.\n '
return pd.DataFrame(x).rolling(window=window, min_periods=1).mean().values.squeeze()
|
def set_momentum(optimizer, mom_val):
'\n Helper to set momentum of Keras optimizers.\n :param optimizer: Keras optimizer\n :param mom_val: value of momentum.\n '
keys = dir(optimizer)
if ('momentum' in keys):
K.set_value(optimizer.momentum, mom_val)
if ('rho' in keys):
K.s... |
def set_lr(optimizer, lr):
'\n Helper to set learning rate of Keras optimizers.\n :param optimizer: Keras optimizer\n :param lr: value of learning rate.\n '
K.set_value(optimizer.lr, lr)
|
def dot_product(x, kernel):
return tf.tensordot(x, kernel, axes=1)
|
class Attention(Layer):
def __init__(self, W_regularizer=None, b_regularizer=None, W_constraint=None, b_constraint=None, bias=True, return_attention=False, **kwargs):
'\n Keras Layer that implements an Attention mechanism for temporal data.\n Supports Masking.\n Follows the work of R... |
class LayerNormalization(Layer):
'\n Implementation of Layer Normalization (https://arxiv.org/abs/1607.06450).\n "Unlike batch normalization, layer normalization performs exactly\n the same computation at training and test times."\n '
def __init__(self, axis=(- 1), **kwargs):
self.axis = ... |
class FocalLoss(tf.keras.losses.Loss):
def __init__(self, gamma=2.0, alpha=4.0, reduction=tf.keras.losses.Reduction.AUTO, name='focal_loss'):
'Focal loss for multi-classification\n FL(p_t)=-alpha(1-p_t)^{gamma}ln(p_t)\n Notice: y_pred is probability after softmax\n gradient is d(Fl)/... |
class LDAMLoss(tf.keras.losses.Loss):
def __init__(self, cls_num_list, max_m=0.5, weight=None, s=30, reduction=tf.keras.loses.Reduction.AUTO, name='LDAM'):
super().__init__(reduction=reduction, name=name)
m_list = (1.0 / np.sqrt(np.sqrt(cls_num_list)))
m_list *= max_m(m_list.max())
... |
class Lookahead(tf.keras.optimizers.Optimizer):
'This class allows to extend optimizers with the lookahead mechanism.\n The mechanism is proposed by Michael R. Zhang et.al in the paper\n [Lookahead Optimizer: k steps forward, 1 step back]\n (https://arxiv.org/abs/1907.08610v1). The optimizer iteratively ... |
class NovoGrad(tf.keras.optimizers.Optimizer):
'The NovoGrad Optimizer was first proposed in [Stochastic Gradient\n Methods with Layerwise Adaptvie Moments for training of Deep\n Networks](https://arxiv.org/pdf/1905.11286.pdf)\n NovoGrad is a first-order SGD-based algorithm, which computes second\n mo... |
def Ranger(sync_period=6, slow_step_size=0.5, learning_rate=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-07, weight_decay=0.0, amsgrad=False, sma_threshold=5.0, total_steps=0, warmup_proportion=0.1, min_lr=0.0, name='Ranger'):
'\n function returning a tf.keras.optimizers.Optimizer object\n returned o... |
class RectifiedAdam(tf.keras.optimizers.Optimizer):
'Variant of the Adam optimizer whose adaptive learning rate is rectified\n so as to have a consistent variance.\n It implements the Rectified Adam (a.k.a. RAdam) proposed by\n Liyuan Liu et al. in [On The Variance Of The Adaptive Learning Rate\n And ... |
class rec_optimizer(Optimizer):
def __init__(self, layers=2, nodes=20):
pass
|
def _solve(a, b, c):
'Return solution of a quadratic minimization.\n The optimization equation is:\n f(a, b, c) = argmin_w{1/2 * a * w^2 + b * w + c * |w|}\n we get optimal solution w*:\n w* = -(b - sign(b)*c)/a if |b| > c else w* = 0\n REQUIRES: Dimensionality of a and b must be same\n ... |
class Yogi(tf.keras.optimizers.Optimizer):
'Optimizer that implements the Yogi algorithm in Keras.\n See Algorithm 2 of\n https://papers.nips.cc/paper/8186-adaptive-methods-for-nonconvex-optimization.pdf.\n '
@typechecked
def __init__(self, learning_rate: Union[(FloatTensorLike, Callable)]=0.01,... |
def attention_simple(inputs, timesteps):
input_dim = int(inputs.shape[(- 1)])
a = Permute((2, 1), name='transpose')(inputs)
a = Dense(timesteps, activation='softmax', name='attention_probs')(a)
a_probs = Permute((2, 1), name='attention_vec')(a)
output_attention_mul = Multiply(name='focused_attenti... |
def dense_model(timesteps, n_class, n_features, classifier_architecture, dropout):
inputs = Input((timesteps, n_features))
x = Dense(128, activation=Mish())(inputs)
x = LayerNormalization()(x)
(x, a) = attention_simple(x, timesteps)
for (d, dr) in zip(classifier_architecture, dropout):
x =... |
class LogAudioCallback(Callback):
'Log audio samples to Weights & Biases.'
model: pl.LightningModule
stored_forward: MethodType
def __init__(self, on_train: bool, on_val: bool, on_test: bool, save_audio_sr: int=48000, n_batches: int=1, log_on_epoch_end: bool=False, max_audio_samples: int=8):
... |
class CleanWandbCacheCallback(pl.Callback):
def __init__(self, every_n_epochs: int=1, max_size_in_gb: float=1.0):
self.every_n_epochs = every_n_epochs
self.gb_str = f'{max_size_in_gb}GB'
def on_train_epoch_end(self, trainer: 'pl.Trainer', pl_module: 'pl.LightningModule') -> None:
if ... |
class SaveConfigCallbackWanb(SaveConfigCallback):
"\n Custom callback to move the config file saved by LightningCLI to the\n experiment directory created by WandbLogger. This has a few benefits:\n 1. The config file is saved in the same directory as the other files created\n by wandb, so it's eas... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.