본문 바로가기

전체 글144

[Kafka] partition, consumer, producer 관계 (1) parition, consumer, producer 가 정확히 어떻게 작동하는 지 궁금하여 테스트를 해보게 되었다. Spring test와 @EmbeddedKafka를 이용하여 테스트 했다. 이는 producer이다. key는 random으로 아무런 값이나 보내게 된다. @Async //항상 1 전송 public void prodcue1(String mm){ kafkaTemplate.send("fcm",Integer.toString(new Random().nextInt()), mm); System.out.println(String.format("pro %s %s", mm, Thread.currentThread().getId())); } @Async //항상 2 전송 public void produce2(.. 2023. 2. 8.
[다익스트라] 백준 9370 이번 문제는 다익스트라를 통해 풀었다. 원래 처음에는 경로를 추적할 수 있도록, 거리를 측정하는 배열에 [이전 노드, 거리] 값을 저장하도록 했었다. 문제는 다익스트라는 해당 노드까지 최단거리로 갈 수 있는 경로가 많은 경우, g와 h를 포함하지 않을 수 있기 때문에 문제가 되었다. 그래서 s -> g -> h -> 목적지, s -> h -> g -> 목적지를 구하기 위해, s ,g, h를 시작점으로 각각 다익스트라 통해 최단 거리를 구한다. import heapq import sys from collections import deque def djk(board, s, n): hq = [] dst = deque([987654321 for _ in range(n+1)]) heapq.heappush(hq, .. 2023. 1. 29.
[다익스트라] 백준 레이저 통신 이번 문제는 백준 6087 레이저 통신 문제입니다. 다익스트라를 이용해서 풀었습니다. 각 지점의 최소거리(거울 개수)를 구하고, 이를 이용하여 또 다른 레이저 좌표까지 탐색하도록 했습니다. 중요한 점은 이전에 어떤 방향으로 진행했는지 알아야 합니다. 그래야지 거울 개수를 알 수 있기 때문입니다. import heapq def dij(razer_pos, board, r, c): hq = [] direction = {} direction['up'] = {'up':(1,0), 'left':(0,-1), 'right' : (0,1)} direction['down'] = {'down':(-1,0), 'left':(0,-1), 'right' : (0,1)} direction['left'] = {'left' : (0.. 2022. 12. 25.
[프로그래머스] 양과 늑대 접근 방법 단순한 단순탐색 문제. 방문했던 노드로 다시 돌아올 수 있다는 점이 차별점입니다.. 방문했던 노드와 인접한 모든 노드를 탐색하면 됩니다. 저는 lv2인 양궁대회보다 이 문제가 더 쉽다고 느껴졌습니다. import java.util.List; import java.util.ArrayList; class Solution { public int[][] graph = null; public int n = 0; public int maxSheep = 1; public int solution(int[] info, int[][] edges) { this.n = info.length; this.graph = new int[this.n][this.n]; for(int i = 0; i < edges.length.. 2022. 8. 20.
jigsaw puzzle 을 이용한 self-supervised 이번에 소개할 논문은 Unsupervised Learning of Visual Representations by Solving Jigsaw Puzzles 를 이용한 self-supervised 논문입니다. 1. Self-Supervised Learning of Pretext-Invariant Representations(CVPR 2020) 이 논문은 input image와 patch들을 서로 비슷하게 해주도록 하는 것이 목표입니다. 그렇게 해주기 위해서 nce loss를 이용합니다. I' 은 negative sample인데, 여기선 다른 이미지의 feature를 뜻 합니다. s는 cosine similarity 입니다. Dn 은 데이터셋의 부분집합입니다. -log를 취해줌으로써 분모는 작게, 분자는 크게.. 2022. 7. 20.
Improving Robustness to Texture Bias via Shape-focused Augmentation(CVPR 2022) 1. Introduction 이 논문은 모델의 robustness를 키우기 위한 논문입니다. robustness를 키워서 out of domain에서 잘 작동을 하면, in domain에서의 성능이 어느 정도 떨어지는 점을 해결했습니다. 사람은 texture보다 shape을 중점으로 보는 것에 영감을 받아, shape-focused augmentation 방법을 제안합니다. texture bias를 줄일 뿐만이 아니라, shape bias에 더 집중을 할 수 있게끔 합니다. 2. Method 방법은 매우 간단합니다. original image에 각각 다른 augmentation 방법을 적용합니다. 그리고 segmentation model을 이용하여 foreground를 추출하고, 이를 이용하여 backg.. 2022. 6. 23.