{"id":26160044,"url":"https://github.com/a-r007/loss-calculation","last_synced_at":"2026-03-10T17:02:51.379Z","repository":{"id":281721969,"uuid":"946207721","full_name":"A-R007/Loss-Calculation","owner":"A-R007","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-10T19:50:46.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T20:34:13.401Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/A-R007.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":"2025-03-10T19:28:28.000Z","updated_at":"2025-03-10T19:50:49.000Z","dependencies_parsed_at":"2025-03-10T20:44:16.702Z","dependency_job_id":null,"html_url":"https://github.com/A-R007/Loss-Calculation","commit_stats":null,"previous_names":["a-r007/loss-calculation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/A-R007/Loss-Calculation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A-R007%2FLoss-Calculation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A-R007%2FLoss-Calculation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A-R007%2FLoss-Calculation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A-R007%2FLoss-Calculation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/A-R007","download_url":"https://codeload.github.com/A-R007/Loss-Calculation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/A-R007%2FLoss-Calculation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30343748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T15:55:29.454Z","status":"ssl_error","status_checked_at":"2026-03-10T15:54:58.440Z","response_time":106,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2025-03-11T11:58:42.427Z","updated_at":"2026-03-10T17:02:51.307Z","avatar_url":"https://github.com/A-R007.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# CH-1 QN1\n\n## Backpropagation Weight Update for a Single Neuron\n\n### Given Data:\n- **Inputs**: \\( x = [1,2] \\)\n- **Weights**: \\( W = [0.4, -0.2] \\)\n- **Bias**: \\( b = 0.1 \\)\n- **Predicted Output**: \\( y' = 0.6 \\)\n- **True Output**: \\( y = 0.8 \\)\n- **Learning Rate**: \\( \\eta = 0.1 \\)\n- **Activation Function Derivative**: \\( y'(1 - y') = 0.24 \\)\n- **Loss Function**: Mean Squared Error (MSE)\n\n### 1. Error Calculation\nThe error is the difference between the true output \\( y \\) and the predicted output \\( y' \\):\n\n$$\n\\text{Error} = y - y' = 0.8 - 0.6 = 0.2\n$$\n\n### 2. Gradient of Loss with Respect to Output\nThe MSE loss function is:\n\n$$\nL = \\frac{1}{2} (y - y')^2\n$$\n\nThe derivative of the loss function with respect to the output \\( y' \\) is:\n\n$$\n\\frac{\\partial L}{\\partial y'} = (y' - y) = 0.6 - 0.8 = -0.2\n$$\n\n### 3. Gradient of Loss with Respect to Weights\nUsing the chain rule:\n\n$$\n\\frac{\\partial L}{\\partial W_i} = \\frac{\\partial L}{\\partial y'} \\times \\frac{\\partial y'}{\\partial W_i}\n$$\n\nSince:\n\n$$\n\\frac{\\partial y'}{\\partial W_i} = x_i \\times y'(1 - y')\n$$\n\nNow, calculating for each weight:\n\n#### For \\( W_1 \\) (corresponding to \\( x_1 = 1 \\)):\n\n$$\n\\frac{\\partial L}{\\partial W_1} = (-0.2) \\times (0.24) \\times (1) = -0.048\n$$\n\n#### For \\( W_2 \\) (corresponding to \\( x_2 = 2 \\)):\n\n$$\n\\frac{\\partial L}{\\partial W_2} = (-0.2) \\times (0.24) \\times (2) = -0.096\n$$\n\n### 4. Weight Updates\nUsing the weight update formula:\n\n$$\nW_i = W_i - \\eta \\times \\frac{\\partial L}{\\partial W_i}\n$$\n\n#### Updated Weights:\n- **For \\( W_1 \\)**:\n\n$$\nW_1 = 0.4 - 0.1 \\times (-0.048) = 0.4 + 0.0048 = 0.4048\n$$\n\n- **For \\( W_2 \\)**:\n\n$$\nW_2 = -0.2 - 0.1 \\times (-0.096) = -0.2 + 0.0096 = -0.1904\n$$\n\n### 5. Final Answer - Updated Weights:\n\n$$\nW = [0.4048, -0.1904]\n$$\n\n---\n\n# CH-1 QN3\n\n## Compute the Final Probability using Sigmoid Activation Function\n\n### Given Data:\n- **Input Temperature** \\( x = 2^\\circ C \\)\n- **Learned Weight** \\( w = 0.5 \\) (influence of temperature on decision)\n- **Bias** \\( b = 1 \\) (accounts for external factors like time of day or user preferences)\n\n### Step-by-Step Calculation\n\n#### 1. Compute \\( z \\):\n\n$$\nz = wx + b\n$$\n\nSubstituting the values:\n\n$$\nz = (0.5 \\times 2) + 1\n$$\n\n$$\nz = 1 + 1 = 2\n$$\n\n#### 2. Apply the Sigmoid Function:\n\nThe formula for the sigmoid function is:\n\n$$\n\\sigma(z) = \\frac{1}{1 + e^{-z}}\n$$\n\nSubstituting \\( z = 2 \\):\n\n$$\n\\sigma(2) = \\frac{1}{1 + e^{-2}}\n$$\n\n#### 3. Calculate the Final Probability:\n\nApproximating \\( e^{-2} \\approx 0.1353 \\):\n\n$$\n\\sigma(2) = \\frac{1}{1 + 0.1353}\n$$\n\n$$\n\\sigma(2) = \\frac{1}{1.1353}\n$$\n\n$$\n\\sigma(2) \\approx 0.8808\n$$\n\n### Final Result\n\nThe final probability of the thermostat turning on is **0.8808** (or **88.08%**).\n\n**Justification:** The sigmoid activation function converts the linear combination of the input temperature, weight, and bias into a probability value between 0 and 1. In this case, given the input temperature of 2°C, the learned weight of 0.5, and the bias of 1, the model predicts a high probability (**88.08%**) of the thermostat turning on.\n\n# CH-1 QN5\n\n## Backpropagation Calculation for Hidden and Output Layers\n\n### Given Data:\n- **Inputs:**\n  - \\( x_1 = 0.10 \\), \\( x_2 = 0.35 \\)\n- **Weights:**\n  - Input to Hidden Layer:\n    - \\( w_1 = 0.15 \\), \\( w_2 = 0.25 \\) (for \\( H1 \\))\n    - \\( w_3 = 0.30 \\), \\( w_4 = 0.35 \\) (for \\( H2 \\))\n  - Hidden to Output Layer:\n    - \\( w_5 = 0.40 \\), \\( w_6 = 0.45 \\) (for \\( y_1 \\))\n    - \\( w_7 = 0.50 \\), \\( w_8 = 0.55 \\) (for \\( y_2 \\))\n- **Bias Values:**\n  - Hidden Layer: \\( b_1 = 0.60 \\), \\( b_2 = 0.60 \\)\n- **Target Values:**\n  - \\( T_1 = 0.01 \\), \\( T_2 = 0.99 \\)\n\n### 1. Compute Hidden Layer Activations\n\nFor each hidden unit:\n\n#### Hidden Neuron \\( H1 \\):\n\n$$ z_{H1} = (x_1 \\times w_1) + (x_2 \\times w_2) + b_1 $$\n\n$$ z_{H1} = (0.10 \\times 0.15) + (0.35 \\times 0.25) + 0.60 $$\n\n$$ z_{H1} = 0.015 + 0.0875 + 0.60 = 0.7025 $$\n\nApplying the sigmoid activation function:\n\n$$ H1 = \\sigma(0.7025) = \\frac{1}{1 + e^{-0.7025}} \\approx 0.6687 $$\n\n#### Hidden Neuron \\( H2 \\):\n\n$$ z_{H2} = (x_1 \\times w_3) + (x_2 \\times w_4) + b_2 $$\n\n$$ z_{H2} = (0.10 \\times 0.30) + (0.35 \\times 0.35) + 0.60 $$\n\n$$ z_{H2} = 0.03 + 0.1225 + 0.60 = 0.7525 $$\n\nApplying the sigmoid activation function:\n\n$$ H2 = \\sigma(0.7525) = \\frac{1}{1 + e^{-0.7525}} \\approx 0.6797 $$\n\n### 2. Compute Output Layer Activations\n\nFor each output neuron:\n\n#### Output Neuron \\( y_1 \\):\n\n$$ z_{y1} = (H1 \\times w_5) + (H2 \\times w_6) $$\n\n$$ z_{y1} = (0.6687 \\times 0.40) + (0.6797 \\times 0.45) $$\n\n$$ z_{y1} = 0.2675 + 0.3059 = 0.5734 $$\n\nApplying the sigmoid activation function:\n\n$$ y_1 = \\sigma(0.5734) = \\frac{1}{1 + e^{-0.5734}} \\approx 0.6395 $$\n\n#### Output Neuron \\( y_2 \\):\n\n$$ z_{y2} = (H1 \\times w_7) + (H2 \\times w_8) $$\n\n$$ z_{y2} = (0.6687 \\times 0.50) + (0.6797 \\times 0.55) $$\n\n$$ z_{y2} = 0.3343 + 0.3738 = 0.7081 $$\n\nApplying the sigmoid activation function:\n\n$$ y_2 = \\sigma(0.7081) = \\frac{1}{1 + e^{-0.7081}} \\approx 0.6699 $$\n\n### 3. Final Values\n- **Hidden Layer Outputs:**\n  - \\( H1 \\approx 0.6687 \\)\n  - \\( H2 \\approx 0.6797 \\)\n- **Output Layer Predictions:**\n  - \\( y_1 \\approx 0.6395 \\)\n  - \\( y_2 \\approx 0.6699 \\)\n\nThese values can now be used for error calculation and backpropagation adjustments.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-r007%2Floss-calculation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-r007%2Floss-calculation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-r007%2Floss-calculation/lists"}