| @@ -41,8 +41,8 @@ | |||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "tensor([[1.2563e-37, 0.0000e+00, 5.7453e-44],\n", | |||||
| " [0.0000e+00, nan, 4.5814e-41],\n", | |||||
| "tensor([[3.7158e-37, 0.0000e+00, 5.7453e-44],\n", | |||||
| " [0.0000e+00, nan, 4.5745e-41],\n", | |||||
| " [1.3733e-14, 6.4076e+07, 2.0706e-19],\n", | " [1.3733e-14, 6.4076e+07, 2.0706e-19],\n", | ||||
| " [7.3909e+22, 2.4176e-12, 1.1625e+33],\n", | " [7.3909e+22, 2.4176e-12, 1.1625e+33],\n", | ||||
| " [8.9605e-01, 1.1632e+33, 5.6003e-02]])" | " [8.9605e-01, 1.1632e+33, 5.6003e-02]])" | ||||
| @@ -67,11 +67,11 @@ | |||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "tensor([[0.7149, 0.6065, 0.8056],\n", | |||||
| " [0.2450, 0.1942, 0.5305],\n", | |||||
| " [0.6735, 0.7798, 0.6060],\n", | |||||
| " [0.1072, 0.8325, 0.8617],\n", | |||||
| " [0.5117, 0.2246, 0.4984]])" | |||||
| "tensor([[0.4157, 0.7456, 0.9620],\n", | |||||
| " [0.3965, 0.8182, 0.7723],\n", | |||||
| " [0.3705, 0.9292, 0.0063],\n", | |||||
| " [0.4054, 0.9137, 0.9611],\n", | |||||
| " [0.8307, 0.0900, 0.6887]])" | |||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 3, | "execution_count": 3, | ||||
| @@ -128,11 +128,11 @@ | |||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "tensor([[1.6605, 1.1155, 1.2724],\n", | |||||
| " [0.6727, 0.6428, 1.0969],\n", | |||||
| " [1.4898, 1.7437, 1.3258],\n", | |||||
| " [0.8030, 1.5725, 1.4709],\n", | |||||
| " [0.6847, 0.4828, 0.6183]])" | |||||
| "tensor([[0.5021, 1.2500, 1.4749],\n", | |||||
| " [0.6019, 0.9378, 1.7240],\n", | |||||
| " [1.2752, 1.3837, 0.6832],\n", | |||||
| " [1.2053, 1.4374, 1.5160],\n", | |||||
| " [0.9404, 0.8743, 0.8164]])" | |||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 5, | "execution_count": 5, | ||||
| @@ -154,13 +154,11 @@ | |||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "\n", | |||||
| " 0.4063 0.7378 1.2411\n", | |||||
| " 0.0687 0.7725 0.0634\n", | |||||
| " 1.1016 1.4291 0.7324\n", | |||||
| " 0.7604 1.2880 0.4597\n", | |||||
| " 0.6020 1.0124 1.0185\n", | |||||
| "[torch.FloatTensor of size 5x3]" | |||||
| "tensor([[0.5021, 1.2500, 1.4749],\n", | |||||
| " [0.6019, 0.9378, 1.7240],\n", | |||||
| " [1.2752, 1.3837, 0.6832],\n", | |||||
| " [1.2053, 1.4374, 1.5160],\n", | |||||
| " [0.9404, 0.8743, 0.8164]])" | |||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 6, | "execution_count": 6, | ||||
| @@ -210,23 +208,23 @@ | |||||
| "output_type": "stream", | "output_type": "stream", | ||||
| "text": [ | "text": [ | ||||
| "最初y\n", | "最初y\n", | ||||
| "tensor([[0.9778, 0.9240, 0.0337],\n", | |||||
| " [0.7461, 0.8548, 0.5141],\n", | |||||
| " [0.5364, 0.9908, 0.1078],\n", | |||||
| " [0.6880, 0.1675, 0.0010],\n", | |||||
| " [0.9120, 0.5539, 0.2896]])\n", | |||||
| "tensor([[0.0864, 0.5044, 0.5128],\n", | |||||
| " [0.2054, 0.1196, 0.9517],\n", | |||||
| " [0.9047, 0.4545, 0.6769],\n", | |||||
| " [0.7999, 0.5236, 0.5549],\n", | |||||
| " [0.1097, 0.7843, 0.1277]])\n", | |||||
| "第一种加法,y的结果\n", | "第一种加法,y的结果\n", | ||||
| "tensor([[0.9778, 0.9240, 0.0337],\n", | |||||
| " [0.7461, 0.8548, 0.5141],\n", | |||||
| " [0.5364, 0.9908, 0.1078],\n", | |||||
| " [0.6880, 0.1675, 0.0010],\n", | |||||
| " [0.9120, 0.5539, 0.2896]])\n", | |||||
| "tensor([[0.0864, 0.5044, 0.5128],\n", | |||||
| " [0.2054, 0.1196, 0.9517],\n", | |||||
| " [0.9047, 0.4545, 0.6769],\n", | |||||
| " [0.7999, 0.5236, 0.5549],\n", | |||||
| " [0.1097, 0.7843, 0.1277]])\n", | |||||
| "第二种加法,y的结果\n", | "第二种加法,y的结果\n", | ||||
| "tensor([[1.7112, 1.2969, 0.3289],\n", | |||||
| " [0.7841, 1.0128, 0.7596],\n", | |||||
| " [1.1364, 1.1541, 0.8970],\n", | |||||
| " [0.8831, 0.7063, 0.3158],\n", | |||||
| " [1.5160, 1.3610, 0.8437]])\n" | |||||
| "tensor([[0.5021, 1.2500, 1.4749],\n", | |||||
| " [0.6019, 0.9378, 1.7240],\n", | |||||
| " [1.2752, 1.3837, 0.6832],\n", | |||||
| " [1.2053, 1.4374, 1.5160],\n", | |||||
| " [0.9404, 0.8743, 0.8164]])\n" | |||||
| ] | ] | ||||
| } | } | ||||
| ], | ], | ||||
| @@ -252,22 +250,16 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 9, | |||||
| "execution_count": 8, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "\n", | |||||
| " 0.2522\n", | |||||
| " 0.7138\n", | |||||
| " 0.6019\n", | |||||
| " 0.3675\n", | |||||
| " 0.5104\n", | |||||
| "[torch.FloatTensor of size 5]" | |||||
| "tensor([0.7456, 0.8182, 0.9292, 0.9137, 0.0900])" | |||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 9, | |||||
| "execution_count": 8, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -288,7 +280,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 8, | |||||
| "execution_count": 9, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -297,7 +289,7 @@ | |||||
| "tensor([1., 1., 1., 1., 1.])" | "tensor([1., 1., 1., 1., 1.])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 8, | |||||
| "execution_count": 9, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -309,7 +301,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 9, | |||||
| "execution_count": 10, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -318,7 +310,7 @@ | |||||
| "array([1., 1., 1., 1., 1.], dtype=float32)" | "array([1., 1., 1., 1., 1.], dtype=float32)" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 9, | |||||
| "execution_count": 10, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -330,7 +322,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 10, | |||||
| "execution_count": 11, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -393,18 +385,18 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 6, | |||||
| "execution_count": 12, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| "name": "stdout", | "name": "stdout", | ||||
| "output_type": "stream", | "output_type": "stream", | ||||
| "text": [ | "text": [ | ||||
| "tensor([[1.6605, 1.1155, 1.2724],\n", | |||||
| " [0.6727, 0.6428, 1.0969],\n", | |||||
| " [1.4898, 1.7437, 1.3258],\n", | |||||
| " [0.8030, 1.5725, 1.4709],\n", | |||||
| " [0.6847, 0.4828, 0.6183]], device='cuda:0')\n" | |||||
| "tensor([[0.9177, 1.9956, 2.4369],\n", | |||||
| " [0.9984, 1.7561, 2.4963],\n", | |||||
| " [1.6457, 2.3129, 0.6895],\n", | |||||
| " [1.6107, 2.3511, 2.4770],\n", | |||||
| " [1.7711, 0.9643, 1.5050]], device='cuda:0')\n" | |||||
| ] | ] | ||||
| } | } | ||||
| ], | ], | ||||
| @@ -446,7 +438,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 8, | |||||
| "execution_count": 13, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [], | "outputs": [], | ||||
| "source": [ | "source": [ | ||||
| @@ -455,7 +447,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 9, | |||||
| "execution_count": 14, | |||||
| "metadata": { | "metadata": { | ||||
| "scrolled": true | "scrolled": true | ||||
| }, | }, | ||||
| @@ -467,7 +459,7 @@ | |||||
| " [1., 1.]], requires_grad=True)" | " [1., 1.]], requires_grad=True)" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 9, | |||||
| "execution_count": 14, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -480,7 +472,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 10, | |||||
| "execution_count": 15, | |||||
| "metadata": { | "metadata": { | ||||
| "scrolled": true | "scrolled": true | ||||
| }, | }, | ||||
| @@ -491,7 +483,7 @@ | |||||
| "tensor(4., grad_fn=<SumBackward0>)" | "tensor(4., grad_fn=<SumBackward0>)" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 10, | |||||
| "execution_count": 15, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -503,16 +495,16 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 11, | |||||
| "execution_count": 16, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "<SumBackward0 at 0x7fb610129c88>" | |||||
| "<SumBackward0 at 0x7f85680bd710>" | |||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 11, | |||||
| "execution_count": 16, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -523,7 +515,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 12, | |||||
| "execution_count": 17, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [], | "outputs": [], | ||||
| "source": [ | "source": [ | ||||
| @@ -532,7 +524,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 13, | |||||
| "execution_count": 18, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -542,7 +534,7 @@ | |||||
| " [1., 1.]])" | " [1., 1.]])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 13, | |||||
| "execution_count": 18, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -562,7 +554,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 14, | |||||
| "execution_count": 19, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -572,7 +564,7 @@ | |||||
| " [2., 2.]])" | " [2., 2.]])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 14, | |||||
| "execution_count": 19, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -584,7 +576,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 15, | |||||
| "execution_count": 20, | |||||
| "metadata": { | "metadata": { | ||||
| "scrolled": true | "scrolled": true | ||||
| }, | }, | ||||
| @@ -596,7 +588,7 @@ | |||||
| " [3., 3.]])" | " [3., 3.]])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 15, | |||||
| "execution_count": 20, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -608,7 +600,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 16, | |||||
| "execution_count": 21, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -618,7 +610,7 @@ | |||||
| " [0., 0.]])" | " [0., 0.]])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 16, | |||||
| "execution_count": 21, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -630,7 +622,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 26, | |||||
| "execution_count": 22, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -640,7 +632,7 @@ | |||||
| " [1., 1.]])" | " [1., 1.]])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 26, | |||||
| "execution_count": 22, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -659,7 +651,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 17, | |||||
| "execution_count": 24, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -681,7 +673,7 @@ | |||||
| " [0.5403, 0.5403, 0.5403, 0.5403, 0.5403]])" | " [0.5403, 0.5403, 0.5403, 0.5403, 0.5403]])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 17, | |||||
| "execution_count": 24, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -713,7 +705,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 27, | |||||
| "execution_count": 25, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -775,7 +767,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 28, | |||||
| "execution_count": 26, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -793,7 +785,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 29, | |||||
| "execution_count": 27, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -827,7 +819,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 30, | |||||
| "execution_count": 28, | |||||
| "metadata": { | "metadata": { | ||||
| "scrolled": true | "scrolled": true | ||||
| }, | }, | ||||
| @@ -838,7 +830,7 @@ | |||||
| "torch.Size([1, 10])" | "torch.Size([1, 10])" | ||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 30, | |||||
| "execution_count": 28, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -851,7 +843,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 31, | |||||
| "execution_count": 29, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [], | "outputs": [], | ||||
| "source": [ | "source": [ | ||||
| @@ -877,7 +869,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 39, | |||||
| "execution_count": 30, | |||||
| "metadata": { | "metadata": { | ||||
| "scrolled": true | "scrolled": true | ||||
| }, | }, | ||||
| @@ -885,10 +877,10 @@ | |||||
| { | { | ||||
| "data": { | "data": { | ||||
| "text/plain": [ | "text/plain": [ | ||||
| "tensor(28.3834, grad_fn=<MseLossBackward>)" | |||||
| "tensor(28.6268, grad_fn=<MseLossBackward>)" | |||||
| ] | ] | ||||
| }, | }, | ||||
| "execution_count": 39, | |||||
| "execution_count": 30, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "output_type": "execute_result" | "output_type": "execute_result" | ||||
| } | } | ||||
| @@ -920,7 +912,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 32, | |||||
| "execution_count": 31, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [ | "outputs": [ | ||||
| { | { | ||||
| @@ -928,26 +920,9 @@ | |||||
| "output_type": "stream", | "output_type": "stream", | ||||
| "text": [ | "text": [ | ||||
| "反向传播之前 conv1.bias的梯度\n", | "反向传播之前 conv1.bias的梯度\n", | ||||
| "Variable containing:\n", | |||||
| " 0\n", | |||||
| " 0\n", | |||||
| " 0\n", | |||||
| " 0\n", | |||||
| " 0\n", | |||||
| " 0\n", | |||||
| "[torch.FloatTensor of size 6]\n", | |||||
| "\n", | |||||
| "tensor([0., 0., 0., 0., 0., 0.])\n", | |||||
| "反向传播之后 conv1.bias的梯度\n", | "反向传播之后 conv1.bias的梯度\n", | ||||
| "Variable containing:\n", | |||||
| "1.00000e-02 *\n", | |||||
| " -4.2109\n", | |||||
| " -2.7638\n", | |||||
| " -5.8431\n", | |||||
| " 1.3761\n", | |||||
| " -2.4141\n", | |||||
| " -1.2015\n", | |||||
| "[torch.FloatTensor of size 6]\n", | |||||
| "\n" | |||||
| "tensor([-0.0368, 0.0240, 0.0169, 0.0118, -0.0122, -0.0259])\n" | |||||
| ] | ] | ||||
| } | } | ||||
| ], | ], | ||||
| @@ -990,7 +965,7 @@ | |||||
| }, | }, | ||||
| { | { | ||||
| "cell_type": "code", | "cell_type": "code", | ||||
| "execution_count": 33, | |||||
| "execution_count": 32, | |||||
| "metadata": {}, | "metadata": {}, | ||||
| "outputs": [], | "outputs": [], | ||||
| "source": [ | "source": [ | ||||