본문 바로가기

분류 전체보기

(153)
zip(), copy(), deepcopy() 1. zip() - 여러개의 순회 가능한(iterable) 객체를 인자로 받음 - 각 객체가 갖고 있는 요소를 튜플 형태로 반복자(iterator)를 반환함 - 두 객체의 각 인덱스를 묶음 A_list = [0, 1, 2] B_list = ['A', 'B', 'C'] for A_B in zip(A_list, B_list): print(A_B) 2. copy() - 1차원 시퀀스 복사 a = [1,2,3] b = a.copy() print(a) print(b) b[0] = 4 print(a) print(b) 수정도 자유자재로 가능하다 - 2차원 이상의 리스트, 배열에서는 문제 발생함 a = [[1,2,3],[4,5,6]] b = a.copy() print(a) print(b) b[0][0] = 7 prin..
np.array, ToTensor, ToPILImage 공부 https://supermemi.tistory.com/entry/Python-PIL-PIL-%EC%9D%B4%EB%AF%B8%EC%A7%80%EC%99%80-TorchTensor-%EB%B3%80%ED%99%98-transforms-1 [ Python / PIL ] PIL 이미지와 Torch.Tensor 변환 (ToTensor, ToPILImage) 2021.12.29 - [Computer Language/Python] - [ Python / PIL ] PIL 이미지, Numpy 배열 변환 및 저장 ( Image.fromarray(), np.array(), np.asarray() ) [ Python / PIL ] PIL 이미지, Numpy 배열 변환 및 저장 ( Image.fromarray(), np.a..
[Softeer] A+B - 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. [풀이 1] import sys n = sys.stdin.readline() i = 1 for _ in range(int(n)): a, b = map(int, sys.stdin.readline().split()) print(f'Case #{i}:', a+b) i +=1 [풀이 2] import sys i=1 lines = sys.stdin.readlines() for line in lines: if line.find(" ")==1: line = line.replace('\n', '') A, B = map(int, line.split(" ")) if 1
[Softeer] 근무 시간 - 근무시간 확인 프로그램 - 5일간 몇분 일했는지 계산하기 [풀이 1] import sys lines = sys.stdin.readlines() result = 0 for line in lines: a, b = map(str, line.split()) a_h, a_m =map(int, a.split(":")) b_h, b_m =map(int, b.split(":")) if b_mA_m[i]: compute_time += 60*(B_h[i]-A_h[i])+(B_m[i]-A_m[i]) elif B_m[i]
Attention mechanism * Multi-head Self-Attention - attention filter가 이미지가 들어왔을 때 어디에 강조할 지를 결정하는 것 - filter weiggt에 따라 강조하고 싶은 부분을 각각 attention 가능 - inductive bias가 적음 * ross-attention - correlation layer를 통해 이미지 간의 correlation 정보 학습 가능 - 적은 이미지를 가지고 학습을 할때 이를 통해 강조 가능 *Stand-alone Self-Attention - 지역적인 부분을 계산 - local과 gloabal 정보 계산 가능
[Softeer] 주행거리 비교하기 a, b = map(int, input().split()) if a>b: print("A") elif b>a: print("B") else: print("same")
[Softeer] 비밀 메뉴 - 식권 자판기의 버튼을 특정 순서대로 누르고 결제 하면 평소와 다른 색깔의 식권이 나옴 -> 비밀 식권 - K개의 자판기 버튼 - M개의 버튼 조작을 통해 비밀 메뉴 식원 발매 - N개의 사용자 버튼 M, N, K = map(int, input().split()) secret_list = list(map(int, input().split())) user_list = list(map(int, input().split())) secret_str = ' '.join(map(str, secret_list)) user_str = ' '.join(map(str, user_list)) if user_str.find(secret_str)!=-1: print('secret') else: print('normal')
[Softeer] 장애물 인식 프로그램 파이썬 * DFS 깊이 우선 탐색을 이용하는 문제 * 문제 조건 : 블록은 좌우 , 위아래 로만 연결 가능 * 상하좌우를 파악한 후 주변 값이 1이면 방문. * 한번 방문한 곳은 방문하지 않음 * 방문하지 않은 지점을 카운트 import sys #---- DFS ----# def dfs(x, y, graph, visited): if x = len(graph) or y = len(graph[0]): return 0 if graph[x][y] == 0 or visited[x][y]: return 0 visited[x][y] = True size = 1 size += dfs(x - 1, y, graph, visited) size += dfs(x, y - 1, graph, visit..

728x90