From 8bf116cbdee9d5bbaadcd1165fd0f427b763b244 Mon Sep 17 00:00:00 2001 From: fada Date: Thu, 12 Jun 2025 00:14:11 +0800 Subject: [PATCH] 1. init --- 04.ipynb | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- main.py | 4 ++ 2 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 main.py diff --git a/04.ipynb b/04.ipynb index ef0fe86..dad047e 100644 --- a/04.ipynb +++ b/04.ipynb @@ -2,16 +2,127 @@ "cells": [ { "cell_type": "code", - "execution_count": null, "id": "initial_id", "metadata": { - "collapsed": true + "collapsed": true, + "ExecuteTime": { + "end_time": "2025-06-11T15:26:24.930498Z", + "start_time": "2025-06-11T15:26:24.925343Z" + } }, - "outputs": [], "source": [ "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": { diff --git a/main.py b/main.py new file mode 100644 index 0000000..0a8866d --- /dev/null +++ b/main.py @@ -0,0 +1,4 @@ +import torch +import numpy as np + +torch.__version__ \ No newline at end of file