{"id":19214656,"url":"https://github.com/garethjns/tf2factorizationmachine","last_synced_at":"2026-04-30T19:31:17.625Z","repository":{"id":39739944,"uuid":"200923055","full_name":"garethjns/TF2FactorizationMachine","owner":"garethjns","description":"Factorization machine implemented in TensorFlow 2","archived":false,"fork":false,"pushed_at":"2023-03-24T22:33:54.000Z","size":2229,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T22:05:08.582Z","etag":null,"topics":["factorization-machines","latent-variable-models","recommender-system","supervised-learning","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garethjns.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-06T20:53:04.000Z","updated_at":"2020-05-31T19:43:15.000Z","dependencies_parsed_at":"2024-11-09T14:21:01.453Z","dependency_job_id":null,"html_url":"https://github.com/garethjns/TF2FactorizationMachine","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/garethjns/TF2FactorizationMachine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethjns%2FTF2FactorizationMachine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethjns%2FTF2FactorizationMachine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethjns%2FTF2FactorizationMachine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethjns%2FTF2FactorizationMachine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garethjns","download_url":"https://codeload.github.com/garethjns/TF2FactorizationMachine/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garethjns%2FTF2FactorizationMachine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32475191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["factorization-machines","latent-variable-models","recommender-system","supervised-learning","tensorflow"],"created_at":"2024-11-09T14:10:52.686Z","updated_at":"2026-04-30T19:31:17.599Z","avatar_url":"https://github.com/garethjns.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Factorization machine in TensorFlow 2\n\nExample implementing a factorization machine in TensorFlow 2, along with a framework for generating user-item ratings for testing.\n\nBased on the theory and tf-1 code in [this article](http://nowave.it/factorization-machines-with-tensorflow.html) by Gabriele Modena and the paper by [Factorization Machines](https://www.csie.ntu.edu.tw/~b97053/paper/Rendle2010FM.pdf) by Steffen Rendle. Please refer to these articles for much more detailed descriptions of the model, and the maths that avoid O(p\u003csup\u003e2\u003c/sup\u003e).\n\nCode is work in progress so expect bugs and inconveniences. See examples/ directory for more detailed examples.\n\n# Install\n\n````bash\ngit clone https://github.com/garethjns/TF2FactorizationMachine.git\n````\n\n# Example\n\n## TensorFlow 2 model\nFor now the current model only implements .\\_\\_init__ .\\_\\_call__ and follows a similar structure as the [TensorFlow linear models example](https://www.tensorflow.org/beta/tutorials/eager/custom_training). Training is done in a loop with a function (train_step) to update the parameters; these will be moved to .fit at some point. \n\nSee also [examples/1_model_development.ipynb](https://github.com/garethjns/TF2FactorizationMachine/blob/master/examples/1_model_development.ipynb) for mode details on model development and [examples/2_movie_lens_data.ipynb](https://github.com/garethjns/TF2FactorizationMachine/blob/master/examples/2_movie_lens_data.ipynb) for an example running it on the MovieLens dataset.\n\n````Python\nimport numpy as np\n\nimport matplotlib.pyplot as plt\n\nfrom fmachine.model import FactorizationMachine\nfrom fmachine.helpers import train_step, l2_loss\n\n# Features\nx = np.array([[1, 0, 0,  1, 0, 0, 0,  0.3, 0.3, 0.3, 0.0,  13,  0, 0, 0, 0 ],\n              [1, 0, 0,  0, 1, 0, 0,  0.3, 0.3, 0.3, 0.0,  14,  1, 0, 0, 0 ],\n              [1, 0, 0,  0, 0, 1, 0,  0.3, 0.3, 0.3, 0.0,  16,  0, 1, 0, 0 ],\n              [0, 1, 0,  0, 0, 1, 0,  0.0, 0.0, 0.5, 0.5,  5,   0, 0, 0, 0 ],\n              [0, 1, 0,  0, 0, 0, 1,  0.0, 0.0, 0.5, 0.5,  8,   0, 0, 1, 0 ],\n              [0, 0, 1,  1, 0, 0, 0,  0.5, 0.0, 0.5, 0.0,  9,   0, 0, 0, 0 ],\n              [0, 0, 1,  0, 0, 1, 0,  0.5, 0.0, 0.5, 0.0,  12,  1, 0, 0, 0 ]])\n\n# Targets (explicit rating)\ny = np.array([5, 3, 1, 4, 5, 1, 5])\ny.shape = (7, 1)\n\nmod = FactorizationMachine(m=16)\n\n# Training\nepochs = 200\nbs, ws, vs, losses = [], [], [], []\nfor e in range(epochs):\n    cur_loss = train_step(mod=mod, \n                     x=x, \n                     y_true=y,\n                     lr=0.0025,\n                     loss_f=l2_loss)\n\n# PLot loss\nplt.plot(losses)\nplt.title('Loss history')\nplt.xlabel('Epoch')\nplt.ylabel('Loss')\n````\n\n## Keras interface\nTodo\n\n## Data generator\nTodo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarethjns%2Ftf2factorizationmachine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarethjns%2Ftf2factorizationmachine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarethjns%2Ftf2factorizationmachine/lists"}