diffusion-model/test.ipynb

63 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2024-05-11 18:46:56 +02:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"tensor([[ 1, 2],\n",
" [ 7, 8],\n",
" [13, 14]])\n",
"tensor([[ 3, 4],\n",
" [ 9, 10],\n",
" [15, 16]])\n",
"tensor([[ 5, 6],\n",
" [11, 12],\n",
" [17, 18]])\n"
]
}
],
"source": [
"import torch\n",
"\n",
"# 创建一个大小为(3, 6)的张量\n",
"tensor = torch.tensor([[1, 2, 3, 4, 5, 6],\n",
" [7, 8, 9, 10, 11, 12],\n",
" [13, 14, 15, 16, 17, 18]])\n",
"\n",
"# 沿着第二个维度分成3份\n",
"chunks = tensor.chunk(3, dim=1)\n",
"\n",
"# 打印分割后的张量\n",
"for chunk in chunks:\n",
" print(chunk)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "arch2vec39",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}