1. init
This commit is contained in:
119
04.ipynb
119
04.ipynb
@ -2,16 +2,127 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
|
||||||
"id": "initial_id",
|
"id": "initial_id",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"collapsed": true
|
"collapsed": true,
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-06-11T15:26:24.930498Z",
|
||||||
|
"start_time": "2025-06-11T15:26:24.925343Z"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import torch\n",
|
"import torch\n",
|
||||||
"\n"
|
"import numpy as np\n",
|
||||||
|
"\n",
|
||||||
|
"torch.__version__"
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"'2.2.1'"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-06-11T15:30:24.600025Z",
|
||||||
|
"start_time": "2025-06-11T15:30:24.594879Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cell_type": "code",
|
||||||
|
"source": [
|
||||||
|
"a = torch.tensor(1)\n",
|
||||||
|
"b = a.item()\n",
|
||||||
|
"print(a)\n",
|
||||||
|
"print(b)"
|
||||||
|
],
|
||||||
|
"id": "ec73dc2f6feeece4",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"tensor(1)\n",
|
||||||
|
"1\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 11
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-06-11T15:30:58.264992Z",
|
||||||
|
"start_time": "2025-06-11T15:30:58.260725Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cell_type": "code",
|
||||||
|
"source": [
|
||||||
|
"a = [1, 2, 3]\n",
|
||||||
|
"b = torch.tensor(a)\n",
|
||||||
|
"c = b.numpy().tolist()\n",
|
||||||
|
"print(c)"
|
||||||
|
],
|
||||||
|
"id": "6c3e0063d8fcc299",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"[1, 2, 3]\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 13
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"ExecuteTime": {
|
||||||
|
"end_time": "2025-06-11T15:33:27.945096Z",
|
||||||
|
"start_time": "2025-06-11T15:33:27.939574Z"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"cell_type": "code",
|
||||||
|
"source": [
|
||||||
|
"a = torch.zeros(2, 3, 5)\n",
|
||||||
|
"print(a.shape)\n",
|
||||||
|
"\n",
|
||||||
|
"print(a.size())\n",
|
||||||
|
"\n",
|
||||||
|
"print(a.numel())\n"
|
||||||
|
],
|
||||||
|
"id": "d04c60d3f01351c2",
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"torch.Size([2, 3, 5])\n",
|
||||||
|
"torch.Size([2, 3, 5])\n",
|
||||||
|
"30\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"execution_count": 18
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"metadata": {},
|
||||||
|
"cell_type": "code",
|
||||||
|
"outputs": [],
|
||||||
|
"execution_count": null,
|
||||||
|
"source": [
|
||||||
|
"x = torch.rand(2, 3, 5)\n",
|
||||||
|
"print(x.shape)"
|
||||||
|
],
|
||||||
|
"id": "774add1439f9aa94"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|||||||
Reference in New Issue
Block a user