backup
This commit is contained in:
parent
b4ba0f4aaa
commit
da2fbceceb
@ -1,4 +1,5 @@
|
||||
ROOT_DIR=/home/wmi/repos/stud-ai
|
||||
DATA_DIR=/mnt/gpudata1/studai/datasets
|
||||
JUPYTER_PORT=42065
|
||||
JUPYTER_TOKEN=some_token
|
||||
JUPYTER_DIR=/jupyter
|
||||
|
@ -6,11 +6,13 @@ services:
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: jupyter.Dockerfile
|
||||
shm_size: '2gb'
|
||||
env_file: ./.env
|
||||
ports:
|
||||
- ${JUPYTER_PORT}:${JUPYTER_PORT}
|
||||
volumes:
|
||||
- ${ROOT_DIR}:/jupyter
|
||||
- ${DATA_DIR}:/jupyter/datasets
|
||||
environment:
|
||||
- NVIDIA_VISIBLE_DEVICES=all
|
||||
command:
|
||||
@ -24,6 +26,8 @@ services:
|
||||
'--NotebookApp.token=${JUPYTER_TOKEN}'
|
||||
]
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: any
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
|
@ -2,7 +2,8 @@ FROM nvidia/cuda:10.2-runtime AS jupyter-base
|
||||
WORKDIR /
|
||||
RUN apt update && apt install -y --no-install-recommends \
|
||||
git build-essential \
|
||||
python3-dev python3-pip python3-setuptools
|
||||
python3-dev python3-pip python3-setuptools \
|
||||
imagemagick
|
||||
RUN pip3 -q install pip --upgrade
|
||||
|
||||
RUN pip3 install jupyter numpy pandas torch torchvision tensorboardX
|
||||
|
@ -27,8 +27,7 @@
|
||||
"Getting Started\n",
|
||||
"---------------\n",
|
||||
"\n",
|
||||
"Tensors\n",
|
||||
"^^^^^^^\n",
|
||||
"## Tensors\n",
|
||||
"\n",
|
||||
"Tensors are similar to NumPy’s ndarrays, with the addition being that\n",
|
||||
"Tensors can also be used on a GPU to accelerate computing.\n",
|
||||
@ -68,18 +67,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[-1.7501e-10, 4.5822e-41, -1.7501e-10],\n",
|
||||
" [ 4.5822e-41, -9.8701e-38, 4.5822e-41],\n",
|
||||
" [-9.8892e-38, 4.5822e-41, -9.8700e-38],\n",
|
||||
" [ 4.5822e-41, -9.8702e-38, 4.5822e-41],\n",
|
||||
" [-9.8701e-38, 4.5822e-41, -9.8703e-38]])\n"
|
||||
"tensor([[6.3417e-36, 0.0000e+00, 6.3419e-36],\n",
|
||||
" [0.0000e+00, 1.1210e-43, 0.0000e+00],\n",
|
||||
" [1.5695e-43, 0.0000e+00, 0.0000e+00],\n",
|
||||
" [0.0000e+00, 6.3917e+04, 4.5559e-41],\n",
|
||||
" [3.1636e+15, 0.0000e+00, 1.8077e-43]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -98,18 +97,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 22,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[0.8525, 0.7922, 0.2553],\n",
|
||||
" [0.2792, 0.6800, 0.7858],\n",
|
||||
" [0.4438, 0.6987, 0.0985],\n",
|
||||
" [0.7342, 0.1807, 0.5665],\n",
|
||||
" [0.0847, 0.8206, 0.6820]])\n"
|
||||
"tensor([[0.6721, 0.7974, 0.8837],\n",
|
||||
" [0.6526, 0.6741, 0.4159],\n",
|
||||
" [0.7239, 0.8301, 0.9470],\n",
|
||||
" [0.7420, 0.4967, 0.1845],\n",
|
||||
" [0.2672, 0.3700, 0.3739]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -128,7 +127,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 23,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -186,7 +185,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 27,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -198,11 +197,11 @@
|
||||
" [1., 1., 1.],\n",
|
||||
" [1., 1., 1.],\n",
|
||||
" [1., 1., 1.]], dtype=torch.float64)\n",
|
||||
"tensor([[ 1.0131, 1.4739, -0.2482],\n",
|
||||
" [-1.8965, -1.6178, 0.4807],\n",
|
||||
" [ 0.1839, 0.3258, -0.6664],\n",
|
||||
" [-0.9516, -1.7041, 1.1624],\n",
|
||||
" [-0.4448, -1.1328, -0.5092]])\n"
|
||||
"tensor([[ 1.8133, -2.0788, 0.1688],\n",
|
||||
" [-0.8336, -0.9961, -0.2995],\n",
|
||||
" [ 1.5661, -0.0205, -0.1414],\n",
|
||||
" [-2.0433, 0.0211, 2.0895],\n",
|
||||
" [ 0.2971, -0.2518, 0.5030]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -245,8 +244,8 @@
|
||||
"source": [
|
||||
"<div class=\"alert alert-info\"><h4>Note</h4><p>``torch.Size`` is in fact a tuple, so it supports all tuple operations.</p></div>\n",
|
||||
"\n",
|
||||
"Operations\n",
|
||||
"^^^^^^^^^^\n",
|
||||
"## Operations\n",
|
||||
"\n",
|
||||
"There are multiple syntaxes for operations. In the following\n",
|
||||
"example, we will take a look at the addition operation.\n",
|
||||
"\n",
|
||||
@ -256,18 +255,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 28,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[ 1.6789, 1.8680, -0.0202],\n",
|
||||
" [-1.2243, -1.5905, 0.8047],\n",
|
||||
" [ 0.5959, 0.7308, -0.1883],\n",
|
||||
" [-0.6292, -0.7051, 1.8369],\n",
|
||||
" [-0.0381, -0.2377, -0.1590]])\n"
|
||||
"tensor([[ 2.4870, -1.1092, 0.2733],\n",
|
||||
" [-0.5093, -0.1695, 0.1134],\n",
|
||||
" [ 2.4207, 0.2844, 0.7987],\n",
|
||||
" [-1.3298, 0.4374, 2.0926],\n",
|
||||
" [ 1.1103, 0.2101, 1.2337]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -293,11 +292,11 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[ 1.6789, 1.8680, -0.0202],\n",
|
||||
" [-1.2243, -1.5905, 0.8047],\n",
|
||||
" [ 0.5959, 0.7308, -0.1883],\n",
|
||||
" [-0.6292, -0.7051, 1.8369],\n",
|
||||
" [-0.0381, -0.2377, -0.1590]])\n"
|
||||
"tensor([[ 0.0166, 1.8655, 0.2933],\n",
|
||||
" [ 3.2162, 0.1241, 0.9112],\n",
|
||||
" [ 1.4397, 0.8543, 0.4838],\n",
|
||||
" [ 0.6985, 0.5795, 0.2113],\n",
|
||||
" [ 0.7467, -0.7956, 0.6495]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -315,18 +314,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 29,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[ 1.6789, 1.8680, -0.0202],\n",
|
||||
" [-1.2243, -1.5905, 0.8047],\n",
|
||||
" [ 0.5959, 0.7308, -0.1883],\n",
|
||||
" [-0.6292, -0.7051, 1.8369],\n",
|
||||
" [-0.0381, -0.2377, -0.1590]])\n"
|
||||
"tensor([[ 2.4870, -1.1092, 0.2733],\n",
|
||||
" [-0.5093, -0.1695, 0.1134],\n",
|
||||
" [ 2.4207, 0.2844, 0.7987],\n",
|
||||
" [-1.3298, 0.4374, 2.0926],\n",
|
||||
" [ 1.1103, 0.2101, 1.2337]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -353,11 +352,11 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[ 1.6789, 1.8680, -0.0202],\n",
|
||||
" [-1.2243, -1.5905, 0.8047],\n",
|
||||
" [ 0.5959, 0.7308, -0.1883],\n",
|
||||
" [-0.6292, -0.7051, 1.8369],\n",
|
||||
" [-0.0381, -0.2377, -0.1590]])\n"
|
||||
"tensor([[ 0.0166, 1.8655, 0.2933],\n",
|
||||
" [ 3.2162, 0.1241, 0.9112],\n",
|
||||
" [ 1.4397, 0.8543, 0.4838],\n",
|
||||
" [ 0.6985, 0.5795, 0.2113],\n",
|
||||
" [ 0.7467, -0.7956, 0.6495]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -387,7 +386,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([ 1.4739, -1.6178, 0.3258, -1.7041, -1.1328])\n"
|
||||
"tensor([ 1.3796, -0.6919, 0.7494, -0.1942, -1.0191])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -405,7 +404,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"execution_count": 36,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -441,8 +440,8 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([-0.8622])\n",
|
||||
"-0.8622472882270813\n"
|
||||
"tensor([-0.0506])\n",
|
||||
"-0.05061284825205803\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -473,8 +472,8 @@
|
||||
"locations (if the Torch Tensor is on CPU), and changing one will change\n",
|
||||
"the other.\n",
|
||||
"\n",
|
||||
"Converting a Torch Tensor to a NumPy Array\n",
|
||||
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
|
||||
"## Converting a Torch Tensor to a NumPy Array\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
@ -590,37 +589,22 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 37,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"1.7.0\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"/usr/local/lib/python3.6/dist-packages/torch/cuda/__init__.py:81: UserWarning: \n",
|
||||
" Found GPU0 GeForce GTX 760 which is of cuda capability 3.0.\n",
|
||||
" PyTorch no longer supports this GPU because it is too old.\n",
|
||||
" The minimum cuda capability that we support is 3.5.\n",
|
||||
" \n",
|
||||
" warnings.warn(old_gpu_warn % (d, name, major, capability[1]))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "RuntimeError",
|
||||
"evalue": "CUDA error: no kernel image is available for execution on the device",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)",
|
||||
"\u001b[0;32m<ipython-input-20-9fca8bb14c5b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcuda\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_available\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mdevice\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cuda\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# a CUDA device object\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0my\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtorch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mones_like\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdevice\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# directly create a tensor on GPU\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdevice\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# or just use strings ``.to(\"cuda\")``\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0mz\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||
"\u001b[0;31mRuntimeError\u001b[0m: CUDA error: no kernel image is available for execution on the device"
|
||||
"1.7.0\n",
|
||||
"tensor([[ 1.3566, 1.3653, 1.4052, -0.1960],\n",
|
||||
" [ 1.6845, 0.8119, 1.1873, -0.4534],\n",
|
||||
" [ 1.6096, -1.4654, 1.7330, 2.0145],\n",
|
||||
" [ 0.6571, 2.4976, 2.0423, 0.8646]], device='cuda:0')\n",
|
||||
"tensor([[ 1.3566, 1.3653, 1.4052, -0.1960],\n",
|
||||
" [ 1.6845, 0.8119, 1.1873, -0.4534],\n",
|
||||
" [ 1.6096, -1.4654, 1.7330, 2.0145],\n",
|
||||
" [ 0.6571, 2.4976, 2.0423, 0.8646]], dtype=torch.float64)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -66,7 +66,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -83,18 +83,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[1., 1.],\n",
|
||||
" [1., 1.]], requires_grad=True)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = torch.ones(2, 2, requires_grad=True)\n",
|
||||
"print(x)"
|
||||
@ -110,18 +101,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[3., 3.],\n",
|
||||
" [3., 3.]], grad_fn=<AddBackward0>)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"y = x + 2\n",
|
||||
"print(y)"
|
||||
@ -137,17 +119,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<AddBackward0 object at 0x7f0d183e5160>\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(y.grad_fn)"
|
||||
]
|
||||
@ -162,18 +136,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[27., 27.],\n",
|
||||
" [27., 27.]], grad_fn=<MulBackward0>) tensor(27., grad_fn=<MeanBackward0>)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"z = y * y * 3\n",
|
||||
"out = z.mean()\n",
|
||||
@ -192,19 +157,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"False\n",
|
||||
"True\n",
|
||||
"<SumBackward0 object at 0x7f0cc743b438>\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"a = torch.randn(2, 2)\n",
|
||||
"a = ((a * 3) / (a - 1))\n",
|
||||
@ -229,7 +184,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -247,18 +202,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[4.5000, 4.5000],\n",
|
||||
" [4.5000, 4.5000]])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(x.grad)"
|
||||
]
|
||||
@ -334,17 +280,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([1688.6201, -110.9400, 181.5985], grad_fn=<MulBackward0>)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x = torch.randn(3, requires_grad=True)\n",
|
||||
"\n",
|
||||
@ -368,17 +306,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([1.0240e+02, 1.0240e+03, 1.0240e-01])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"v = torch.tensor([0.1, 1.0, 0.0001], dtype=torch.float)\n",
|
||||
"y.backward(v)\n",
|
||||
@ -398,19 +328,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"True\n",
|
||||
"True\n",
|
||||
"False\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(x.requires_grad)\n",
|
||||
"print((x ** 2).requires_grad)\n",
|
||||
@ -430,19 +350,9 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"True\n",
|
||||
"False\n",
|
||||
"tensor(True)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(x.requires_grad)\n",
|
||||
"y = x.detach()\n",
|
||||
|
@ -166,7 +166,7 @@
|
||||
"\n",
|
||||
"![image-6.png](attachment:image-6.png)\n",
|
||||
"\n",
|
||||
"> LeNet is a convolutional neural network structure proposed by Yann LeCun et al. in **1989**. In general, LeNet refers to lenet-5 and is a simple convolutional neural network. Convolutional neural networks are a kind of feed-forward neural network whose artificial neurons can respond to a part of the surrounding cells in the coverage range and perform well in large-scale image processing. [Wikipedia](https://en.wikipedia.org/wiki/LeNet)\n",
|
||||
"> LeNet is a convolutional neural network structure proposed by Yann LeCun et al. in **1998**. In general, LeNet refers to lenet-5 and is a simple convolutional neural network. Convolutional neural networks are a kind of feed-forward neural network whose artificial neurons can respond to a part of the surrounding cells in the coverage range and perform well in large-scale image processing. [Wikipedia](https://en.wikipedia.org/wiki/LeNet)\n",
|
||||
"\n",
|
||||
"It is a simple feed-forward network. It takes the input, feeds it\n",
|
||||
"through several layers one after the other, and then finally gives the\n",
|
||||
@ -278,7 +278,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 3,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -308,7 +308,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -349,7 +349,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 20,
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -405,7 +405,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -434,7 +434,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 22,
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -463,7 +463,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"execution_count": 8,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -492,15 +492,15 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([[-0.0187, -0.0279, -0.0972, -0.0216, 0.0167, 0.2310, -0.1081, -0.0525,\n",
|
||||
" 0.0611, 0.0367]], grad_fn=<AddmmBackward>)\n"
|
||||
"tensor([[-0.0400, -0.0896, 0.0977, 0.0221, 0.0746, 0.0415, 0.0352, -0.1424,\n",
|
||||
" 0.0262, -0.0233]], grad_fn=<AddmmBackward>)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -520,7 +520,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -584,14 +584,14 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 30,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor(0.8534, grad_fn=<MseLossBackward>)\n"
|
||||
"tensor(1.5053, grad_fn=<MseLossBackward>)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -629,16 +629,16 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"<MseLossBackward object at 0x7f78386ee438>\n",
|
||||
"<AddmmBackward object at 0x7f78386ee390>\n",
|
||||
"<AccumulateGrad object at 0x7f78386ee438>\n"
|
||||
"<MseLossBackward object at 0x7f18dc4d2518>\n",
|
||||
"<AddmmBackward object at 0x7f18dc4d2ef0>\n",
|
||||
"<AccumulateGrad object at 0x7f18dc4d2518>\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -666,7 +666,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"execution_count": 13,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -676,7 +676,7 @@
|
||||
"conv1.bias.grad before backward\n",
|
||||
"tensor([0., 0., 0., 0., 0., 0.])\n",
|
||||
"conv1.bias.grad after backward\n",
|
||||
"tensor([ 0.0008, 0.0015, 0.0122, 0.0016, 0.0040, -0.0035])\n"
|
||||
"tensor([ 0.0006, 0.0030, -0.0049, -0.0047, -0.0134, -0.0125])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@ -732,9 +732,18 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"execution_count": 14,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"tensor([0., 0., 0., 0., 0., 0.])\n",
|
||||
"tensor([ 0.0006, 0.0030, -0.0049, -0.0047, -0.0134, -0.0125])\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import torch.optim as optim\n",
|
||||
"\n",
|
||||
@ -743,10 +752,12 @@
|
||||
"\n",
|
||||
"# in your training loop:\n",
|
||||
"optimizer.zero_grad() # zero the gradient buffers\n",
|
||||
"print(net.conv1.bias.grad)\n",
|
||||
"output = net(input)\n",
|
||||
"loss = criterion(output, target)\n",
|
||||
"loss.backward()\n",
|
||||
"optimizer.step() # Does the update"
|
||||
"optimizer.step() # Does the update\n",
|
||||
"print(net.conv1.bias.grad)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
File diff suppressed because one or more lines are too long
494
1-intro/5-allegro-data.ipynb
Normal file
494
1-intro/5-allegro-data.ipynb
Normal file
File diff suppressed because one or more lines are too long
383
1-intro/6-one_image.ipynb
Normal file
383
1-intro/6-one_image.ipynb
Normal file
File diff suppressed because one or more lines are too long
393
1-intro/7-colours_nn.ipynb
Normal file
393
1-intro/7-colours_nn.ipynb
Normal file
File diff suppressed because one or more lines are too long
32
1-intro/Damskie-mini_generator.ipynb
Normal file
32
1-intro/Damskie-mini_generator.ipynb
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"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.6.9"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
BIN
1-intro/cifar_net.pth
Normal file
BIN
1-intro/cifar_net.pth
Normal file
Binary file not shown.
BIN
1-intro/class-col.pkl
Normal file
BIN
1-intro/class-col.pkl
Normal file
Binary file not shown.
BIN
1-intro/class-shoe.pkl
Normal file
BIN
1-intro/class-shoe.pkl
Normal file
Binary file not shown.
BIN
1-intro/nn-col-state-dict.pth
Normal file
BIN
1-intro/nn-col-state-dict.pth
Normal file
Binary file not shown.
BIN
1-intro/nn-state-dict.pth
Normal file
BIN
1-intro/nn-state-dict.pth
Normal file
Binary file not shown.
BIN
1-intro/nn.pth
Normal file
BIN
1-intro/nn.pth
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user