{"id":16882636,"url":"https://github.com/valaydave/mnist-experiments-with-metaflow","last_synced_at":"2025-04-11T21:12:27.292Z","repository":{"id":93795128,"uuid":"239039461","full_name":"valayDave/mnist-experiments-with-metaflow","owner":"valayDave","description":"Experimentation Of different deep learning models for classification of digits on a MNIST dataset using Metaflow","archived":false,"fork":false,"pushed_at":"2020-03-07T19:35:03.000Z","size":456,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T21:12:13.124Z","etag":null,"topics":["deeplearning","keras","metaflow","tensorflow"],"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/valayDave.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":"2020-02-07T23:18:21.000Z","updated_at":"2023-03-26T14:13:18.000Z","dependencies_parsed_at":"2023-06-15T02:30:27.141Z","dependency_job_id":null,"html_url":"https://github.com/valayDave/mnist-experiments-with-metaflow","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/valayDave%2Fmnist-experiments-with-metaflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valayDave%2Fmnist-experiments-with-metaflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valayDave%2Fmnist-experiments-with-metaflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valayDave%2Fmnist-experiments-with-metaflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valayDave","download_url":"https://codeload.github.com/valayDave/mnist-experiments-with-metaflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480428,"owners_count":21110937,"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":["deeplearning","keras","metaflow","tensorflow"],"created_at":"2024-10-13T16:08:01.287Z","updated_at":"2025-04-11T21:12:27.283Z","avatar_url":"https://github.com/valayDave.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Experiments With MNIST Using Metaflow\n\nUsed Metaflow to test and experiment with different deep learning models for classification of digits on a MNIST dataset\n\n## Setting it Up \n\n- ``pip install -r requirements.txt``\n- Conda is required to Run this. \n    1. Download Miniconda at https://docs.conda.io/en/latest/miniconda.html\n    2. ```conda config --add channels conda-forge```\n\n- export PATH=\"/Users/valaydave/miniconda3/bin:$PATH\" --\u003e Change this to where u install miniconda. U need to run this before executing the Experiments. \n\n## Why Metaflow ?\n\n- Metaflow is this neat library that helps datascientists focus on thier core responsiblities of managing insights extraction by abstracting out computation and data warehousing, versioning and deployments.  \n\n- The below is how a `Flow` is defined on metaflow. Every function marked with the `@step` decorator which helps define a compuational Node in a DAG. Metaflow works on the **dataflow paradigm** so nodes later in the flow can have access to properties set during the pervious steps in the flow. The below flow is an example. see [hello_mnist.py](hello_mnist.py) for actual code. \n- The below flow show cases how 3 different types of models can be trained efficiently in parallel with easy access to results of the entire data pipeline.  \n\n- Please note when run locally each `@step` is a process. But with AWS, one can use `@batch(cpu=3,memory=4000,image=python:3.7)` to run the same step of the flow on a python container in AWS's Batch Service. \n    ```python\n    from metaflow import FlowSpec, step\n    class MNISTFlowExplain(FlowSpec):\n        @step\n        def start(self):\n            \"\"\"\n            Parse the MNIST Dataset into Flattened and None Flattened Data artifacts. \n\n            \"\"\"\n            self.data_flattened,self.unflattened =  process_data()\n\n        @step\n        def train_sequential(self):\n            \"\"\"\n            Train sequential Neural Network with with the Set of parameters. \n            \n            \"\"\"\n            self.history = train_sequential(self.data_flattened)\n            self.next(self.join)\n\n        @step\n        def train_convolution(self):\n            \"\"\"\n            Train a Convolutional Neural Network with the Set of parameters.\n            \"\"\"\n            self.history = train_convolution(self.unflattened)\n            self.next(self.join)\n\n        @step\n        def train_convolution_batch_norm(self):\n            \"\"\"\n            Train a Convolutional Neural Network with Batch Norm and Dropout with the Set of parameters.\n            \"\"\"\n            self.history = train_batch_norm(self.unflattened)\n            self.next(self.join)\n\n    \n        @step\n        def join(self,inputs):\n            \"\"\"\n            Join our parallel branches and merge results,\n            \"\"\"\n            self.history = {\n                'convolution' : inputs.train_convolution.history,\n                'sequential' : inputs.train_sequential.history,\n                'convolution_batch_norm' : inputs.train_convolution_batch_norm.history\n            }\n            \n            self.next(self.end)\n\n        @step\n        def end(self):\n            print(\"Done Computation\")\n\n    ```\n\n- The above flow can be presented in the below state diagram. \n- ![](graph.png)\n- Experiments can be defined with multiple `Parameters` which may be set at runtime. These are stored as a part of every `Run` of the Flow.  \n- Once the flow is completed. It can be accessed via \n    ```python\n    from metaflow import Metaflow, Flow, get_metadata,Run\n    print(Metaflow().flows)\n    ```\n- See *Experiment Analysis* for more details. \n\n## Experimentation Strategy :\n\n- Run individual Experiments Using ``python hello_mnist.py --environment=conda run --num_training_examples 10000``\n\n## Metaflow Help \n\n-  ``python hello_mnist.py --environment=conda run --help`` : This will show all the parameters which are currently avaliable to perform experiments on. \n\n-  ``python hello_mnist.py --environment=conda show`` : This will show the steps of the DAG used for this Experiment. And each step.\n\n## Experiment Analysis\n\n- After running a couple of Experiments successfully running the [experiments_analytics.ipynb](experiments_analytics.ipynb) will help create charts that will help analyse different parameters of the Experiment. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalaydave%2Fmnist-experiments-with-metaflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalaydave%2Fmnist-experiments-with-metaflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalaydave%2Fmnist-experiments-with-metaflow/lists"}