update
This commit is contained in:
@ -37,16 +37,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"\n",
|
"\nnumpy array: [[0 1 2]\n [3 4 5]] \ntorch tensor: tensor([[ 0, 1, 2],\n [ 3, 4, 5]], dtype=torch.int32) \ntensor to array: [[0 1 2]\n [3 4 5]]\n"
|
||||||
"numpy array: [[0 1 2]\n",
|
|
||||||
" [3 4 5]] \n",
|
|
||||||
"torch tensor: \n",
|
|
||||||
" 0 1 2\n",
|
|
||||||
" 3 4 5\n",
|
|
||||||
"[torch.LongTensor of size 2x3]\n",
|
|
||||||
" \n",
|
|
||||||
"tensor to array: [[0 1 2]\n",
|
|
||||||
" [3 4 5]]\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -71,16 +62,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"\n",
|
"\nabs \nnumpy: [1 2 1 2] \ntorch: tensor([ 1., 2., 1., 2.])\n"
|
||||||
"abs \n",
|
|
||||||
"numpy: [1 2 1 2] \n",
|
|
||||||
"torch: \n",
|
|
||||||
" 1\n",
|
|
||||||
" 2\n",
|
|
||||||
" 1\n",
|
|
||||||
" 2\n",
|
|
||||||
"[torch.FloatTensor of size 4]\n",
|
|
||||||
"\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -103,12 +85,7 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"\n",
|
"tensor([ 1., 2., 1., 2.])"
|
||||||
" 1\n",
|
|
||||||
" 2\n",
|
|
||||||
" 1\n",
|
|
||||||
" 2\n",
|
|
||||||
"[torch.FloatTensor of size 4]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 4,
|
"execution_count": 4,
|
||||||
@ -129,16 +106,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"\n",
|
"\nsin \nnumpy: [-0.84147098 -0.90929743 0.84147098 0.90929743] \ntorch: tensor([-0.8415, -0.9093, 0.8415, 0.9093])\n"
|
||||||
"sin \n",
|
|
||||||
"numpy: [-0.84147098 -0.90929743 0.84147098 0.90929743] \n",
|
|
||||||
"torch: \n",
|
|
||||||
"-0.8415\n",
|
|
||||||
"-0.9093\n",
|
|
||||||
" 0.8415\n",
|
|
||||||
" 0.9093\n",
|
|
||||||
"[torch.FloatTensor of size 4]\n",
|
|
||||||
"\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -159,12 +127,7 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"\n",
|
"tensor([ 0.2689, 0.1192, 0.7311, 0.8808])"
|
||||||
" 0.2689\n",
|
|
||||||
" 0.1192\n",
|
|
||||||
" 0.7311\n",
|
|
||||||
" 0.8808\n",
|
|
||||||
"[torch.FloatTensor of size 4]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 6,
|
"execution_count": 6,
|
||||||
@ -184,12 +147,7 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"\n",
|
"tensor([ 0.3679, 0.1353, 2.7183, 7.3891])"
|
||||||
" 0.3679\n",
|
|
||||||
" 0.1353\n",
|
|
||||||
" 2.7183\n",
|
|
||||||
" 7.3891\n",
|
|
||||||
"[torch.FloatTensor of size 4]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 7,
|
"execution_count": 7,
|
||||||
@ -210,10 +168,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"\n",
|
"\nmean \nnumpy: 0.0 \ntorch: tensor(0.)\n"
|
||||||
"mean \n",
|
|
||||||
"numpy: 0.0 \n",
|
|
||||||
"torch: 0.0\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -235,15 +190,7 @@
|
|||||||
"name": "stdout",
|
"name": "stdout",
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"\n",
|
"\nmatrix multiplication (matmul) \nnumpy: [[ 7 10]\n [15 22]] \ntorch: tensor([[ 7., 10.],\n [ 15., 22.]])\n"
|
||||||
"matrix multiplication (matmul) \n",
|
|
||||||
"numpy: [[ 7 10]\n",
|
|
||||||
" [15 22]] \n",
|
|
||||||
"torch: \n",
|
|
||||||
" 7 10\n",
|
|
||||||
" 15 22\n",
|
|
||||||
"[torch.FloatTensor of size 2x2]\n",
|
|
||||||
"\n"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -300,19 +247,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 11,
|
"execution_count": 10,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"\n",
|
"tensor([[ 7., 10.],\n [ 15., 22.]])"
|
||||||
" 7 10\n",
|
|
||||||
" 15 22\n",
|
|
||||||
"[torch.FloatTensor of size 2x2]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 11,
|
"execution_count": 10,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@ -323,19 +267,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 12,
|
"execution_count": 11,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"\n",
|
"tensor([[ 1., 4.],\n [ 9., 16.]])"
|
||||||
" 1 4\n",
|
|
||||||
" 9 16\n",
|
|
||||||
"[torch.FloatTensor of size 2x2]"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 12,
|
"execution_count": 11,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"output_type": "execute_result"
|
"output_type": "execute_result"
|
||||||
}
|
}
|
||||||
@ -352,7 +293,7 @@
|
|||||||
{
|
{
|
||||||
"data": {
|
"data": {
|
||||||
"text/plain": [
|
"text/plain": [
|
||||||
"30.0"
|
"tensor(7.)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"execution_count": 13,
|
"execution_count": 13,
|
||||||
@ -361,8 +302,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"torch.dot(torch.Tensor([2, 3]), torch.Tensor([2, 1]))
|
"torch.dot(torch.Tensor([2, 3]), torch.Tensor([2, 1]))"
|
||||||
7.0"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user