add lecture 13

This commit is contained in:
Frank Xu
2025-05-22 14:55:57 -04:00
parent 16f62d7f82
commit b37b465308
11 changed files with 404 additions and 784 deletions

View File

@@ -3,5 +3,16 @@ pip install scikit-learn
pip install ultralytics pip install ultralytics
pip install ultralytics opencv-python pip install ultralytics opencv-python
pip install transformers pip install transformers
pip install ipykernel
# pip install sentencepiece did not work # pip install sentencepiece did not work
conda install sentencepiece conda install sentencepiece
For AI Agents
- Create a different envirofment: python version 3.11
- installl pytorch
- pip install browser-use
- pip install "browser-use[memory]"
- playwright install chromium --with-deps --no-shell

View File

@@ -10,7 +10,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 69, "execution_count": 30,
"id": "2d8b3880", "id": "2d8b3880",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -69,7 +69,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 70, "execution_count": 31,
"id": "02ff97f3", "id": "02ff97f3",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -134,7 +134,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 71, "execution_count": 32,
"id": "af64b425", "id": "af64b425",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -187,7 +187,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 72, "execution_count": 33,
"id": "c26b1fa2", "id": "c26b1fa2",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -229,7 +229,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 73, "execution_count": 34,
"id": "8d3cb18e", "id": "8d3cb18e",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
@@ -239,7 +239,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 79, "execution_count": 35,
"id": "7e4a9a78", "id": "7e4a9a78",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@@ -281,6 +281,29 @@
"print(f\"Cross-Entropy Loss (One Example): {loss:.4f}\")" "print(f\"Cross-Entropy Loss (One Example): {loss:.4f}\")"
] ]
}, },
{
"cell_type": "code",
"execution_count": 36,
"id": "d4436c0d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Cross-Entropy Loss (One Example): 0.2191\n"
]
}
],
"source": [
"# corss entroy using torch library\n",
"# F.cross_entropy expects: [batch_size, num_classes]\n",
"import torch\n",
"from torch.nn import functional as F\n",
"loss= F.cross_entropy(torch.tensor([logits], dtype=torch.float32), torch.tensor([one_hot_target], dtype=torch.float32))\n",
"print(f\"Cross-Entropy Loss (One Example): {loss:.4f}\")"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "9000b450", "id": "9000b450",
@@ -294,7 +317,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 75, "execution_count": 37,
"id": "4d146b28", "id": "4d146b28",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [

File diff suppressed because one or more lines are too long