{"id":15659705,"url":"https://github.com/remigenet/tkat","last_synced_at":"2025-04-09T12:04:10.996Z","repository":{"id":242706498,"uuid":"809767791","full_name":"remigenet/TKAT","owner":"remigenet","description":"Temporal Kolmogorov-Arnold Transformer","archived":false,"fork":false,"pushed_at":"2024-12-27T11:14:23.000Z","size":211,"stargazers_count":79,"open_issues_count":0,"forks_count":12,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T11:01:43.166Z","etag":null,"topics":["jax","keras","keras3","temporal-networks","tensorflow","timeseries","timeseries-forecasting","tkan","tkat","torch","transformer"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remigenet.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":"2024-06-03T12:14:20.000Z","updated_at":"2025-03-16T12:30:36.000Z","dependencies_parsed_at":"2024-06-27T08:56:01.994Z","dependency_job_id":"e91a14b6-2afc-49d0-a07c-236fa3e43c5c","html_url":"https://github.com/remigenet/TKAT","commit_stats":{"total_commits":10,"total_committers":2,"mean_commits":5.0,"dds":0.4,"last_synced_commit":"0ef3fbb25150b60f26cff42a74249ec1d55c8aa5"},"previous_names":["remigenet/tkat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remigenet%2FTKAT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remigenet%2FTKAT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remigenet%2FTKAT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remigenet%2FTKAT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remigenet","download_url":"https://codeload.github.com/remigenet/TKAT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036064,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["jax","keras","keras3","temporal-networks","tensorflow","timeseries","timeseries-forecasting","tkan","tkat","torch","transformer"],"created_at":"2024-10-03T13:18:18.453Z","updated_at":"2025-04-09T12:04:10.976Z","avatar_url":"https://github.com/remigenet.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Temporal Kolmogorov-Arnold Transformer for Time Series Forecasting\n\n![TKAT representation](images/model_representation.jpeg)\n\nThis folder includes the original code implemented for the [paper](https://arxiv.org/abs/2406.02486) of the same name. The model is made in keras3 and is supporting all backend (jax, tensorflow, pytorch).\n\nIt is inspired on the Temporal Fusion Transformer by [google-research](https://github.com/google-research/google-research/tree/master/tft) and the [Temporal Kolmogorov Arnold Network](https://github.com/remigenet/TKAN). \n\nThe Temporal Kolmogorov-Arnold Transformer uses the TKAN layers from the [paper](https://arxiv.org/abs/2405.07344) to improve the performance of the Temporal Fusion Transformer by replacing the internal LSTM encoder and decoder part. It needs the implementation available here [tkan](https://github.com/remigenet/tkan) with version \u003e= 0.2.\n\nThe TKAT is however different from the Temporal Fusion Transformer on many aspects like the absence of static inputs and a different architecture after the multihead.\n\n## Installation\n\nA Pypi package is available for the TKAT implementation. You can install it directly from PyPI:\n\n```bash\npip install tkat\n```\n\nor can be installed by cloning the repo and using:\n\n```bash\npip install path/to/tkat\n```\n\n## Usage\n\nContrary to the TKAN package, the TKAT is a full model implementation and thus can be used directly as a model. Here is an example of how to use it:\n\n```python\nfrom tkat import TKAT\n\nN_MAX_EPOCHS = 100\nBATCH_SIZE = 128\nearly_stopping_callback = lambda : tf.keras.callbacks.EarlyStopping(\n    monitor=\"val_loss\",\n    min_delta=0.00001,\n    patience=6,\n    mode=\"min\",\n    restore_best_weights=True,\n    start_from_epoch=6,\n)\nlr_callback = lambda : tf.keras.callbacks.ReduceLROnPlateau(\n    monitor=\"val_loss\",\n    factor=0.25,\n    patience=3,\n    mode=\"min\",\n    min_delta=0.00001,\n    min_lr=0.000025,\n    verbose=0,\n)\ncallbacks = lambda : [early_stopping_callback(), lr_callback(), tf.keras.callbacks.TerminateOnNaN()]\n\n\nsequence_length = 30\nnum_unknow_features = 8\nnum_know_features = 2\nnum_embedding = 1\nnum_hidden = 100\nnum_heads = 4\nuse_tkan = True\n\nmodel = TKAT(sequence_length, num_unknow_features, num_know_features, num_embedding, num_hidden, num_heads, n_ahead, use_tkan = use_tkan)\noptimizer = tf.keras.optimizers.Adam(0.001)\nmodel.compile(optimizer=optimizer, loss='mean_squared_error')\n\nmodel.summary()\n\nhistory = model.fit(X_train, y_train, batch_size=BATCH_SIZE, epochs=N_MAX_EPOCHS, validation_split=0.2, callbacks=callbacks(), shuffle=True, verbose = False)\n\ntest_preds = model.predict(X_test)\n\n```\n\nX_train should be a numpy array of shape (n_samples, sequence_length + n_ahead, num_unknow_features + num_know_features) and y_train should be a numpy array of shape (n_samples, n_ahead).\nThe values in X_train[:,sequence_length:,:num_unknow_features] are not used and can be set to 0.\nThe known inputs should be the last features in X_train.\n\nFor a more detailed example please look to the notebook in the example folder.\n\nPlease cite our work if you use this repo:\n```\n@article{genet2024temporal,\n  title={A Temporal Kolmogorov-Arnold Transformer for Time Series Forecasting},\n  author={Genet, Remi and Inzirillo, Hugo},\n  journal={arXiv preprint arXiv:2406.02486},\n  year={2024}\n}\n```\n\nShield: [![CC BY-NC-SA 4.0][cc-by-nc-sa-shield]][cc-by-nc-sa]\n\nThis work is licensed under a\n[Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][cc-by-nc-sa].\n\n[![CC BY-NC-SA 4.0][cc-by-nc-sa-image]][cc-by-nc-sa]\n\n[cc-by-nc-sa]: http://creativecommons.org/licenses/by-nc-sa/4.0/\n[cc-by-nc-sa-image]: https://licensebuttons.net/l/by-nc-sa/4.0/88x31.png\n[cc-by-nc-sa-shield]: https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremigenet%2Ftkat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremigenet%2Ftkat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremigenet%2Ftkat/lists"}