[리트코드] 3620. Network Recovery Pathways
·
알고리즘연구소👨‍💻/혼자서는 세상을 구할 수 없다.
문제 내용과 입력You are given a directed acyclic graph of n nodes numbered from 0 to n − 1. This is represented by a 2D array edges of length m, where edges[i] = [ui, vi, costi] indicates a one‑way communication from node ui to node vi with a recovery cost of costi.Some nodes may be offline. You are given a boolean array online where online[i] = true means node i is online. Nodes 0 and n − 1 are always..
[리트코드] 3753. Total Waviness of Numbers in Range II
·
알고리즘연구소👨‍💻/혼자서는 세상을 구할 수 없다.
문제내용You are given two integers num1 and num2 representing an inclusive range [num1, num2].The waviness of a number is defined as the total count of its peaks and valleys:A digit is a peak if it is strictly greater than both of its immediate neighbors.A digit is a valley if it is strictly less than both of its immediate neighbors.The first and last digits of a number cannot be peaks or valleys.An..
[AI] ADAM: A METHOD FOR STOCHASTIC OPTIMIZATION (1)
·
CS연구소👨‍💻
유튜브, 강의등에서 AI를 풀어서 설명해주는걸 듣다보면 뭔가 다 알고있는것 같다. 하지만 그런 마음가짐으로 논문을 보면, 모든게 어지러워진다. 사실 내가 전혀 모르고 있는거다.모르는걸 마주할때마다 주먹구구 식으로 넘어가는게 극히 싫기 때문에,내 여태까지 삶에서 유효했던 발전 방법으로 논문을 접해보려고한다. Adam 알고리즘의 핵심 처음 고른 논문은 Adam 손실함수를 최적화해주는 함수라는건 다 안다. 하지만 어떻게? 여기부터가 의문의 시작이다. 직접 부딪혀보자. 초반에 등장해서 바로 복잡해보이게 하는 이 식은, 알고보니 ADAM의 핵심 알고리즘이었다. 초기값들을 먼저 정리해보자.최적화 알고리즘 변수 정의$g_t$: 기울기를 의미하는 벡터이다.$f(\theta)$: $\theta$ 벡터를 입력으로 받아 l..
[AI] 왜 샘플링이 beam search보다 많이 쓰이는가?
·
CS연구소👨‍💻
해당 글은 허깅페이스 블로그중 아래 글을 참조해 및 정리한 내용입니다.https://huggingface.co/blog/how-to-generate디코딩이란?디코딩 자체는 연속된 확률 분포에터 토큰을 뽑아내는 일에 지나지 않는다. 현대 생성형 모델은 전부 다 디코딩만으로 모든 질문이나 태스크의 대답을 출력해내고 있다.충분히 다양해진 AI모델들에 마주하다보면 모델별로 다른 디코딩 방식을 활용한 다는 걸 알 수 있다.방식은 크게,그리디 디코딩(Greedy Decoding),빔서치 (Beam Search),샘플링 (p | k Sampling),등으로 나눌 수 있다. 이렇게 디코딩방식들을 보다가 다음 궁금증이 생겼다.왜 OCR, Whisper은 그리디 디코딩을 쓰고 일반 생성형 모델은 샘플링을 활용하는가?그리고..
[리트코드] 1665. Minimum Initial Energy to Finish Tasks
·
알고리즘연구소👨‍💻/리트코드
문제 상황You are given an array tasks where tasks[i] = [actuali, minimumi]:actuali is the actual amount of energy you spend to finish the ith task.minimumi is the minimum amount of energy you require to begin the ith task.For example, if the task is [10, 12] and your current energy is 11, you cannot start this task. However, if your current energy is 13, you can complete this task, and your energy w..
[리트코드] 3474. Lexicographically Smallest Generated String
·
알고리즘연구소👨‍💻/혼자서는 세상을 구할 수 없다.
역시나 리트코드 오늘의 문제 난이도가 날이 갈수록 올라가고있다고 느낀다. 무려 힌트가 6개인 하드문제다. 일단 문제부터 보면. 문제You are given two strings, str1 and str2, of lengths n and m, respectively.A string word of length n + m - 1 is defined to be generated by str1 and str2 if it satisfies the following conditions for each index 0 If str1[i] == 'T', the substring of word with size m starting at index i is equal to str2, i.e., word[i..(i + m - ..