{"id":17118182,"url":"https://github.com/stepfenshawn/tidf","last_synced_at":"2025-03-24T01:44:15.359Z","repository":{"id":165907078,"uuid":"612809538","full_name":"StepfenShawn/tidf","owner":"StepfenShawn","description":"A tiny, simple, stupid but powerful deep-learning framework in c++. ","archived":false,"fork":false,"pushed_at":"2023-05-16T10:31:20.000Z","size":62,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-29T08:11:53.215Z","etag":null,"topics":["c-plus-plus","deep-learning","machine-learning"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StepfenShawn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-03-12T03:11:42.000Z","updated_at":"2023-06-17T12:53:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"c4e9a087-f999-4c08-83a4-9b3885fce080","html_url":"https://github.com/StepfenShawn/tidf","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepfenShawn%2Ftidf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepfenShawn%2Ftidf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepfenShawn%2Ftidf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StepfenShawn%2Ftidf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StepfenShawn","download_url":"https://codeload.github.com/StepfenShawn/tidf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245195908,"owners_count":20575936,"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":["c-plus-plus","deep-learning","machine-learning"],"created_at":"2024-10-14T17:53:43.897Z","updated_at":"2025-03-24T01:44:15.333Z","avatar_url":"https://github.com/StepfenShawn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tidf\nA tiny, simple, stupid but powerful deep-learning framework in c++.  \n\n# Why Tidf?\n* Powerful: `Tidf` provides a Keras-like api.\n* Simple and stupid: Support brandcast and made in pure c++11.\n* Tiny but fast: The implementation is under 1,000 semicolons.\n\n# Components\n### Layers\n* Dense Layer (Linear Layer)\n\n### Regularizations\n* L1 regularization\n* L2 regularization\n* Dropout\n\n### Activations\n* sigmoid\n* relu\n* tanh\n\n### Optimizers\n* SGD (Stochastic gradient descent)\n\n### Cast Functions\n* CrossEntropy\n* MSE (L2Loss)\n* L1Loss\n\nmore to come! :)\n\n# Examples\n\n### Train a 3-Layers neural network\n```cpp\n#include \"../tidf/core.h\"\n\nint main() {\n    _TIDF_INIT_;\n    NEW_MAT(train_inputs, double, \n      ({{0.0, 0.0, 1.0},\n        {1.0, 1.0, 1.0},\n        {1.0, 0.0, 1.0},\n        {0.0, 1.0, 1.0}}));\n\n    NEW_MAT(train_outputs, double,\n      ({{0.0, 1.0, 1.0, 0.0}}));\n    \n    Net\u003cdouble\u003e* net = new Net\u003cdouble\u003e(train_inputs.transpose(), train_outputs);\n    net-\u003eaddLayer\u003c 4 \u003e(LayerType::Dense, \"sigmoid\"); \n    net-\u003eaddLayer\u003c 4 \u003e(LayerType::Dense, \"tanh\"); \n    net-\u003eaddLayer\u003c 1 \u003e(LayerType::Dense, \"sigmoid\");\n    net-\u003ecompile(\"CrossEntropyLoss\", \"SGD\");\n    net-\u003efit(100000);\n    std::cout \u003c\u003c net-\u003epredict(\n      MAT( double, ({{1.0}, {1.0}, {1.0}})) ) \u003c\u003c std::endl;\n    return 0;\n}\n```\nResult:  \n```\nMatrix(1 x 1):\n0.998889\n```\n\nYou can also load matrix from `.txt` files:  \n```cpp\n  ...\n  Matrix\u003cdouble\u003e train_inputs = load_mat\u003cdouble\u003e(\"train_X.txt\");\n  Matrix\u003cdouble\u003e train_outputs = load_mat\u003cdouble\u003e(\"train_Y.txt\");\n  ...\n```\n\n### Matrix\n`tidf` supports `brandcast` and provides a simple but powerful `API` to make it easier to work with matrices:  \n```cpp\n#include \"tidf/core.h\"\n\nint main() {\n    NEW_MAT(m1, double, ({{1, 4, 3}, {1, 2, 3}}));\n    NEW_MAT(m2, double, ({{1, 2, 3}}));\n    NEW_MAT(m3, double, ({{2, 3, 4}}));\n\n    std::cout \u003c\u003c m1.dot(m2.transpose()) \u003c\u003c std::endl;\n    std::cout \u003c\u003c m2 * 2.0 + m3 \u003c\u003c std::endl;\n    std::cout \u003c\u003c m2.apply([](double x) -\u003e double {return x * 10.0;}) \u003c\u003c std::endl;\n    std::cout \u003c\u003c m2.join(m3) \u003c\u003c std::endl;\n    std::cout \u003c\u003c m1.row(1).sum() \u003c\u003c std::endl;\n    return 0;\n}\n```\n\n# License\nMIT License  \nCopyright (c) 2023 Stepfen Shawn","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepfenshawn%2Ftidf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepfenshawn%2Ftidf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepfenshawn%2Ftidf/lists"}