We can see that the first graph in the dataset contains 37 nodes, each one having 3 features.
There are 168/2 = 84 undirected edges and the graph is assigned to exactly one class.
In addition, the data object is holding exactly one graph-level target.
We can even use slices, long or bool tensors to split the dataset.
*E.g.*, to create a 90/10 train/test split, type:
데이터셋의 첫 번째 그래프에는 37개의 노드가 있으며, 각 노드에는 3개의 피쳐가 있는 것을 확인할 수 있습니다.
168/2 = 84개의 방향성이 없는 엣지가 있고 그래프는 정확히 하나의 클래스에 할당되어 있습니다.
또한, 데이터 객체는 정확히 하나의 그래프 수준의 타겟을 가지고 있습니다.
슬라이스(slices), 롱(long) 또는 부울(bool) 텐서를 사용하여 데이터 셋을 분할할 수도 있습니다.
*예시*, 90/10 학습/테스트 분할(train/test split)을 하려면, 다음을 입력하십시오:
.. code-block:: python
...
...
@@ -210,7 +211,7 @@ We can even use slices, long or bool tensors to split the dataset.
dataset.num_node_features
>>> 1433
여기 이 데이터셋에는 방향이 없는 인용 그래프(citation graph) 하나만 포함되어 있습니다:
여기 이 데이터셋에는 방향성이 없는 인용 그래프(citation graph) 하나만 포함되어 있습니다:
.. code-block:: python
...
...
@@ -231,24 +232,26 @@ We can even use slices, long or bool tensors to split the dataset.
>>> 1000
This time, the :class:`~torch_geometric.data.Data` objects holds a label for each node, and additional node-level attributes: :obj:`train_mask`, :obj:`val_mask` and :obj:`test_mask`, where
이번에는, `~torch_geometric.data.Data` 클래스(class)의 객체에 각 노드의 레이블과 추가적인 노드 수준의 속성(attribute)인 `train_mask`, `val_mask`, `test_mask`가 있습니다:
- :obj:`train_mask` denotes against which nodes to train (140 nodes),
- :obj:`val_mask` denotes which nodes to use for validation, *e.g.*, to perform early stopping (500 nodes),
- :obj:`test_mask` denotes against which nodes to test (1000 nodes).
- `train_mask`는 훈련할 노드(140개 노드)를 나타냅니다,
- `val_mask`는 검증 단계(validation)에서, *예를 들어*, 조기 종료(early stopping)시키기 위해 사용할 노드(500개 노드)를 나타냅니다,
- `test_mask` 테스트할 노드(1000개 노드)를 나타냅니다.
Mini-batches
미니 배치(Mini-batches)
------------
Neural networks are usually trained in a batch-wise fashion.
:pyg:`PyG` achieves parallelization over a mini-batch by creating sparse block diagonal adjacency matrices (defined by :obj:`edge_index`) and concatenating feature and target matrices in the node dimension.
This composition allows differing number of nodes and edges over examples in one batch:
신경망(Neural network)은 주로 배치 별 학습 방식을 사용합니다.
`PyG` 희소 블록 대각 인접 행렬(sparse block diagonal adjacency matrix, `edge_index`로 정의됨)을 만들고 노드의 차원으로 특징(feature)과 타겟 행렬을 결합(concatenate)해서 미니 배치를 활용한 병렬화를 가능하게 합니다.
이 구성에 따라 예제마다 하나의 배치당 노드 개수와 엣지 개수를 다르게 가져갈 수 있습니다:
:pyg:`PyG` contains its own :class:`torch_geometric.loader.DataLoader`, which already takes care of this concatenation process.
Let's learn about it in an example:
`PyG`는 이미 이러한 결합(concatenation) 프로세스를 처리하는 자체적인 `torch_geometric.loader.DataLoader` 클래스(class)를 가지고 있습니다.
예시를 통해 배워봅시다:
.. code-block:: python
...
...
@@ -265,15 +268,15 @@ Let's learn about it in an example:
batch.num_graphs
>>> 32
:class:`torch_geometric.data.Batch` inherits from :class:`torch_geometric.data.Data` and contains an additional attribute called :obj:`batch`.
`torch_geometric.data.Batch` 클래스(class)는 `torch_geometric.data.Data` 클래스(class)로부터 상속을 받으며 `batch`라는 추가적인 속성(attribute)을 갖습니다.
:obj:`batch` is a column vector which maps each node to its respective graph in the batch:
`batch`는 배치에서 각 노드를 그것이 속하는 그래프에 매핑하는 열 벡터입니다:
.. math::
\mathrm{batch} = {\begin{bmatrix} 0 & \cdots & 0 & 1 & \cdots & n - 2 & n -1 & \cdots & n - 1 \end{bmatrix}}^{\top}
You can use it to, *e.g.*, average node features in the node dimension for each graph individually:
이것은, 예를 들어 각 그래프에 속한 노드들의 특징(feature)을 노드 차원에서 평균화하는 데 사용할 수 있습니다:
.. code-block:: python
...
...
@@ -296,7 +299,9 @@ You can use it to, *e.g.*, average node features in the node dimension for each
>>> torch.Size([32, 21])
You can learn more about the internal batching procedure of :pyg:`PyG`, *e.g.*, how to modify its behavior, `here <../advanced/batching.html>`__.
`여기 <../advanced/batching.html>`__ 서 `PyG`의 내부 배치 처리 기법(예: 배치의 동작을 수정하는 방법)에 대해 더 자세히 알아볼 수 있습니다.
For documentation of scatter operations, we refer the interested reader to the :obj:`torch_scatter` `documentation <https://pytorch-scatter.readthedocs.io>`_.
scatter 연산에 대해 관심 있는 독자분들은 `torch_scatter` `documentation <https://pytorch-scatter.readthedocs.io>`_ 를 참조하시기 바랍니다.