Update 'sec4.2.ipynb'

This commit is contained in:
TerenceLiu 2023-02-20 14:49:29 +08:00
parent 6f030b73cd
commit c3e5e5e6eb
1 changed files with 35 additions and 188 deletions

View File

@ -2,218 +2,65 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"id": "011c5f34-be40-4f0b-8146-73f66ba18672", "id": "011c5f34-be40-4f0b-8146-73f66ba18672",
"metadata": {}, "metadata": {
"tags": []
},
"outputs": [], "outputs": [],
"source": [ "source": [
"from algorithm.optimization.common import *\n", "from algorithm.optimization.common import *\n",
"from algorithm.optimization.gradient import *" "from algorithm.optimization.gradient import *\n",
"from IPython.display import IFrame"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": null,
"id": "a4827f0c", "id": "7a1ba495-73ac-4710-bab7-edb429ab9628",
"metadata": {}, "metadata": {
"outputs": [ "tags": []
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3879a8b297fa4dffacb2dc6aba04dc5f",
"version_major": 2,
"version_minor": 0
}, },
"text/plain": [ "outputs": [],
"VBox(children=(HBox(children=(VBox(children=(Text(value='sin(x) + sin((10.0 / 3.0) * x)', description='Express…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8c7609027a8d4f56a8492fda092401b6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1fa7e58deae44726bb5868c3454b3c4a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<algorithm.optimization.gradient.gd_1d at 0x24697aae548>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"gd_1d(environ=\"jupyterlab\")" "IFrame(\"https://ufal.mff.cuni.cz/~straka/courses/npfl129/2223/demos/mnist_web.html\", width=1080, height=800)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"id": "a4827f0c",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"gd1d(environ=\"jupyterlab\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f28bd167", "id": "f28bd167",
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "subslide" "slide_type": "subslide"
}
}, },
"outputs": [ "tags": []
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3e3eda22a6eb43bc836431a749170cc1",
"version_major": 2,
"version_minor": 0
}, },
"text/plain": [ "outputs": [],
"VBox(children=(HBox(children=(Dropdown(options=(('(1 - 8 * x1 + 7 * x1**2 - (7/3) * x1**3 + (1/4) * x1**4) * x…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "94b62fa1c4c24a359419e7b9087c63a4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4eccbd5a5fd94a7ab11f561e2ba2d247",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2c3d255d1b984fc38f8f3da9ebb4fd38",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<algorithm.optimization.gradient.gd2d at 0x24697af6248>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"gd2d(environ=\"jupyterlab\")" "gd2d(environ=\"jupyterlab\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": null,
"id": "d5651fc9-3fcd-4e91-8d3c-04897da1ea02", "id": "d5651fc9-3fcd-4e91-8d3c-04897da1ea02",
"metadata": {}, "metadata": {
"outputs": [ "tags": []
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6bf4e3de13db419883591537fc222a36",
"version_major": 2,
"version_minor": 0
}, },
"text/plain": [ "outputs": [],
"VBox(children=(HBox(children=(Dropdown(options=(('(1 - 8 * x1 + 7 * x1**2 - (7/3) * x1**3 + (1/4) * x1**4) * x…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7aea5da550ff487da02c07710a3a5078",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7b8c6c9cbceb4eeaa1e1187cb01476af",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Output()"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<algorithm.optimization.gradient.gd2d_compete at 0x24697e44788>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"gd2d_compete(environ=\"jupyterlab\")" "gd2d_compete(environ=\"jupyterlab\")"
] ]
@ -244,7 +91,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.13" "version": "3.10.9"
} }
}, },
"nbformat": 4, "nbformat": 4,