mirror of
https://github.com/frankwxu/AI4DigitalForensics.git
synced 2026-04-10 11:23:42 +00:00
add cyfi445 labs
This commit is contained in:
@@ -26,7 +26,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 15,
|
||||||
"id": "5eedde1f",
|
"id": "5eedde1f",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 16,
|
||||||
"id": "c6fcc605",
|
"id": "c6fcc605",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 17,
|
||||||
"id": "a899d7d6",
|
"id": "a899d7d6",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -188,14 +188,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 18,
|
||||||
"id": "84f1138d",
|
"id": "84f1138d",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"application/vnd.jupyter.widget-view+json": {
|
"application/vnd.jupyter.widget-view+json": {
|
||||||
"model_id": "1fc20f3c750c45d6a8c7eb4998fd12ab",
|
"model_id": "004cf80f023f4aff865aa2c9188ae4b2",
|
||||||
"version_major": 2,
|
"version_major": 2,
|
||||||
"version_minor": 0
|
"version_minor": 0
|
||||||
},
|
},
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
"<function __main__.plot_neuron(w=2.0, b=-10.0)>"
|
"<function __main__.plot_neuron(w=2.0, b=-10.0)>"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 4,
|
"execution_count": 18,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 5,
|
"execution_count": 19,
|
||||||
"id": "e347fec9",
|
"id": "e347fec9",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -354,7 +354,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 6,
|
"execution_count": 20,
|
||||||
"id": "326de3e1",
|
"id": "326de3e1",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -362,16 +362,16 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Epoch [10000/40000], Loss: 0.1531\n",
|
"Epoch [10000/40000], Loss: 0.1530\n",
|
||||||
"Epoch [20000/40000], Loss: 0.1125\n",
|
"Epoch [20000/40000], Loss: 0.1125\n",
|
||||||
"Epoch [30000/40000], Loss: 0.0943\n",
|
"Epoch [30000/40000], Loss: 0.0942\n",
|
||||||
"Epoch [40000/40000], Loss: 0.0831\n",
|
"Epoch [40000/40000], Loss: 0.0831\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Model Parameters: w = 1.8303, b = -9.8934\n",
|
"Model Parameters: w = 1.8304, b = -9.8944\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Tumor Sizes: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n",
|
"Tumor Sizes: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n",
|
||||||
"True Labels: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n",
|
"True Labels: [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n",
|
||||||
"Predicted Probabilities: [0.0003148354298900813, 0.0019599415827542543, 0.012097183614969254, 0.07093961536884308, 0.3225499391555786, 0.7480406165122986, 0.9487512111663818, 0.9914116859436035, 0.998612642288208, 0.9997772574424744]\n",
|
"Predicted Probabilities: [0.00031458670855499804, 0.0019587331917136908, 0.012091861106455326, 0.0709216371178627, 0.32252806425094604, 0.7480542063713074, 0.9487631320953369, 0.9914152026176453, 0.9986134767532349, 0.9997773766517639]\n",
|
||||||
"Predicted Labels: [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0]\n"
|
"Predicted Labels: [0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0]\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -415,6 +415,8 @@
|
|||||||
" outputs = model(X_tensor)\n",
|
" outputs = model(X_tensor)\n",
|
||||||
" loss = criterion(outputs, Y_tensor)\n",
|
" loss = criterion(outputs, Y_tensor)\n",
|
||||||
" \n",
|
" \n",
|
||||||
|
" # print(loss.grad_fn) # <PowBackward0 object>\n",
|
||||||
|
" \n",
|
||||||
" # Backward pass and optimization\n",
|
" # Backward pass and optimization\n",
|
||||||
" optimizer.zero_grad()\n",
|
" optimizer.zero_grad()\n",
|
||||||
" loss.backward()\n",
|
" loss.backward()\n",
|
||||||
@@ -447,7 +449,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 7,
|
"execution_count": 21,
|
||||||
"id": "de9d2f63",
|
"id": "de9d2f63",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@@ -458,7 +460,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"Unseen Tumor Size: 5.5\n",
|
"Unseen Tumor Size: 5.5\n",
|
||||||
"Predicted Probability of Malignancy: 0.5432\n",
|
"Predicted Probability of Malignancy: 0.5432\n",
|
||||||
"Predicted Label: 1.0 (Malignant)\n"
|
"Predicted Label: True (Malignant)\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -468,7 +470,7 @@
|
|||||||
"model.eval()\n",
|
"model.eval()\n",
|
||||||
"with torch.no_grad():\n",
|
"with torch.no_grad():\n",
|
||||||
" prediction = model(unseen_input)\n",
|
" prediction = model(unseen_input)\n",
|
||||||
" predicted_label = (prediction >= 0.5).float()\n",
|
" predicted_label = prediction >= 0.5\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# Print results\n",
|
"# Print results\n",
|
||||||
"print(f\"\\nUnseen Tumor Size: {unseen_input.item()}\")\n",
|
"print(f\"\\nUnseen Tumor Size: {unseen_input.item()}\")\n",
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user