{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random\nimport math\nfrom sklearn.model_selection import train_test_split\n\ndef seed_everything(SEED): \n    np.random.seed(SEED) \n    random.seed(SEED)\n\nseed_everything(last_4_digits_of_your_Fordham_ID)\n\n\nclass Layer:\n    \n    def __init__(self, in_size, out_size, activation_func):\n        \n        '''\n        init Weight and Bias \n        \n        '''\n\nclass NN:\n    \n    # The following member functions are madantory\n    \n    def __init__(self, ...):\n    \n    # forward propagation\n    def forward_propagation(self, ...):\n\n    # loss function\n    def loss(self, ...):\n       \n    # backward propagation\n    def backward_propagation(self, ...):\n \n    \n    # The following member functions are optional, but can be helpful\n    \n    #define softmax function\n    def softmax(self, ...):\n\n    #step 6.update parameters\n    def update_parameters(self, ...):\n    \n\n# Driver function\n\nx_train = np.load('/kaggle/input/fall-2023-cisc6000-deep-learning-hw1/mnist.train.npy')\nsubmission = pd.read_csv('/kaggle/input/fall-2023-cisc6000-deep-learning-hw1/sample_submission.csv')\ny_train = np.load('/kaggle/input/fall-2023-cisc6000-deep-learning-hw1/mnist.trainlabel.npy')\nx_test = np.load('/kaggle/input/fall-2023-cisc6000-deep-learning-hw1/mnist.test.npy')\n\n\n# one-hot encode the labels\n\n# prepare training (80%) and validation data (20%)\n x, x_validation, y, y_validation = train_test_split(x_train,y_train,test_size = 0.2)\n\n\n# Create your NN with two hidden layers\nn_1 = 512\nn_2 = 256\nn_3 = 10\n\n\n\nlearnning_rate_pool = [0.001,0.002,0.0015]\nlearnning_rate = np.random.choice(learnning_rate_pool)\n\n# Train your Model using x, x_validation, y, y_validation\nfor e in range(100):    \n    for i in range(0,x.shape[0],32):\n        data,target = x[i:i+32],y[i:i+32]   # this is one mini-batch\n        data = data.reshape(-1,784)         \n        \n        ## pass the data to your model and perform forward and backward passes\n        ## must show the training process, i.e., running loss, accuracy, etc.\n        ## must using the above learning rate to train. \n        \n\n# get predictions for test data x_test\n\n\n#submit my predictions\nsubmission = pd.read_csv('/kaggle/input/fall-2023-cisc6000-deep-learning-hw1/sample_submission.csv',index_col = 0)\nsubmission['class'] = pred_test\nsubmission.to_csv('Neural_Network_Submission.csv')\n\nsubmission.head()","metadata":{},"execution_count":null,"outputs":[]}],"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}}