{"id":16907211,"url":"https://github.com/mfbalin/concrete-autoencoders","last_synced_at":"2025-05-09T00:04:06.328Z","repository":{"id":34934273,"uuid":"167724871","full_name":"mfbalin/Concrete-Autoencoders","owner":"mfbalin","description":null,"archived":false,"fork":false,"pushed_at":"2022-05-24T19:27:00.000Z","size":365,"stargazers_count":118,"open_issues_count":14,"forks_count":31,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-09T00:03:59.120Z","etag":null,"topics":["concrete-autoencoders","feature-selection","icml","icml-2019","machine-learning","supervised-learning","unsupervised-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","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/mfbalin.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}},"created_at":"2019-01-26T18:40:14.000Z","updated_at":"2025-04-08T20:36:09.000Z","dependencies_parsed_at":"2022-08-27T19:21:28.811Z","dependency_job_id":null,"html_url":"https://github.com/mfbalin/Concrete-Autoencoders","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/mfbalin%2FConcrete-Autoencoders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbalin%2FConcrete-Autoencoders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbalin%2FConcrete-Autoencoders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfbalin%2FConcrete-Autoencoders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfbalin","download_url":"https://codeload.github.com/mfbalin/Concrete-Autoencoders/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166514,"owners_count":21864475,"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":["concrete-autoencoders","feature-selection","icml","icml-2019","machine-learning","supervised-learning","unsupervised-learning"],"created_at":"2024-10-13T18:46:33.298Z","updated_at":"2025-05-09T00:04:06.282Z","avatar_url":"https://github.com/mfbalin.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Concrete Autoencoders\n\nThe concrete autoencoder is an end-to-end differentiable method for global feature selection, which efficiently identifies a subset of the most informative features and simultaneously learns a neural network to reconstruct the input data from the selected features. The method can be applied to unsupervised and supervised settings, and is a modification of the standard autoencoder.\n\nFor more details, see the accompanying paper: [\"Concrete Autoencoders for Differentiable Feature Selection and Reconstruction\"](https://arxiv.org/abs/1901.09346), *ICML 2019*, and please use the citation below.\n\n```\n@article{abid2019concrete,\n  title={Concrete Autoencoders for Differentiable Feature Selection and Reconstruction},\n  author={Abid, Abubakar and Balin, Muhammed Fatih and Zou, James},\n  journal={arXiv preprint arXiv:1901.09346},\n  year={2019}\n}\n```\n\n## Installation\n\nTo install, use `pip install concrete-autoencoder`\n\n## Usage\n\nHere's an example of using Concrete Autoencoders to select the 20 most important features (pixels) across the entire MNIST dataset:\n\n```python\nfrom concrete_autoencoder import ConcreteAutoencoderFeatureSelector\nfrom keras.datasets import mnist\nfrom keras.utils import to_categorical\nfrom keras.layers import Dense, Dropout, LeakyReLU\nimport numpy as np\n\n(x_train, y_train), (x_test, y_test) = mnist.load_data()\nx_train = np.reshape(x_train, (len(x_train), -1))\nx_test = np.reshape(x_test, (len(x_test), -1))\ny_train = to_categorical(y_train)\ny_test = to_categorical(y_test)\nprint(x_train.shape, y_train.shape)\nprint(x_test.shape, y_test.shape)\n\ndef decoder(x):\n    x = Dense(320)(x)\n    x = LeakyReLU(0.2)(x)\n    x = Dropout(0.1)(x)\n    x = Dense(320)(x)\n    x = LeakyReLU(0.2)(x)\n    x = Dropout(0.1)(x)\n    x = Dense(784)(x)\n    return x\n\nselector = ConcreteAutoencoderFeatureSelector(K = 20, output_function = decoder, num_epochs = 800)\n\nselector.fit(x_train, x_train, x_test, x_test)\n```\n\nThen, to get the pixels, run this:\n```python\nselector.get_support(indices = True)\n```\n\nRun this code inside a colab notebook: https://colab.research.google.com/drive/11NMLrmToq4bo6WQ_4WX5G4uIjBHyrzXd\n\n## Documentation:\n\nclass ConcreteAutoencoderFeatureSelector:\n\n  Constructor takes a number of parameters to initalize the class. They are:\n  \n    K: the number of features one wants to select\n    \n    output_function: the decoder function\n    \n    num_epochs: number of epochs to start training concrete autoencoders\n    \n    batch_size: the batch size during training\n    \n    learning_rate: learning rate of the adam optimizer used during training\n    \n    start_temp: the starting temperature of the concrete select layer\n    \n    min_temp: the ending temperature of the concrete select layer\n    \n    tryout_limit: number of times to double the number of epochs and try again in case it doesn't converge\n    \n    \n  fit(X, Y = None): trains the concrete autoencoder\n  \n    X: the data for which you want to do feature selection\n    \n    Y: labels, in case labels are given, it will do supervised feature selection, if not, then unsupervised feature selection\n  \n  \n  transform(X): filters X's features after fit has been called\n  \n    X: the data to be filtered\n    \n    \n  fit_transform(X): calls fit and transform in a sequence\n  \n    X: the data to do feature selection on and filter\n    \n    \n  get_support(indices = False): if indices is True, returns indices of the features selected, if not, returns a mask\n  \n    indices: boolean flag to determine whether to return a list of indices or a boolean mask\n    \n  \n  get_params(): returns the underlying keras model for the concrete autoencoder\n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfbalin%2Fconcrete-autoencoders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfbalin%2Fconcrete-autoencoders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfbalin%2Fconcrete-autoencoders/lists"}