{"id":15369923,"url":"https://github.com/tokusumi/keras-flops","last_synced_at":"2025-04-14T03:25:29.094Z","repository":{"id":62573944,"uuid":"287066460","full_name":"tokusumi/keras-flops","owner":"tokusumi","description":"FLOPs calculator with tf.profiler for neural network architecture written in tensorflow 2.2+ (tf.keras)","archived":false,"fork":false,"pushed_at":"2023-10-31T00:03:16.000Z","size":55,"stargazers_count":54,"open_issues_count":9,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T17:22:58.083Z","etag":null,"topics":["flops","profiler","tensorflow2"],"latest_commit_sha":null,"homepage":"","language":"Python","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/tokusumi.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":"2020-08-12T16:47:28.000Z","updated_at":"2025-03-06T06:47:54.000Z","dependencies_parsed_at":"2024-06-21T05:44:18.065Z","dependency_job_id":"81202bd0-22b4-4629-b106-3d0219f189c9","html_url":"https://github.com/tokusumi/keras-flops","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.0714285714285714,"last_synced_commit":"5c130bfe91d39eea39af89346b029e70c3351999"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Fkeras-flops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Fkeras-flops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Fkeras-flops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokusumi%2Fkeras-flops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tokusumi","download_url":"https://codeload.github.com/tokusumi/keras-flops/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248596704,"owners_count":21130748,"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":["flops","profiler","tensorflow2"],"created_at":"2024-10-01T13:39:15.652Z","updated_at":"2025-04-14T03:25:29.074Z","avatar_url":"https://github.com/tokusumi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# keras-flops\n\n![](https://github.com/tokusumi/keras-flops/workflows/Tests/badge.svg)\n[![PyPI version](https://badge.fury.io/py/keras-flops.svg)](https://badge.fury.io/py/keras-flops)\n\nFLOPs calculator for neural network architecture written in tensorflow (tf.keras) v2.2+\n\nThis stands on the shoulders of giants, [tf.profiler](https://www.tensorflow.org/api_docs/python/tf/compat/v1/profiler/Profiler). \n\n## Requirements\n\n* Python 3.6+\n* Tensorflow 2.2+\n\n## Installation\n\nUsing pip:\n\n```\npip install keras-flops\n```\n\n## Example\n\nSee colab examples [here](https://github.com/tokusumi/keras-flops/tree/master/notebooks) in details.\n\n```python\nfrom tensorflow.keras import Model, Input\nfrom tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout\n\nfrom keras_flops import get_flops\n\n# build model\ninp = Input((32, 32, 3))\nx = Conv2D(32, kernel_size=(3, 3), activation=\"relu\")(inp)\nx = Conv2D(64, (3, 3), activation=\"relu\")(x)\nx = MaxPooling2D(pool_size=(2, 2))(x)\nx = Dropout(0.25)(x)\nx = Flatten()(x)\nx = Dense(128, activation=\"relu\")(x)\nx = Dropout(0.5)(x)\nout = Dense(10, activation=\"softmax\")(x)\nmodel = Model(inp, out)\n\n# Calculae FLOPS\nflops = get_flops(model, batch_size=1)\nprint(f\"FLOPS: {flops / 10 ** 9:.03} G\")\n# \u003e\u003e\u003e FLOPS: 0.0338 G\n```\n\n## Support\n\nSupport `tf.keras.layers` as follows,\n\n| name | layer | \n| -- | -- |\n| Conv | Conv[1D/2D/3D]|\n| | Conv[1D/2D]Transpose |\n| | DepthwiseConv2D |\n| | SeparableConv[1D/2D] |\n| Pooling | AveragePooling[1D/2D] |\n| | GlobalAveragePooling[1D/2D/3D]|\n| | MaxPooling[1D/2D] |\n| | GlobalMaxPool[1D/2D/3D] |\n| Normalization | BatchNormalization |\n| Activation | Softmax |\n| Attention | Attention |\n| | AdditiveAttention |\n| others | Dense |\n\n## Not supported\n\nNot support `tf.keras.layers` as follows. They are calculated as zero or smaller value than correct value.\n\n| name | layer | \n| -- | -- |\n| Conv | Conv3DTranspose |\n| Pooling | AveragePooling3D |\n| | MaxPooling3D |\n| | UpSampling[1D/2D/3D] |\n| Normalization | LayerNormalization |\n| RNN | SimpleRNN |\n| | LSTM |\n| | GRU |\n| others | Embedding |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokusumi%2Fkeras-flops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokusumi%2Fkeras-flops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokusumi%2Fkeras-flops/lists"}