diff --git a/09.ipynb b/09.ipynb new file mode 100644 index 0000000..2f3ed32 --- /dev/null +++ b/09.ipynb @@ -0,0 +1,101 @@ +{ + "cells": [ + { + "cell_type": "code", + "id": "initial_id", + "metadata": { + "collapsed": true, + "ExecuteTime": { + "end_time": "2025-06-16T08:22:25.477936Z", + "start_time": "2025-06-16T08:22:25.474514Z" + } + }, + "source": [ + "import torch\n", + "import torch.nn as nn" + ], + "outputs": [], + "execution_count": 4 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-06-16T08:20:55.729969Z", + "start_time": "2025-06-16T08:20:55.664951Z" + } + }, + "cell_type": "code", + "source": [ + "input_feat = torch.tensor([[4, 1, 7, 5], [4, 4, 2, 5], [7, 7, 2, 4], [1, 0, 2, 4]], dtype=torch.float32)\n", + "print(input_feat)\n", + "print(input_feat.shape)" + ], + "id": "c2fef52f697ea63", + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tensor([[4., 1., 7., 5.],\n", + " [4., 4., 2., 5.],\n", + " [7., 7., 2., 4.],\n", + " [1., 0., 2., 4.]])\n", + "torch.Size([4, 4])\n" + ] + } + ], + "execution_count": 2 + }, + { + "metadata": { + "ExecuteTime": { + "end_time": "2025-06-16T08:22:26.834622Z", + "start_time": "2025-06-16T08:22:26.825132Z" + } + }, + "cell_type": "code", + "source": [ + "conv2d = nn.Conv2d(1, 1, (2, 2), stride=1, padding='same', bias=True)\n", + "# 默认情况随机初始化参数\n", + "print(conv2d.weight)\n", + "print(conv2d.bias)" + ], + "id": "1903942bae26fde7", + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Parameter containing:\n", + "tensor([[[[ 0.4068, -0.3036],\n", + " [ 0.4212, 0.4779]]]], requires_grad=True)\n", + "Parameter containing:\n", + "tensor([0.0521], requires_grad=True)\n" + ] + } + ], + "execution_count": 5 + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}