Skip to content

Instantly share code, notes, and snippets.

@jfkirk
Last active May 9, 2018 13:45
Show Gist options
  • Save jfkirk/5a740656922aa76a484d2aad2584bfb7 to your computer and use it in GitHub Desktop.
Save jfkirk/5a740656922aa76a484d2aad2584bfb7 to your computer and use it in GitHub Desktop.
TensorRec Keras Blog Example
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