반응형

Bounding box 이란?

Bounding box는 이미지 안에서 박스 형태로 위치를 표시해주는 것을 말합니다.

Coordinates 이란?

Coordinates는 좌표라는 뜻을 가지고 있고, 딥러닝에서도 좌표라는 의미로 사용됩니다.

 

Bounding box Coordinates

Bounding box에서 사용되는 coordinate는 보통 center coordinatescorner coordinates입니다. 

기본적으로 center coordinates은 주로 IoU를 계산할 때 사용됩니다. corner coordinates는 anchor나 MSELoss를 계산할 때 사용합니다.

 

 

cx = (x1 + x2) / 2

cy = (y1 + y2) / 2

w = x2 -x1

h = y2 -y1

 

 

 

 

 

 

코드

def corner_to_center(corner_boxes):
    """
    input
    corner_boxes: corner coordinates boxes : [N, 4] (x1, y1, x2, y2)
    output
    center_boxes: center coordinates boxes : [N, 4] (cx, cy, w, h)
    """
    cxcy = (corner_boxes[..., :2] + corner_boxes[..., 2:4]) / 2
    wh = corner_boxes[..., 2:4] - corner_boxes[..., :2]
    centor_boxes = torch.cat([cxcy, wh], dim=-1)
    return centor_boxes
    
    
def center_to_corner(center_boxes):
    """
    input
    center_boxes : center coordinates boxes : [N, 4] (cx, cy, w, h)
    output
    corner_boxes : corner coordinates boxes : [N, 4] (x1, y1, x2, y2)
    """
    x1y1 = center_boxes[..., :2] - (center_boxes[..., 2:4])/2
    x2y2 = center_boxes[..., :2] + (center_boxes[..., 2:4])/2
    corner_boxes = torch.cat([x1y1, x2y2], dim=-1)
    return corner_boxes

 

 

 

 

 

 

반응형

'머신러닝 & 딥러닝 > 용어' 카테고리의 다른 글

[용어]mini batch  (0) 2023.05.14
반응형

end-to-end란?

딥러닝에서 end-to-end의 의미는 입력에서 출력까지 파이프라인 네트워크 없이 신경망으로 한 번에 처리하는 것을 의미합니다.

즉, 복잡한 파이프라인 없이 하나의 신경망으로 입력받은 것을 출력할 수 있다는 것입니다.

 

반응형

end-to-end  장점

- 신경망 모델로 입력 받은 값에 대한 출력 값을 찾아낼 수 있습니다.

- 직접 파이프라인 설계할 필요가 없어집니다.

end-to-end  단점

- 라벨링 된 데이터가 많이 필요합니다.

- 메모리가 부족할 경우 사용할 수 없습니다.

- 복잡한 문제를 해결하기에는 효율적이지 않습니다.

반응형

'머신러닝 & 딥러닝' 카테고리의 다른 글

'NoneType' object has no attribute 'shape'  (0) 2023.04.13
pin_memory란?  (0) 2023.04.11
torchvision.transforms.ToTensor()  (0) 2023.04.10
Data annotation이란?  (0) 2023.04.10
Fully Connected Layers  (0) 2023.04.07
반응형

module 'torch.backends' has no attribute 'mps' 해결 방법

* 현재 Apple M1 pro 사용하고 있습니다.

반응형

 

 상황

- import torch 이후 torch.device('mps:0' if torch.backends.mps.is_available() else 'cpu')로 mps가 잘 되었다가 하루 뒤 

module 'torch.backends' has no attribute 'mps'가 뜨면서 작동하지 않았습니다.

 

해결

저는 일단 Pytorch version 확인 후 update 할려고 했지만 실패해서 다른 방법을 찾다 해결했습니다.

 

1. 가상환경 또는 사용하는 환경에서

   $ pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu

   진행해서 설치 했습니다.

 

해결한 상태에서 확인 한 결과입니다.

import platform
print(platform.platform())

import torch
print(torch.__version__)
-> 2.1.0.dev20230407

print(torch.backends.mps.is_built())
-> True
반응형

'머신러닝 & 딥러닝 > 설정' 카테고리의 다른 글

Apple M1 GPU 사용하는 방법  (0) 2023.04.08
반응형

PyTorch로 GPU 설정

반응형
## PyTorch 설정
import torch

device = torch.device('mps:0' if torch.backends.mps.is_available() else 'cpu')

print (f"PyTorch version:{torch.__version__}") # 1.12.1 이상
print(f"MPS 장치를 지원하도록 build 되었는지 확인: {torch.backends.mps.is_built()}") # True
print(f"MPS 장치가 사용 가능한지 확인: {torch.backends.mps.is_available()}") # True
!python -c 'import platform;print(platform.platform())'

 

결과

 

Tensorflow로 GPU 설정

## tensorflow GPU 설정
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

반응형
반응형

 

목차

  “Fully Connected Layer” 이란?

  “Fully Connected Layer” 구조

  “Fully Connected Layer” 장단점

  "Fully Connected Layer” 코드

  “Fully Connected Layer”에 대한 결론

  참고

 

 

“Fully Connected Layer” 이란?

Fully Connected Layer(=Dense layer)은 한 층(layer)의 모든 뉴런이 다음 층(layer)의 모든 뉴런과 연결된 상태의 층(layer)에서 1차원 배열의 형태로 이미지를 정의된 라벨로 분류하는 계층을 말합니다.


“Fully Connected Layer” 구조

아래 3개의 과정을 Fully Connected Layer의 구조입니다.

  1. 2차원 배열 형태의 이미지를 1차원 배열로 평탄화합니다.
  2. 활성화 함수를 활성화합니다.
  3. softmax 함수로 이미즈를 분류합니다.

“Fully Connected Layer” 장단점

단점

  • 흑백 이미지를 1차원 행렬로 변환하는데 아무 문제가 없지만 컬러이미지를 1차원으로 평탄화 작업을 하게되면 공간 정보가 손실되어 이미지를 분류하는데 한계가 생깁니다.

“Fully Connected Layer” 코드

from keras.models import Sequential

model = Sequential()
model.add(layers.Flatten(input_shape = (28, 28))
model.add(layers.Dense(128, activation='relu'))
model.add(layers.Dense(10, activation='softmax'))

“Fully Connected Layer”에 대한 결론

CNN 구조를 이해하기 위한 밑거름으로 쉽게 layer가 어떻게 구성되어 있는지 알 수 있습니다.


참고

반응형

'머신러닝 & 딥러닝' 카테고리의 다른 글

'NoneType' object has no attribute 'shape'  (0) 2023.04.13
pin_memory란?  (0) 2023.04.11
torchvision.transforms.ToTensor()  (0) 2023.04.10
Data annotation이란?  (0) 2023.04.10
end-to-end란?  (0) 2023.04.09

+ Recent posts