deas
This commit is contained in:
wyy4github
2019-05-28 11:25:53 +08:00
parent 6cd2c0e830
commit 0e8984fc68
7 changed files with 307 additions and 86 deletions

62
.idea/workspace.xml generated
View File

@ -2,15 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="dba69579-024f-442a-b5bf-b31a92577c82" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/Image/输出11.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出12.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出13.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出14.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出15.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出16.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出17.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出18.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出19.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出20.PNG" afterDir="false" />
<change afterPath="$PROJECT_DIR$/Image/输出21.PNG" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/SecondSection/Autograd.md" beforeDir="false" afterPath="$PROJECT_DIR$/SecondSection/Autograd.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/SecondSection/Tensor.md" beforeDir="false" afterPath="$PROJECT_DIR$/SecondSection/Tensor.md" afterDir="false" />
@ -27,8 +20,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/tensorTest.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="51" column="18" lean-forward="true" selection-start-line="51" selection-start-column="18" selection-end-line="51" selection-end-column="18" />
<state relative-caret-position="199">
<caret line="13" column="13" lean-forward="true" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
<folding>
<element signature="e#0#37#0" expanded="true" />
</folding>
@ -36,24 +29,24 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/SecondSection/Tensor.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="-694">
<caret line="217" lean-forward="true" selection-start-line="217" selection-end-line="217" />
<first_editor relative-caret-position="58">
<caret line="131" column="3" lean-forward="true" selection-start-line="131" selection-start-column="3" selection-end-line="131" selection-end-column="3" />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/SecondSection/Autograd.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="210">
<caret line="7" column="1" selection-start-line="7" selection-start-column="1" selection-end-line="7" selection-end-column="1" />
<first_editor relative-caret-position="356">
<caret line="60" lean-forward="true" selection-start-line="60" selection-end-line="60" />
</first_editor>
<second_editor />
</state>
@ -81,16 +74,17 @@
<option value="$PROJECT_DIR$/FirstSection/PyTorchIntro.md" />
<option value="$PROJECT_DIR$/FirstSection/InstallIutorial.md" />
<option value="$PROJECT_DIR$/Tensor.md" />
<option value="$PROJECT_DIR$/SecondSection/Autograd.md" />
<option value="$PROJECT_DIR$/tensorTest.py" />
<option value="$PROJECT_DIR$/SecondSection/Tensor.md" />
<option value="$PROJECT_DIR$/tensorTest.py" />
<option value="$PROJECT_DIR$/SecondSection/Autograd.md" />
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="487" />
<option name="width" value="1439" />
<option name="height" value="1040" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-342" />
<option name="y" value="557" />
<option name="width" value="1840" />
<option name="height" value="823" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
@ -199,15 +193,15 @@
<option name="totallyTimeSpent" value="12000" />
</component>
<component name="ToolWindowManager">
<frame x="487" y="0" width="1439" height="1040" extended-state="0" />
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.17558886" />
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.09694415" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.4520397" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.3488624" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
@ -297,11 +291,11 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SecondSection/Autograd.md">
<entry file="file://$PROJECT_DIR$/SecondSection/Tensor.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="210">
<caret line="7" column="1" selection-start-line="7" selection-start-column="1" selection-end-line="7" selection-end-column="1" />
<first_editor relative-caret-position="58">
<caret line="131" column="3" lean-forward="true" selection-start-line="131" selection-start-column="3" selection-end-line="131" selection-end-column="3" />
</first_editor>
<second_editor />
</state>
@ -309,19 +303,19 @@
</entry>
<entry file="file://$PROJECT_DIR$/tensorTest.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="357">
<caret line="51" column="18" lean-forward="true" selection-start-line="51" selection-start-column="18" selection-end-line="51" selection-end-column="18" />
<state relative-caret-position="199">
<caret line="13" column="13" lean-forward="true" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
<folding>
<element signature="e#0#37#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/SecondSection/Tensor.md">
<entry file="file://$PROJECT_DIR$/SecondSection/Autograd.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="-694">
<caret line="217" lean-forward="true" selection-start-line="217" selection-end-line="217" />
<first_editor relative-caret-position="356">
<caret line="60" lean-forward="true" selection-start-line="60" selection-end-line="60" />
</first_editor>
<second_editor />
</state>

BIN
Image/输出20.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
Image/输出21.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -2,7 +2,63 @@
## 什么是Autograd
Autograd(自动微分) 包是 PyTorch 中所有神经网络的核心。该 autograd 软件包为 Tensors 上的所有操作提供自动微分。它是一个
由运行定义的框架,这意味着以代码运行方式定义你的后向传播,并且每次迭代都可以不同。
Autograd(自动微分) 包是 PyTorch 中所有神经网络的核心。Tensor是PyTorch实现多维数组计算和自动微分的关键数据结构关于
Tensor的各种数学运算上一小节已做说明。本小节主要讲Tensor提供的自动微分记录作用于Tensor上的所有操作用于后续的梯度计算,这意味着以代码运行方式定义你的后向传播,并且每次迭代都可以不同。
Autograd机制记录作用于Tensor上的所有操作生成一个动态计算图。图的叶子节点是输入的数据根节点是输出的结果。当在
根节点调用.backward()的时候就会从根到叶应用链式法则计算梯度。默认情况下,只有.requires_grad和is_leaf两个属性都为True的
节点才会被计算导数并存储到grad中。
### requires_grad属性
requires_grad属性默认为False如果一个节点的requires_grad是True那么所有依赖它的节点requires_grad也会是True。
```buildoutcfg
x = torch.randn(5, 5) # requires_grad=False by default
y = torch.randn(5, 5) # requires_grad=False by default
z = torch.randn((5, 5), requires_grad=True)
a = x + y
print(a.requires_grad)
b = a + z
print(b.requires_grad)
```
输出结果:
![](../Image/输出20.PNG)
### Function类
每当对Tensor施加一个运算的时候就会产生一个Function对象它产生运算的结果记录运算的发生并且记录运算的输入。
Tensor使用.grad_fn属性记录这个计算图的入口。反向传播过程中autograd引擎会按照逆序通过Function的backward依次计算梯度。
<h4>1.backward()函数计算张量的梯度之和
参数tensors如果是标量,函数backward计算参数tensors对于给定图叶子节点的梯度。参数tensors如果不是标量需要另外指定参
数grad_tensors参数grad_tensors必须和参数tensors的长度相同。这种情况下将计算雅可比矢量乘积。
每次backward之前需要注意叶子梯度节点是否清零如果没有清零第二次backward会累计上一次的梯度。
```buildoutcfg
x=torch.randn((3),dtype=torch.float32,requires_grad=True)
y = torch.randn((3),dtype=torch.float32,requires_grad=True)
z = torch.randn((3),dtype=torch.float32,requires_grad=True)
t = x + y
loss = t.dot(z) #求向量的内积
loss.backward(retain_graph=True)
print(z,x.grad,y.grad)
print(t,z.grad)
print(t.grad)
```
我们手动计算上面代码的导数可得为z所以预期结果中z=x.grad=y.grad ; t=z.grad且t为非叶子节点即t.grad=None
输出结果:
![](../Image/输出21.PNG)
<h4>2.detach()函数停止记录在tensor上的操作
<h4>3.grad()函数累计输入的梯度

View File

@ -129,7 +129,7 @@ print(y)
注意:任何使张量发生变化的操作都有一个前缀'_'。例如x_copy_(y),x_t()将会改变x
#### 绝对值运算
### 绝对值运算
<h4> torch.abs()输出全部张量元素的绝对值

210
hs_err_pid119532.log Normal file
View File

@ -0,0 +1,210 @@
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 134217728 bytes for Failed to commit area from 0x0000000081600000 to 0x0000000089600000 of length 134217728.
# Possible reasons:
# The system is out of physical RAM or swap space
# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
# Reduce memory load on the system
# Increase physical memory or swap space
# Check if swap backing store is full
# Decrease Java heap size (-Xmx/-Xms)
# Decrease number of Java threads
# Decrease Java thread stack sizes (-Xss)
# Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
# Out of Memory Error (c:/BuildAgent/work/dd4f663211fab7c/src/hotspot/os/windows/os_windows.cpp:3272), pid=119532, tid=119116
#
# JRE version: (11.0.2+9) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.2+9-b159.34, mixed mode, aot, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
--------------- S U M M A R Y ------------
Command Line: org.jetbrains.git4idea.http.GitAskPassApp Username for 'https://github.com':
Host: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz, 8 cores, 7G, Windows 7 , 64 bit Build 7601 (6.1.7601.24441)
Time: Sun May 26 00:05:04 2019 ?D1<44><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?<3F><><EFBFBD><EFBFBD>?? elapsed time: 0 seconds (0d 0h 0m 0s)
--------------- T H R E A D ---------------
Current thread (0x0000000000317000): JavaThread "Unknown thread" [_thread_in_vm, id=119116, stack(0x0000000002240000,0x0000000002340000)]
Stack: [0x0000000002240000,0x0000000002340000]
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [jvm.dll+0x5da82a]
V [jvm.dll+0x70b6c9]
V [jvm.dll+0x70cbe8]
V [jvm.dll+0x70d2b3]
V [jvm.dll+0x240f18]
V [jvm.dll+0x5d7fc4]
V [jvm.dll+0x5cd115]
V [jvm.dll+0x2fa5eb]
V [jvm.dll+0x2fa55a]
V [jvm.dll+0x2fa432]
V [jvm.dll+0x2ff316]
V [jvm.dll+0x347993]
V [jvm.dll+0x348096]
V [jvm.dll+0x347a93]
V [jvm.dll+0x2d5588]
V [jvm.dll+0x2d66c7]
V [jvm.dll+0x6eaac7]
V [jvm.dll+0x6ec22c]
V [jvm.dll+0x3551c9]
V [jvm.dll+0x6d274e]
V [jvm.dll+0x3bd953]
V [jvm.dll+0x3bfcc1]
C [java.exe+0x3763]
C [java.exe+0x17a0c]
C [kernel32.dll+0x1556d]
C [ntdll.dll+0x5385d]
--------------- P R O C E S S ---------------
Threads class SMR info:
_java_thread_list=0x00000000002f9910, length=0, elements={
}
Java Threads: ( => current thread )
Other Threads:
0x0000000000330800 GCTaskThread "GC Thread#0" [stack: 0x0000000014cc0000,0x0000000014dc0000] [id=118392]
0x0000000000364800 ConcurrentGCThread "G1 Main Marker" [stack: 0x000000001a210000,0x000000001a310000] [id=119528]
0x0000000000365800 ConcurrentGCThread "G1 Conc#0" [stack: 0x000000001a3a0000,0x000000001a4a0000] [id=119664]
[error occurred during error reporting (printing all threads), id 0xc0000005, EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007fee4645687]
VM state:not at safepoint (not fully initialized)
VM Mutex/Monitor currently owned by a thread: ([mutex/lock_event])
[0x00000000003149a0] Heap_lock - owner thread: 0x0000000000317000
Heap address: 0x0000000081600000, size: 2026 MB, Compressed Oops mode: Non-zero based: 0x0000000081600000
Narrow klass base: 0x0000000000000000, Narrow klass shift: 0
GC Heap History (0 events):
No events
Deoptimization events (0 events):
No events
Classes redefined (0 events):
No events
Internal exceptions (0 events):
No events
Events (0 events):
No events
Dynamic libraries:
0x000000013ff80000 - 0x000000013ffc7000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\java.exe
0x0000000077740000 - 0x00000000778df000 C:\Windows\SYSTEM32\ntdll.dll
0x0000000077520000 - 0x000000007763f000 C:\Windows\system32\kernel32.dll
0x000007fefd260000 - 0x000007fefd2ca000 C:\Windows\system32\KERNELBASE.dll
0x0000000077640000 - 0x000000007773a000 C:\Windows\system32\USER32.dll
0x000007fefd5e0000 - 0x000007fefd647000 C:\Windows\system32\GDI32.dll
0x000007fefe210000 - 0x000007fefe21e000 C:\Windows\system32\LPK.dll
0x000007feff960000 - 0x000007feffa2b000 C:\Windows\system32\USP10.dll
0x000007fefd730000 - 0x000007fefd7cf000 C:\Windows\system32\msvcrt.dll
0x000007fefb9e0000 - 0x000007fefbbd5000 C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.24440_none_e36f1bbf30ff0606\COMCTL32.dll
0x000007fefe060000 - 0x000007fefe0d1000 C:\Windows\system32\SHLWAPI.dll
0x000007feff560000 - 0x000007feff58e000 C:\Windows\system32\IMM32.DLL
0x000007fefd7d0000 - 0x000007fefd8d9000 C:\Windows\system32\MSCTF.dll
0x000007fef4a10000 - 0x000007fef4a13000 C:\Windows\system32\api-ms-win-core-synch-l1-2-0.DLL
0x000007fef5ea0000 - 0x000007fef5eb7000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\vcruntime140.dll
0x000007fef4960000 - 0x000007fef4964000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-runtime-l1-1-0.dll
0x000007fee8410000 - 0x000007fee850a000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\ucrtbase.DLL
0x000007feef160000 - 0x000007feef163000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-core-localization-l1-2-0.dll
0x000007feef180000 - 0x000007feef183000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-core-processthreads-l1-1-1.dll
0x000007feeacf0000 - 0x000007feeacf3000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-core-file-l1-2-0.dll
0x000007feead00000 - 0x000007feead03000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-core-timezone-l1-1-0.dll
0x000007fee8fd0000 - 0x000007fee8fd3000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-core-file-l2-1-0.dll
0x000007fef4870000 - 0x000007fef4874000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-string-l1-1-0.dll
0x000007fef4860000 - 0x000007fef4863000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-heap-l1-1-0.dll
0x000007fef4850000 - 0x000007fef4854000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-stdio-l1-1-0.dll
0x000007fef4100000 - 0x000007fef4104000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-convert-l1-1-0.dll
0x000007feef090000 - 0x000007feef12d000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\msvcp140.dll
0x000007feef070000 - 0x000007feef073000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-locale-l1-1-0.dll
0x000007fef40d0000 - 0x000007fef40d5000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-math-l1-1-0.dll
0x000007feef040000 - 0x000007feef045000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-multibyte-l1-1-0.dll
0x000007fef3ce0000 - 0x000007fef3ce3000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-time-l1-1-0.dll
0x000007fef40c0000 - 0x000007fef40c3000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-filesystem-l1-1-0.dll
0x000007fef40f0000 - 0x000007fef40f3000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-environment-l1-1-0.dll
0x000007fef40e0000 - 0x000007fef40e3000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\api-ms-win-crt-utility-l1-1-0.dll
0x000007fee4360000 - 0x000007fee4e16000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\server\jvm.dll
0x000007feff590000 - 0x000007feff66b000 C:\Windows\system32\ADVAPI32.dll
0x000007fefe740000 - 0x000007fefe75f000 C:\Windows\SYSTEM32\sechost.dll
0x000007fefe0e0000 - 0x000007fefe20c000 C:\Windows\system32\RPCRT4.dll
0x000007fef5e30000 - 0x000007fef5e39000 C:\Windows\system32\WSOCK32.dll
0x000007feff510000 - 0x000007feff55d000 C:\Windows\system32\WS2_32.dll
0x000007feff770000 - 0x000007feff778000 C:\Windows\system32\NSI.dll
0x000007fef66f0000 - 0x000007fef672b000 C:\Windows\system32\WINMM.dll
0x000007fefc300000 - 0x000007fefc30c000 C:\Windows\system32\VERSION.dll
0x00000000778e0000 - 0x00000000778e7000 C:\Windows\system32\PSAPI.DLL
0x000007fef3cc0000 - 0x000007fef3cd1000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\verify.dll
0x000007fefac50000 - 0x000007fefad75000 C:\Windows\system32\DBGHELP.DLL
0x000007feef130000 - 0x000007feef159000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\java.dll
0x000007fef3ca0000 - 0x000007fef3cb7000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\zip.dll
0x000007fef3c00000 - 0x000007fef3c0b000 E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\jimage.dll
dbghelp: loaded successfully - version: 4.0.5 - missing functions: none
symbol engine: initialized successfully - sym options: 0x614 - pdb path: .;E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin;C:\Windows\SYSTEM32;C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.24440_none_e36f1bbf30ff0606;E:\software\python\PyCharm Community Edition 2019.1.1\jre64\bin\server
VM Arguments:
java_command: org.jetbrains.git4idea.http.GitAskPassApp Username for 'https://github.com':
java_class_path (initial): E:/software/python/PyCharm Community Edition 2019.1.1/plugins/git4idea/lib/git4idea-rt.jar;E:/software/python/PyCharm Community Edition 2019.1.1/lib/xmlrpc-2.0.1.jar;E:/software/python/PyCharm Community Edition 2019.1.1/lib/commons-codec-1.10.jar;E:/software/python/PyCharm Community Edition 2019.1.1/lib/util.jar
Launcher Type: SUN_STANDARD
[Global flags]
intx CICompilerCount = 4 {product} {ergonomic}
uint ConcGCThreads = 2 {product} {ergonomic}
uint G1ConcRefinementThreads = 8 {product} {ergonomic}
size_t G1HeapRegionSize = 1048576 {product} {ergonomic}
uintx GCDrainStackTargetSize = 64 {product} {ergonomic}
size_t InitialHeapSize = 134217728 {product} {ergonomic}
size_t MarkStackSize = 4194304 {product} {ergonomic}
size_t MaxHeapSize = 2124414976 {product} {ergonomic}
size_t MinHeapDeltaBytes = 1048576 {product} {ergonomic}
uintx NonNMethodCodeHeapSize = 5835340 {pd product} {ergonomic}
uintx NonProfiledCodeHeapSize = 122911450 {pd product} {ergonomic}
uintx ProfiledCodeHeapSize = 122911450 {pd product} {ergonomic}
uintx ReservedCodeCacheSize = 251658240 {pd product} {ergonomic}
bool SegmentedCodeCache = true {product} {ergonomic}
bool UseCompressedClassPointers = true {lp64_product} {ergonomic}
bool UseCompressedOops = true {lp64_product} {ergonomic}
bool UseG1GC = true {product} {ergonomic}
bool UseLargePagesIndividualAllocation = false {pd product} {ergonomic}
Logging:
Log output configuration:
#0: stdout all=warning uptime,level,tags
#1: stderr all=off uptime,level,tags
Environment Variables:
PATH=E:/software/Git/mingw64/libexec/git-core;E:/software/Git/mingw64/libexec/git-core;E:\software\Git\mingw64\bin;E:\software\Git\usr\bin;C:\Users\Administrator\bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;E:\software\Git\cmd;E:\software\MATLAB\runtime\win64;E:\software\MATLAB\bin;E:\software\Anaconda3.5;E:\software\Anaconda3.5\Library\bin;E:\software\Anaconda3.5\Scripts;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Administrator\AppData\Local\Programs\Python\Python37\;E:\software\python\PyCharm Community Edition 2019.1.1\bin;C:\Users\Administrator\AppData\Local\GitHubDesktop\bin
USERNAME=Administrator
DISPLAY=:0.0
OS=Windows_NT
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
--------------- S Y S T E M ---------------
OS: Windows 7 , 64 bit Build 7601 (6.1.7601.24441)
CPU:total 8 (initial active 8) (4 cores per cpu, 2 threads per core) family 6 model 94 stepping 3, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, rtm, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx, fma
Memory: 4k page, system-wide physical 8099M (695M free)
TotalPageFile size 10145M (AvailPageFile size 121M)
current process WorkingSet (physical memory assigned to process): 11M, peak: 11M
current process commit charge ("private bytes"): 66M, peak: 193M
vm_info: OpenJDK 64-Bit Server VM (11.0.2+9-b159.34) for windows-amd64 JRE (11.0.2+9-b159.34), built on Mar 26 2019 11:55:29 by "" with MS VC++ 14.0 (VS2015)
END.

View File

@ -1,53 +1,14 @@
from __future__ import print_function
import torch
# x = torch.empty(5, 3)
# print(x)
#
# x = torch.rand(5, 3)
# print(x)
#
# x = torch.zeros(5, 3, dtype=torch.long)
# print(x)
#
# x = torch.tensor([5.5, 3])
# print(x)
#
# x = x.new_ones(5, 3, dtype=torch.double)
# print(x)
# x = torch.randn_like(x, dtype=torch.float)
# # 重写了数据类型
# print(x)
# # 结果大小相同
# #
# print(x.size())
# #
# y = torch.rand(5, 3)
# # #加法方式1
# print(x + y)
# # #加法方式2
# # #print(torch.add(x, y))
# #
# print(x[:,1])
# x = torch.randn(4, 4)
# y = x.view(16)
# z = x.view(-1, 8) # the size -1 is inferred from other dimensions
# print(x.size(), y.size(), z.size())
# x = torch.randn(1)
# print(x)
# print(x.item())
x = torch.randn((3), dtype=torch.float32, requires_grad=True)
y = torch.randn((3), dtype=torch.float32, requires_grad=True)
z = torch.randn((3), dtype=torch.float32, requires_grad=True)
t = x + y
loss = t.dot(z) # 求向量的内积
# x = torch.rand(5, 3)
# print(x)
# x[0,1] = 100
# print(x)
x = torch.randn(2, 3)
print(x)
y = torch.randn(3)
print(y)
# 被传入的参数中的第1个参数代表矩阵第2个参数代表向量顺序不能颠倒。
z = torch.mv(x, y)
print(z)
loss.backward(retain_graph=True)
print(z, x.grad, y.grad) # 预期打印出的结果都一样
print(t, z.grad) # 预期打印出的结果都一样
print(t.grad)