{"id":18607541,"url":"https://github.com/cesarsouza/keras-sharp","last_synced_at":"2025-04-10T01:15:30.043Z","repository":{"id":73426206,"uuid":"97279426","full_name":"cesarsouza/keras-sharp","owner":"cesarsouza","description":"Keras# initiated as an effort to port the Keras deep learning library to C#, supporting both TensorFlow and CNTK","archived":false,"fork":false,"pushed_at":"2021-01-01T18:37:51.000Z","size":1679,"stargazers_count":244,"open_issues_count":21,"forks_count":59,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-04-10T01:15:23.167Z","etag":null,"topics":["deep-learning","keras","machine-learning","neural-networks","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"C#","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/cesarsouza.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":"2017-07-14T23:22:22.000Z","updated_at":"2025-01-16T10:11:56.000Z","dependencies_parsed_at":"2023-03-24T11:49:56.063Z","dependency_job_id":null,"html_url":"https://github.com/cesarsouza/keras-sharp","commit_stats":{"total_commits":75,"total_committers":3,"mean_commits":25.0,"dds":"0.026666666666666616","last_synced_commit":"4fd000f5ab0765a2dc589ede61b1d762d44baf27"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarsouza%2Fkeras-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarsouza%2Fkeras-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarsouza%2Fkeras-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cesarsouza%2Fkeras-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cesarsouza","download_url":"https://codeload.github.com/cesarsouza/keras-sharp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137892,"owners_count":21053775,"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":["deep-learning","keras","machine-learning","neural-networks","tensorflow"],"created_at":"2024-11-07T02:29:56.736Z","updated_at":"2025-04-10T01:15:30.028Z","avatar_url":"https://github.com/cesarsouza.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keras Sharp\n\n\nNote: This project is about to get archived. For a better replacement, please take a look at [TensorFlow.NET](https://github.com/SciSharp/TensorFlow.NET) or [Keras.NET](https://github.com/SciSharp/Keras.NET).\n\nCheers and happy coding!\u003cbr /\u003e\nCesar\n\n----\n\n[![Join the chat at https://gitter.im/keras-sharp/Lobby](https://badges.gitter.im/keras-sharp/Lobby.svg)](https://gitter.im/keras-sharp/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\nAn ongoing effort to port most of the Keras deep learning library to C#.\n\nWelcome to the Keras# project! We aim to bring a experience-compatible Keras-like API to C#, meaning that, if you already know Keras, you should not have to learn any new concepts to get up and running with Keras#. This is a direct, line-by-line port of the Keras project, meaning that all updates and fixes currently sent to the main Keras project should be simple and straightforward to be applied to this branch. As in the original project, we aim to support both TensorFlow and CNTK - but not Theano, as it [has been recently discontinued](https://groups.google.com/d/msg/theano-users/7Poq8BZutbY/rNCIfvAEAwAJ) in 2017.\n\n## Example\n\nConsider the following [Keras Python example originally done by Jason Brownlee](https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/), reproduced below:\n\n```python\nfrom keras.models import Sequential\nfrom keras.layers import Dense\nimport numpy\n\n# fix random seed for reproducibility\nnumpy.random.seed(7)\n\n# load pima indians dataset\ndataset = numpy.loadtxt(\"pima-indians-diabetes.csv\", delimiter=\",\")\n# split into input (X) and output (Y) variables\nX = dataset[:,0:8]\nY = dataset[:,8]\n\n# create model\nmodel = Sequential()\nmodel.add(Dense(12, input_dim=8, activation='relu'))\nmodel.add(Dense(8, activation='relu'))\nmodel.add(Dense(1, activation='sigmoid'))\n\n# Compile model\nmodel.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])\n\n# Fit the model\nmodel.fit(X, Y, epochs=150, batch_size=10)\n\n# evaluate the model\nscores = model.evaluate(X, Y)\nprint(\"\\n%s: %.2f%%\" % (model.metrics_names[1], scores[1]*100))\n```\n\nThe same can be obtained using Keras# using:\n\n```csharp\n// Load the Pima Indians Data Set\nvar pima = new Accord.DataSets.PimaIndiansDiabetes();\nfloat[,] x = pima.Instances.ToMatrix().ToSingle();\nfloat[] y = pima.ClassLabels.ToSingle();\n\n// Create the model\nvar model = new Sequential();\nmodel.Add(new Dense(12, input_dim: 8, activation: new ReLU()));\nmodel.Add(new Dense(8, activation: new ReLU()));\nmodel.Add(new Dense(1, activation: new Sigmoid()));\n\n// Compile the model (for the moment, only the mean square \n// error loss is supported, but this should be solved soon)\nmodel.Compile(loss: new MeanSquareError(), \n    optimizer: new Adam(), \n    metrics: new[] { new Accuracy() });\n\n// Fit the model for 150 epochs\nmodel.fit(x, y, epochs: 150, batch_size: 10);\n\n// Use the model to make predictions\nfloat[] pred = model.predict(x)[0].To\u003cfloat[]\u003e();\n\n// Evaluate the model\ndouble[] scores = model.evaluate(x, y);\nConsole.WriteLine($\"{model.metrics_names[1]}: {scores[1] * 100}\");\n```\n\nUpon execution, you should see the same familiar Keras behavior as shown below:\n\n![Keras Sharp during training](https://github.com/cesarsouza/keras-sharp/raw/master/Docs/Wiki/learning.png)\n\nThis is posssible because Keras# is a direct, line-by-line port of the Keras project into C#. A goal of this project is to make sure that porting existing code from its Python counterpart into C# can be done in no time or with minimum effort, if at all.\n\n## Backends\n\nKeras# currently supports TensorFlow and CNTK backends. If you would like to switch between different backends:\n\n```csharp\nKerasSharp.Backends.Current.Switch(\"KerasSharp.Backends.TensorFlowBackend\");\n```\nor,\n```csharp\nKerasSharp.Backends.Current.Switch(\"KerasSharp.Backends.CNTKBackend\");\n```\nor,\n\nIf you would like to implement your own backend to your own preferred library, such as [DiffSharp](https://github.com/DiffSharp/DiffSharp), just provide your own implementation of the IBackend interface and specify it using:\n```csharp\nKerasSharp.Backends.Current.Switch(\"YourNamespace.YourOwnBackend\");\n```\n\n## Work-in-progress\n\nHowever, please note that this is still work-in-progress. Not only Keras#, but also [TensorFlowSharp](https://github.com/migueldeicaza/TensorFlowSharp) and [CNTK](https://github.com/Microsoft/CNTK). If you would like to contribute to the development of this project, please consider submitting new issues to any of those projects, [including us](https://github.com/cesarsouza/keras-sharp/issues).\n\n## Contributing in development\n\nIf you would like to contribute to the project, please see: [How to contribute to Keras#](https://github.com/cesarsouza/keras-sharp/wiki/How-to-contribute-in-development).\n\n## License \u0026 Copyright\n\nThe Keras-Sharp project is brought to you under the as-permissable-as-possible MIT license. This is the same license provided by the original Keras project. This project also keeps track of all code contributions through the project's issue tracker, and pledges to update all licensing information once user contributions are accepted. Contributors are asked to grant explicit copyright licensens upon their contributions, which guarantees this project can be used in production without any licensing-related worries.\n\nThis project is brought to you by the same creators of the [Accord.NET Framework](https://github.com/accord-net/framework).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesarsouza%2Fkeras-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcesarsouza%2Fkeras-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcesarsouza%2Fkeras-sharp/lists"}