Skip to content

Instantly share code, notes, and snippets.

View svtdanny's full-sized avatar

Sivtsov Danil svtdanny

  • Yandex Ads
  • Moscow, Russia
View GitHub Profile
@zaxcie
zaxcie / attention_rnn_keras.py
Created January 16, 2018 17:19
Attention layer for an RNN (LSTM, GRU or simple RNN) in Keras
class Attention(Layer):
def __init__(self, step_dim,
W_regularizer=None, b_regularizer=None,
W_constraint=None, b_constraint=None,
bias=True, **kwargs):
"""
Keras Layer that implements an Attention mechanism for temporal data.
Supports Masking.
Follows the work of Raffel et al. [https://arxiv.org/abs/1512.08756]
# Input shape
@mcarilli
mcarilli / nsight.sh
Last active November 18, 2024 15:15
Favorite nsight systems profiling commands for Pytorch scripts
# This isn't supposed to run as a bash script, i named it with ".sh" for syntax highlighting.
# https://developer.nvidia.com/nsight-systems
# https://docs.nvidia.com/nsight-systems/profiling/index.html
# My preferred nsys (command line executable used to create profiles) commands
#
# In your script, write
# torch.cuda.nvtx.range_push("region name")
# ...