Last active
May 9, 2018 13:45
-
-
Save jfkirk/5a740656922aa76a484d2aad2584bfb7 to your computer and use it in GitHub Desktop.
TensorRec Keras Blog Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras as ks | |
from tensorrec import TensorRec | |
from tensorrec.representation_graphs import AbstractKerasRepresentationGraph | |
# My new deep net representation graph | |
class DeepRepresentationGraph(AbstractKerasRepresentationGraph): | |
def create_layers(self, n_features, n_components): | |
return [ | |
ks.layers.Dense(n_components * 16, activation='relu'), | |
ks.layers.Dense(n_components * 8, activation='relu'), | |
ks.layers.Dense(n_components * 2, activation='relu'), | |
ks.layers.Dense(n_components, activation='tanh'), | |
] | |
# My new recommender system with two deep nets | |
model = TensorRec(item_repr_graph=DeepRepresentationGraph(), | |
user_repr_graph=DeepRepresentationGraph()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment