Skip to content

Instantly share code, notes, and snippets.

@ivsanro1
ivsanro1 / ALS Matrix Factorization in Spark.ipynb
Created May 3, 2022 11:28 — forked from twolodzko/ALS Matrix Factorization in Spark.ipynb
Using ALS Matrix Factorization for Making Recommendations in Spark
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ivsanro1
ivsanro1 / AttentionWithContext.py
Created March 7, 2019 15:10 — forked from cbaziotis/AttentionWithContext.py
Keras Layer that implements an Attention mechanism, with a context/query vector, for temporal data. Supports Masking. Follows the work of Yang et al. [https://www.cs.cmu.edu/~diyiy/docs/naacl16.pdf] "Hierarchical Attention Networks for Document Classification"
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
x (): input
kernel (): weights
Returns:
"""
if K.backend() == 'tensorflow':