{ "cells": [ { "cell_type": "code", "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2025-11-04T14:28:00.043927Z", "start_time": "2025-11-04T14:27:59.939813Z" } }, "source": "import numpy as np", "outputs": [], "execution_count": 3 }, { "metadata": { "ExecuteTime": { "end_time": "2025-11-04T14:28:09.512985Z", "start_time": "2025-11-04T14:28:09.508856Z" } }, "cell_type": "code", "source": [ "nn_architecture = [\n", " {\"input_dim\": 2, \"output_dim\": 4, \"activation\": \"relu\"},\n", " {\"input_dim\": 4, \"output_dim\": 6, \"activation\": \"relu\"},\n", " {\"input_dim\": 6, \"output_dim\": 6, \"activation\": \"relu\"},\n", " {\"input_dim\": 6, \"output_dim\": 4, \"activation\": \"relu\"},\n", " {\"input_dim\": 4, \"output_dim\": 1, \"activation\": \"sigmoid\"},\n", "]" ], "id": "48cafaf4b64967bb", "outputs": [], "execution_count": 4 }, { "metadata": { "ExecuteTime": { "end_time": "2025-11-04T14:28:39.907457Z", "start_time": "2025-11-04T14:28:39.903244Z" } }, "cell_type": "code", "source": [ "def init_layers(nn_architecture, seed = 99):\n", " np.random.seed(seed)\n", " number_of_layers = len(nn_architecture)\n", " params_values = {}\n", "\n", " for idx, layer in enumerate(nn_architecture):\n", " layer_idx = idx + 1\n", " layer_input_size = layer[\"input_dim\"]\n", " layer_output_size = layer[\"output_dim\"]\n", "\n", " params_values['W' + str(layer_idx)] = np.random.randn(\n", " layer_output_size, layer_input_size) * 0.1\n", " params_values['b' + str(layer_idx)] = np.random.randn(\n", " layer_output_size, 1) * 0.1\n", "\n", " return params_values\n" ], "id": "d13137630b41b756", "outputs": [], "execution_count": 6 }, { "metadata": { "ExecuteTime": { "end_time": "2025-11-04T14:29:00.821197Z", "start_time": "2025-11-04T14:29:00.795742Z" } }, "cell_type": "code", "source": "init_layers(nn_architecture)", "id": "31f205147667dea6", "outputs": [ { "data": { "text/plain": [ "{'W1': array([[-0.01423588, 0.20572217],\n", " [ 0.02832619, 0.1329812 ],\n", " [-0.01546219, -0.00690309],\n", " [ 0.07551805, 0.08256466]]),\n", " 'b1': array([[-0.01130692],\n", " [-0.23678376],\n", " [-0.01670494],\n", " [ 0.0685398 ]]),\n", " 'W2': array([[ 0.00235001, 0.04562013, 0.02704928, -0.14350081],\n", " [ 0.08828171, -0.05800817, -0.05015653, 0.05909533],\n", " [-0.07316163, 0.02617555, -0.08557956, -0.01875259],\n", " [-0.03734863, -0.0461971 , -0.08164661, -0.00451233],\n", " [ 0.01213278, 0.09259528, -0.05738197, 0.00527031],\n", " [ 0.22073106, 0.03918219, 0.04827134, 0.0433334 ]]),\n", " 'b2': array([[-0.17042917],\n", " [-0.02439081],\n", " [-0.21397038],\n", " [ 0.08613227],\n", " [ 0.17002844],\n", " [-0.05287848]]),\n", " 'W3': array([[ 0.17634779, -0.11216078, -0.11919342, 0.05527319, -0.08159809,\n", " -0.04966468],\n", " [ 0.10862256, -0.09746753, -0.02821358, -0.01172141, 0.03785473,\n", " 0.07321946],\n", " [-0.0103571 , -0.11987063, 0.10100356, 0.28753603, 0.08203126,\n", " 0.05606115],\n", " [-0.03756422, -0.02521043, -0.13896134, 0.06173323, -0.0135787 ,\n", " 0.1287905 ],\n", " [-0.10369944, 0.13643321, -0.03099566, -0.06111171, -0.04831058,\n", " -0.06089837],\n", " [-0.20883353, 0.0639322 , 0.0774304 , 0.12785694, 0.0705276 ,\n", " 0.06559774]]),\n", " 'b3': array([[-0.1678502 ],\n", " [ 0.01831099],\n", " [-0.11332241],\n", " [-0.02790857],\n", " [ 0.13966199],\n", " [ 0.00322194]]),\n", " 'W4': array([[-0.26136608, -0.10015776, -0.0567511 , -0.0225658 , 0.09380238,\n", " 0.08367841],\n", " [ 0.08121485, 0.0232307 , -0.02951077, -0.0361676 , 0.04321151,\n", " 0.09339585],\n", " [ 0.15526339, 0.00936234, 0.02948258, 0.14854308, -0.10868852,\n", " 0.08211628],\n", " [-0.07879492, 0.15938117, 0.14059044, 0.16447566, 0.15415987,\n", " 0.08406076]]),\n", " 'b4': array([[-0.10230944],\n", " [ 0.04947723],\n", " [ 0.08957326],\n", " [ 0.0477352 ]]),\n", " 'W5': array([[-0.01145305, 0.01568974, 0.03875967, -0.10262266]]),\n", " 'b5': array([[0.06791429]])}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "execution_count": 7 } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.7" } }, "nbformat": 4, "nbformat_minor": 5 }