Python_Deeplearning_pytorch_01-2(tensor 다루기)
Reshape shape 변경 tensor객체.reshape(*shape) / view(*shape) 이용 - 변환 후 값을 변경하면 원본 배열의 값도 같이 바뀐다. > tensor.clone(): tensor를 복제한다. reshape a=torch.rand(12) a2 = a.reshape(3,4) a3 = a.reshape((3,2,2)) a4 = a.reshape((3,2,-1)) #한 개 axis는 -1로 설정가능하고 그럼 계산해서 알아서 설정해 준다. print(a.shape, a2.size(), a3.shape, a4.shape) view a5 = a.view(3,4) a6 = a.view((3,2,2)) a7 = a.view((3,2,-1)) #한개 axis는 -1로 설정가능 print(a..
Python_opencv_03(도형그리기, 이미지 이동)
도형그리기 각 함수들은 원본 이미지에 도형을 그린다. cv2.line(img, pt1, pt2, color, tickness=None, lineType=None, shift):img** - 선그리기 - 매개변수 - img: 그릴 대상 이미지 - pt1, pt2: 직선의 시작/끝점. 각각 튜플(x, y) - color: 선색 또는 밝기 (B,G,R) 튜플 또는 정수 - thickness: 선 두께. 기본값=1 (픽셀) - lineType: 선 타입. cv2.LINE_4, cv2.LINE_8(기본값), cv2.LINE_AA(부드러운 형태) 중 선택. 일직선이 아니 면 LINE_AA를 준다. - 반환값 - 선을 그린 image (ndarray) 반환 (모든 도형함수 동일) cv2.rectangle(img, p..