-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpytorch
1 lines (1 loc) · 21.4 KB
/
pytorch
1
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[],"dockerImageVersionId":30823,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n for filename in filenames:\n print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:23:57.878975Z","iopub.execute_input":"2024-12-22T15:23:57.879310Z","iopub.status.idle":"2024-12-22T15:23:57.892565Z","shell.execute_reply.started":"2024-12-22T15:23:57.879278Z","shell.execute_reply":"2024-12-22T15:23:57.891689Z"}},"outputs":[],"execution_count":5},{"cell_type":"code","source":"import torch\nprint(torch.__version__)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:23:59.950306Z","iopub.execute_input":"2024-12-22T15:23:59.950579Z","iopub.status.idle":"2024-12-22T15:23:59.955318Z","shell.execute_reply.started":"2024-12-22T15:23:59.950558Z","shell.execute_reply":"2024-12-22T15:23:59.954390Z"}},"outputs":[{"name":"stdout","text":"2.4.1+cu121\n","output_type":"stream"}],"execution_count":6},{"cell_type":"code","source":"if torch.cuda.is_available():\n print(\"GPU\")\n print(f\"using gpu: {torch.cuda.get_device_name(0)}\")\nelse:\n print(\"Not avaiable\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:24:00.975850Z","iopub.execute_input":"2024-12-22T15:24:00.976142Z","iopub.status.idle":"2024-12-22T15:24:00.981195Z","shell.execute_reply.started":"2024-12-22T15:24:00.976098Z","shell.execute_reply":"2024-12-22T15:24:00.980383Z"}},"outputs":[{"name":"stdout","text":"GPU\nusing gpu: Tesla T4\n","output_type":"stream"}],"execution_count":7},{"cell_type":"markdown","source":"# Creating tensors","metadata":{}},{"cell_type":"code","source":"torch.empty(3, 4, 5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:24:02.946031Z","iopub.execute_input":"2024-12-22T15:24:02.946347Z","iopub.status.idle":"2024-12-22T15:24:03.014015Z","shell.execute_reply.started":"2024-12-22T15:24:02.946320Z","shell.execute_reply":"2024-12-22T15:24:03.013355Z"}},"outputs":[{"execution_count":8,"output_type":"execute_result","data":{"text/plain":"tensor([[[6.5467e+01, 3.2908e-41, 1.5835e-42, 3.2908e-41, 0.0000e+00],\n [0.0000e+00, 1.5414e-44, 0.0000e+00, 6.5467e+01, 3.2908e-41],\n [1.5849e-42, 5.6052e-45, 0.0000e+00, 0.0000e+00, 1.5414e-44],\n [0.0000e+00, 6.5467e+01, 3.2908e-41, 1.5863e-42, 3.2908e-41]],\n\n [[0.0000e+00, 0.0000e+00, 1.5414e-44, 0.0000e+00, 6.5468e+01],\n [3.2908e-41, 1.5877e-42, 3.2908e-41, 0.0000e+00, 0.0000e+00],\n [1.5414e-44, 0.0000e+00, 6.5468e+01, 3.2908e-41, 1.5891e-42],\n [3.2908e-41, 0.0000e+00, 0.0000e+00, 1.5414e-44, 0.0000e+00]],\n\n [[6.5468e+01, 3.2908e-41, 1.5905e-42, 3.2908e-41, 0.0000e+00],\n [0.0000e+00, 1.5414e-44, 0.0000e+00, 6.5468e+01, 3.2908e-41],\n [1.5961e-42, 3.2908e-41, 0.0000e+00, 0.0000e+00, 1.5414e-44],\n [0.0000e+00, 6.5469e+01, 3.2908e-41, 1.5947e-42, 3.2908e-41]]])"},"metadata":{}}],"execution_count":8},{"cell_type":"code","source":"type(torch.zeros(2,4))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:24:45.595751Z","iopub.execute_input":"2024-12-22T15:24:45.596032Z","iopub.status.idle":"2024-12-22T15:24:45.601405Z","shell.execute_reply.started":"2024-12-22T15:24:45.596010Z","shell.execute_reply":"2024-12-22T15:24:45.600470Z"}},"outputs":[{"execution_count":11,"output_type":"execute_result","data":{"text/plain":"torch.Tensor"},"metadata":{}}],"execution_count":11},{"cell_type":"code","source":"torch.rand(2,3)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:25:06.374518Z","iopub.execute_input":"2024-12-22T15:25:06.374816Z","iopub.status.idle":"2024-12-22T15:25:06.383084Z","shell.execute_reply.started":"2024-12-22T15:25:06.374794Z","shell.execute_reply":"2024-12-22T15:25:06.382192Z"}},"outputs":[{"execution_count":12,"output_type":"execute_result","data":{"text/plain":"tensor([[0.5602, 0.3676, 0.9076],\n [0.2273, 0.8785, 0.6501]])"},"metadata":{}}],"execution_count":12},{"cell_type":"code","source":"torch.manual_seed(100)\ntorch.rand(2,3)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:26:15.807204Z","iopub.execute_input":"2024-12-22T15:26:15.807562Z","iopub.status.idle":"2024-12-22T15:26:15.815957Z","shell.execute_reply.started":"2024-12-22T15:26:15.807537Z","shell.execute_reply":"2024-12-22T15:26:15.814985Z"}},"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"tensor([[0.1117, 0.8158, 0.2626],\n [0.4839, 0.6765, 0.7539]])"},"metadata":{}}],"execution_count":14},{"cell_type":"code","source":"torch.tensor([[2,3,4], [2,4,2]])","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:27:05.767910Z","iopub.execute_input":"2024-12-22T15:27:05.768236Z","iopub.status.idle":"2024-12-22T15:27:05.774294Z","shell.execute_reply.started":"2024-12-22T15:27:05.768206Z","shell.execute_reply":"2024-12-22T15:27:05.773452Z"}},"outputs":[{"execution_count":17,"output_type":"execute_result","data":{"text/plain":"tensor([[2, 3, 4],\n [2, 4, 2]])"},"metadata":{}}],"execution_count":17},{"cell_type":"code","source":"torch.eye(5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:27:59.835621Z","iopub.execute_input":"2024-12-22T15:27:59.835934Z","iopub.status.idle":"2024-12-22T15:27:59.845033Z","shell.execute_reply.started":"2024-12-22T15:27:59.835900Z","shell.execute_reply":"2024-12-22T15:27:59.844206Z"}},"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":"tensor([[1., 0., 0., 0., 0.],\n [0., 1., 0., 0., 0.],\n [0., 0., 1., 0., 0.],\n [0., 0., 0., 1., 0.],\n [0., 0., 0., 0., 1.]])"},"metadata":{}}],"execution_count":18},{"cell_type":"code","source":"torch.linspace(2,3, 10) # linspace-> linear space","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:28:16.442280Z","iopub.execute_input":"2024-12-22T15:28:16.442584Z","iopub.status.idle":"2024-12-22T15:28:16.450138Z","shell.execute_reply.started":"2024-12-22T15:28:16.442561Z","shell.execute_reply":"2024-12-22T15:28:16.449412Z"}},"outputs":[{"execution_count":19,"output_type":"execute_result","data":{"text/plain":"tensor([2.0000, 2.1111, 2.2222, 2.3333, 2.4444, 2.5556, 2.6667, 2.7778, 2.8889,\n 3.0000])"},"metadata":{}}],"execution_count":19},{"cell_type":"markdown","source":"# Tensor shapes","metadata":{}},{"cell_type":"code","source":"torch.manual_seed(42)\na = torch.randn(3, 3)\na.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:35:53.478811Z","iopub.execute_input":"2024-12-22T15:35:53.479143Z","iopub.status.idle":"2024-12-22T15:35:53.486209Z","shell.execute_reply.started":"2024-12-22T15:35:53.479098Z","shell.execute_reply":"2024-12-22T15:35:53.485288Z"}},"outputs":[{"execution_count":37,"output_type":"execute_result","data":{"text/plain":"torch.Size([3, 3])"},"metadata":{}}],"execution_count":37},{"cell_type":"code","source":"torch.empty_like(a)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:35:54.571681Z","iopub.execute_input":"2024-12-22T15:35:54.572062Z","iopub.status.idle":"2024-12-22T15:35:54.578825Z","shell.execute_reply.started":"2024-12-22T15:35:54.572029Z","shell.execute_reply":"2024-12-22T15:35:54.577944Z"}},"outputs":[{"execution_count":38,"output_type":"execute_result","data":{"text/plain":"tensor([[0.0000e+00, 0.0000e+00, 7.7052e+31],\n [7.2148e+22, 1.5766e-19, 1.0256e-08],\n [1.0313e-08, 3.0614e+12, 4.3355e-08]])"},"metadata":{}}],"execution_count":38},{"cell_type":"code","source":"a.dtype","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:35:54.801497Z","iopub.execute_input":"2024-12-22T15:35:54.801829Z","iopub.status.idle":"2024-12-22T15:35:54.806716Z","shell.execute_reply.started":"2024-12-22T15:35:54.801799Z","shell.execute_reply":"2024-12-22T15:35:54.805771Z"}},"outputs":[{"execution_count":39,"output_type":"execute_result","data":{"text/plain":"torch.float32"},"metadata":{}}],"execution_count":39},{"cell_type":"code","source":"b = torch.tensor([[[1,2,3],[2,3,3], [3,4,4]]], dtype = torch.float32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:35:54.955597Z","iopub.execute_input":"2024-12-22T15:35:54.955901Z","iopub.status.idle":"2024-12-22T15:35:54.960241Z","shell.execute_reply.started":"2024-12-22T15:35:54.955855Z","shell.execute_reply":"2024-12-22T15:35:54.958999Z"}},"outputs":[],"execution_count":40},{"cell_type":"code","source":"b.dtype","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:35:55.090563Z","iopub.execute_input":"2024-12-22T15:35:55.090975Z","iopub.status.idle":"2024-12-22T15:35:55.096302Z","shell.execute_reply.started":"2024-12-22T15:35:55.090940Z","shell.execute_reply":"2024-12-22T15:35:55.095347Z"}},"outputs":[{"execution_count":41,"output_type":"execute_result","data":{"text/plain":"torch.float32"},"metadata":{}}],"execution_count":41},{"cell_type":"code","source":"b.to(torch.int32)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:35:56.310418Z","iopub.execute_input":"2024-12-22T15:35:56.310701Z","iopub.status.idle":"2024-12-22T15:35:56.317361Z","shell.execute_reply.started":"2024-12-22T15:35:56.310678Z","shell.execute_reply":"2024-12-22T15:35:56.316389Z"}},"outputs":[{"execution_count":42,"output_type":"execute_result","data":{"text/plain":"tensor([[[1, 2, 3],\n [2, 3, 3],\n [3, 4, 4]]], dtype=torch.int32)"},"metadata":{}}],"execution_count":42},{"cell_type":"code","source":"a + b","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:36:03.321710Z","iopub.execute_input":"2024-12-22T15:36:03.321986Z","iopub.status.idle":"2024-12-22T15:36:03.328305Z","shell.execute_reply.started":"2024-12-22T15:36:03.321965Z","shell.execute_reply":"2024-12-22T15:36:03.327493Z"}},"outputs":[{"execution_count":45,"output_type":"execute_result","data":{"text/plain":"tensor([[[1.3367, 2.1288, 3.2345],\n [2.2303, 1.8771, 2.8137],\n [5.2082, 3.3620, 4.4617]]])"},"metadata":{}}],"execution_count":45},{"cell_type":"code","source":"torch.abs(a)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:36:24.331724Z","iopub.execute_input":"2024-12-22T15:36:24.332021Z","iopub.status.idle":"2024-12-22T15:36:24.339251Z","shell.execute_reply.started":"2024-12-22T15:36:24.331999Z","shell.execute_reply":"2024-12-22T15:36:24.338541Z"}},"outputs":[{"execution_count":46,"output_type":"execute_result","data":{"text/plain":"tensor([[0.3367, 0.1288, 0.2345],\n [0.2303, 1.1229, 0.1863],\n [2.2082, 0.6380, 0.4617]])"},"metadata":{}}],"execution_count":46},{"cell_type":"code","source":"torch.round(a)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:36:40.641050Z","iopub.execute_input":"2024-12-22T15:36:40.641382Z","iopub.status.idle":"2024-12-22T15:36:40.648755Z","shell.execute_reply.started":"2024-12-22T15:36:40.641355Z","shell.execute_reply":"2024-12-22T15:36:40.648085Z"}},"outputs":[{"execution_count":47,"output_type":"execute_result","data":{"text/plain":"tensor([[ 0., 0., 0.],\n [ 0., -1., -0.],\n [ 2., -1., 0.]])"},"metadata":{}}],"execution_count":47},{"cell_type":"code","source":"torch.clamp(a, min = 0.5, max = 1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:37:33.279374Z","iopub.execute_input":"2024-12-22T15:37:33.279648Z","iopub.status.idle":"2024-12-22T15:37:33.285769Z","shell.execute_reply.started":"2024-12-22T15:37:33.279628Z","shell.execute_reply":"2024-12-22T15:37:33.284963Z"}},"outputs":[{"execution_count":50,"output_type":"execute_result","data":{"text/plain":"tensor([[0.5000, 0.5000, 0.5000],\n [0.5000, 0.5000, 0.5000],\n [1.0000, 0.5000, 0.5000]])"},"metadata":{}}],"execution_count":50},{"cell_type":"markdown","source":"# Reduction Operation","metadata":{}},{"cell_type":"code","source":"x = torch.randint(size = (3,4), low = 0, high = 10, dtype = torch.float64)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:40:15.512872Z","iopub.execute_input":"2024-12-22T15:40:15.513197Z","iopub.status.idle":"2024-12-22T15:40:15.517399Z","shell.execute_reply.started":"2024-12-22T15:40:15.513166Z","shell.execute_reply":"2024-12-22T15:40:15.516480Z"}},"outputs":[],"execution_count":59},{"cell_type":"code","source":"x\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:40:16.529077Z","iopub.execute_input":"2024-12-22T15:40:16.529390Z","iopub.status.idle":"2024-12-22T15:40:16.536170Z","shell.execute_reply.started":"2024-12-22T15:40:16.529367Z","shell.execute_reply":"2024-12-22T15:40:16.535418Z"}},"outputs":[{"execution_count":60,"output_type":"execute_result","data":{"text/plain":"tensor([[7., 3., 3., 4.],\n [3., 7., 0., 9.],\n [0., 9., 6., 9.]], dtype=torch.float64)"},"metadata":{}}],"execution_count":60},{"cell_type":"code","source":"torch.sum(x, dim=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:40:17.394855Z","iopub.execute_input":"2024-12-22T15:40:17.395194Z","iopub.status.idle":"2024-12-22T15:40:17.401148Z","shell.execute_reply.started":"2024-12-22T15:40:17.395162Z","shell.execute_reply":"2024-12-22T15:40:17.400522Z"}},"outputs":[{"execution_count":61,"output_type":"execute_result","data":{"text/plain":"tensor([17., 19., 24.], dtype=torch.float64)"},"metadata":{}}],"execution_count":61},{"cell_type":"code","source":"torch.mean(x)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:40:41.856729Z","iopub.execute_input":"2024-12-22T15:40:41.857000Z","iopub.status.idle":"2024-12-22T15:40:41.863082Z","shell.execute_reply.started":"2024-12-22T15:40:41.856978Z","shell.execute_reply":"2024-12-22T15:40:41.862208Z"}},"outputs":[{"execution_count":63,"output_type":"execute_result","data":{"text/plain":"tensor(5., dtype=torch.float64)"},"metadata":{}}],"execution_count":63},{"cell_type":"code","source":"torch.var(x)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:41:28.018492Z","iopub.execute_input":"2024-12-22T15:41:28.018762Z","iopub.status.idle":"2024-12-22T15:41:28.024944Z","shell.execute_reply.started":"2024-12-22T15:41:28.018741Z","shell.execute_reply":"2024-12-22T15:41:28.023935Z"}},"outputs":[{"execution_count":69,"output_type":"execute_result","data":{"text/plain":"tensor(10.9091, dtype=torch.float64)"},"metadata":{}}],"execution_count":69},{"cell_type":"code","source":"torch.argmax(x)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:41:46.851288Z","iopub.execute_input":"2024-12-22T15:41:46.851585Z","iopub.status.idle":"2024-12-22T15:41:46.858612Z","shell.execute_reply.started":"2024-12-22T15:41:46.851560Z","shell.execute_reply":"2024-12-22T15:41:46.857629Z"}},"outputs":[{"execution_count":70,"output_type":"execute_result","data":{"text/plain":"tensor(7)"},"metadata":{}}],"execution_count":70},{"cell_type":"code","source":"# Matrix multiplication\ntorch.matmul(a,b)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:42:45.909641Z","iopub.execute_input":"2024-12-22T15:42:45.909951Z","iopub.status.idle":"2024-12-22T15:42:45.922516Z","shell.execute_reply.started":"2024-12-22T15:42:45.909924Z","shell.execute_reply":"2024-12-22T15:42:45.921681Z"}},"outputs":[{"execution_count":71,"output_type":"execute_result","data":{"text/plain":"tensor([[[ 1.2977, 1.9977, 2.3343],\n [-2.5744, -3.6532, -3.4229],\n [ 2.3172, 4.3490, 6.5572]]])"},"metadata":{}}],"execution_count":71},{"cell_type":"code","source":"torch.transpose(x, 0, 1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:45:04.756009Z","iopub.execute_input":"2024-12-22T15:45:04.756623Z","iopub.status.idle":"2024-12-22T15:45:04.762669Z","shell.execute_reply.started":"2024-12-22T15:45:04.756581Z","shell.execute_reply":"2024-12-22T15:45:04.761994Z"}},"outputs":[{"execution_count":74,"output_type":"execute_result","data":{"text/plain":"tensor([[7., 3., 0.],\n [3., 7., 9.],\n [3., 0., 6.],\n [4., 9., 9.]], dtype=torch.float64)"},"metadata":{}}],"execution_count":74},{"cell_type":"code","source":"a","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:45:14.035518Z","iopub.execute_input":"2024-12-22T15:45:14.035803Z","iopub.status.idle":"2024-12-22T15:45:14.041513Z","shell.execute_reply.started":"2024-12-22T15:45:14.035780Z","shell.execute_reply":"2024-12-22T15:45:14.040764Z"}},"outputs":[{"execution_count":75,"output_type":"execute_result","data":{"text/plain":"tensor([[ 0.3367, 0.1288, 0.2345],\n [ 0.2303, -1.1229, -0.1863],\n [ 2.2082, -0.6380, 0.4617]])"},"metadata":{}}],"execution_count":75},{"cell_type":"code","source":"torch.det(a)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:45:15.922831Z","iopub.execute_input":"2024-12-22T15:45:15.923197Z","iopub.status.idle":"2024-12-22T15:45:15.934329Z","shell.execute_reply.started":"2024-12-22T15:45:15.923165Z","shell.execute_reply":"2024-12-22T15:45:15.933507Z"}},"outputs":[{"execution_count":76,"output_type":"execute_result","data":{"text/plain":"tensor(0.2656)"},"metadata":{}}],"execution_count":76},{"cell_type":"code","source":"a_ = torch.inverse(a)\na_","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:46:30.943405Z","iopub.execute_input":"2024-12-22T15:46:30.943677Z","iopub.status.idle":"2024-12-22T15:46:30.949821Z","shell.execute_reply.started":"2024-12-22T15:46:30.943655Z","shell.execute_reply":"2024-12-22T15:46:30.949162Z"}},"outputs":[{"execution_count":79,"output_type":"execute_result","data":{"text/plain":"tensor([[-2.3989, -0.7870, 0.9007],\n [-1.9492, -1.3639, 0.4395],\n [ 8.7808, 1.8794, -1.5349]])"},"metadata":{}}],"execution_count":79},{"cell_type":"code","source":"torch.matmul(a, a_)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:46:33.237836Z","iopub.execute_input":"2024-12-22T15:46:33.238102Z","iopub.status.idle":"2024-12-22T15:46:33.244375Z","shell.execute_reply.started":"2024-12-22T15:46:33.238082Z","shell.execute_reply":"2024-12-22T15:46:33.243474Z"}},"outputs":[{"execution_count":80,"output_type":"execute_result","data":{"text/plain":"tensor([[ 1.0000e+00, 0.0000e+00, 3.3528e-08],\n [ 2.3842e-07, 1.0000e+00, 0.0000e+00],\n [-8.3447e-07, 1.1921e-07, 1.0000e+00]])"},"metadata":{}}],"execution_count":80},{"cell_type":"code","source":"torch.sigmoid(x)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:47:23.594436Z","iopub.execute_input":"2024-12-22T15:47:23.594774Z","iopub.status.idle":"2024-12-22T15:47:23.602291Z","shell.execute_reply.started":"2024-12-22T15:47:23.594747Z","shell.execute_reply":"2024-12-22T15:47:23.601523Z"}},"outputs":[{"execution_count":81,"output_type":"execute_result","data":{"text/plain":"tensor([[0.9991, 0.9526, 0.9526, 0.9820],\n [0.9526, 0.9991, 0.5000, 0.9999],\n [0.5000, 0.9999, 0.9975, 0.9999]], dtype=torch.float64)"},"metadata":{}}],"execution_count":81},{"cell_type":"code","source":"torch.softmax(a, dim=0)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:48:21.027526Z","iopub.execute_input":"2024-12-22T15:48:21.027804Z","iopub.status.idle":"2024-12-22T15:48:21.036227Z","shell.execute_reply.started":"2024-12-22T15:48:21.027783Z","shell.execute_reply":"2024-12-22T15:48:21.035374Z"}},"outputs":[{"execution_count":84,"output_type":"execute_result","data":{"text/plain":"tensor([[0.1191, 0.5713, 0.3435],\n [0.1071, 0.1634, 0.2255],\n [0.7738, 0.2653, 0.4311]])"},"metadata":{}}],"execution_count":84},{"cell_type":"code","source":"torch.relu(x)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-22T15:49:03.778327Z","iopub.execute_input":"2024-12-22T15:49:03.778666Z","iopub.status.idle":"2024-12-22T15:49:03.785230Z","shell.execute_reply.started":"2024-12-22T15:49:03.778640Z","shell.execute_reply":"2024-12-22T15:49:03.784529Z"}},"outputs":[{"execution_count":86,"output_type":"execute_result","data":{"text/plain":"tensor([[7., 3., 3., 4.],\n [3., 7., 0., 9.],\n [0., 9., 6., 9.]], dtype=torch.float64)"},"metadata":{}}],"execution_count":86},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}