본문 바로가기

분류 전체보기

(284)
(softeer) 로봇이 지나간 길 import sys def start(y, x): global maxx, maxy, direc, direcnum #4구석탱이인 경우나 하나 구석인 경우나 4면 다 뚫린 경우 dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] cnt, dirr = 0, 0 for i in range(4): nx, ny = x + dx[i], y + dy[i] if nx = maxy or nx >= maxx: continue if mp[ny][nx] == '#': cnt = cnt+1 dirr = i if cnt == 1: if dirr == 0 : direc, direcnum = '>', 0 elif dirr == 1: direc, direcnum = 'v', 1 el..
[softeer] 업무처리 import sys # input()을 ' '로 split, 이후 int로 mapping height, job, day = map(int, input().split()) # print(height, job, day) head_job = 0 # output, 보스가 처리한 일 all_node = 2 ** (height + 1) # 1부터 시작, 보스는 1 final_slave = (all_node) // 2 # 말단직원 수 slave = [] for i in range(all_node): if i > (final_slave - 1) : a = list(map(int, input().split())) slave.append(a) else : slave.append([]) # print(slave) for i..
[프로그래머스] 둘만의 암호 def solution(s, skip, index): answer = '' full_text = 'abcdefghijklmnopqrstuvwxyz' adapt_text = '' for i in range(len(full_text)): if full_text[i] in skip: continue adapt_text += full_text[i] for i in range(len(s)) : if s[i] in adapt_text : idx = adapt_text.index(s[i]) + index # if idx >= len(full_text) : idx = idx % len(adapt_text) answer += adapt_text[idx] return answer 딱히 어려운 건 없지만, 알아두면 좋은 함..
[softeer] 성적평가 import sys n = int(input()) # arr = [list(map(int, input().split())) for _ in range(3)] arr = [] value = [] # 총점수 계산 for i in range(3): tmplst = list(map(int, input().split())) tmp = [] tmpval = [0] * n for j in range(len(tmplst)): tmp.append((tmplst[j], j)) tmpval[j] += tmplst[j] arr.append(tmp) totalval = [] for i in range(n): totalval.append([0, i]) # pair을 만들고, 정렬시키자. prize = [1] * n for i i..
[Softeer] 금고 관리 import sys # 70*2 + 30*1 = 170, 자를 수 있다. 따라서 챙길 수 있는 것중 가장 비싼건 무조건 챙겨야됨. input = sys.stdin.readline wgt, cnt = map(int, input().split()) lst = [] lst = [list(map(int, input().split())) for _ in range(cnt)] # for i in range(cnt): # much, price = map(int, input().split()) # lst.append((price, much)) lst.sort(key = lambda x : x[1], reverse=True) posb, curprice, idx = wgt,0, 0 while posb > 0: if pos..
[Optical Flow] RAFT 이해를 위한 여러 함수 정리글 torch.meshgrid 정리 - raft.py의 coords0, coords1 = self.initialize_flow(image1) 를 실행할 경우 행해지는 함수들 width, height = 128, 64 coords = torch.meshgrid(torch.arange(width//8), torch.arange(height//8)) # 16, 8 print(coords) print('------------------------------') print(coords[::-1]) print('------------------------------') coords = torch.stack(coords[::-1], dim=0).float() # print(coords) print('-----------..
[chatGPT] 파이썬, LSTM 혹은 numpy, torch 질답 모음 The "forget gate" is a crucial component of the Long Short-Term Memory (LSTM) network, which is a type of recurrent neural network that is designed to handle sequence data. The forget gate is responsible for selectively forgetting or remembering information from the previous time step. In an LSTM network, the forget gate is implemented using a sigmoid activation function and a set of weights and..
Optical Flow의 RAFT GRU 이해를 위한 RNN/LSTM/GRU An RNN built with matrices and trained with SGD (explained.ai) Explaining RNNs without neural networks This article explains how recurrent neural networks (RNN's) work without using the neural network metaphor. It uses a visually-focused data-transformation perspective to show how RNNs encode variable-length input vectors as fixed-length embeddings. Include explained.ai RNN에서는 가중치를 3개를 쓰는데, 1) 임..