본문 바로가기
문자열 분리 문자열분리 * 알고리즘 문제를 풀다 보면 문자열을 일정크기로 잘라야하는 경우가 있다. def get_splits(s, split_len): return [s[i:i+split_len] for i in range(0, len(s), split_len)] text = 'asdfhlkasdfjhlasdf' print(get_splits(text, 2)) # ['as', 'df', 'hl', 'ka', 'sd', 'fj', 'hl', 'as', 'df'] print(get_splits(text, 4)) # ['asdf', 'hlka', 'sdfj', 'hlas', 'df'] print(get_splits(text, 3)) # ['asd', 'fhl', 'kas', 'dfj', 'hla', 'sdf'] 2022. 4. 25.
CUDA_HOME environment variable is not set. Please set it to your CUDA install root for pytorch cpp extensions 1. Probelm Description - Mostly, this error comes from not setting path for nvcc - so first check the nvcc using `nvcc --version` - nvidia-smi is not related # nvidia-smi command works fine You can't use 'macro parameter character #' in math mode nvcc --version 2. Solution - setting correct path in ~/.bashrc or ~/.zshrc depending on shell you are using $ vi ~/.zshrc # adding below at the end of script # export P.. 2022. 4. 24.
[Python] List cannot be an element in a set; use Tuple You can't add a list to a set because lists are mutable, meaning that you can change the contents of the list after adding it to the set. Ref https://stackoverflow.com/questions/1306631/add-list-to-set 2022. 4. 23.
시뮬레이션 - 방향설정 방향바꾸기 알고리즘 문제를 풀다 보면 방향을 바꾸어야 될 필요성이 있다 현재 방향에서 왼쪽 또는 오른쪽 이때 dx, dy 를 설정하고 direction으로 방향 인덱스를 바꾼다. # 동, 북, 서, 남 # 0, 1, 2, 3 dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] # 동쪽 direction = 0 dx[direction] == 1 dy[direction] == 0 # 동쪽에서 북쪽으로 왼쪽으로 방향을 바꾼다 direction += 1 dx[direction] == 0 dy[direction] == 1 # 북쪽에서 서쪽으로 왼쪽으로 방향을 바꾼다 direction += 1 dx[direction] == -1 dy[direction] == 0 # 서쪽에서 북쪽으로 오른쪽으로 방향.. 2022. 4. 21.
Rotate Matrix def rotate_matrix(grid): return list(map(list, zip(*reversed(grid)))) def print_matrix(grid): for row in grid: print(row) print('----') grid = [['1', '2'], ['.', '0']] # check original matrix print_matrix(grid) # reverse the outer list print_matrix(list(reversed(grid))) # zip the reversed list print_matrix(rotate_matrix(grid)) Ref https://stackoverflow.com/questions/53242961/rotating-a-list-of-l.. 2022. 4. 16.
Git multiple accounts / 깃 다중 계정 Git Multiple Account Management 1. ssh generation ssh-keygen -t rsa -C "user1@naver.com" -f "work" ssh-keygen -t rsa -C "user2@gmail.com" -f "private" 2. Adding public key to each Git accounts pbcopy < ~/.ssh/work.pub pbcopy < ~/.ssh/private.pub 3. Register each ssh entries to ssh-agent # Check Currnet Entries You can't use 'macro parameter character #' in math mode ssh-add ~/.ssh/work $ ssh-add ~/.ssh/private 4. Editin.. 2022. 4. 13.
BART: Denoising Sequence-to-Sequence Pre-training for NaturalLanguage Generation, Translation, and Comprehension - BART BART: A Robustly Optimized BERT Pretraining Approach Paper : https://arxiv.org/pdf/1910.13461.pdf Abstract BART a denoising autoencoder for pretraining sequence-to-sequence models. BART is trained by corrupting text with an arbitrary noising function learning a model to reconstruct the original text uses a standard Tranformer-based neural machine translation architecture which, despite its simpl.. 2022. 4. 1.
RoBERTa: A Robustly Optimized BERT Pretraining Approach - RoBERTa RoBERTa: A Robustly Optimized BERT Pretraining Approach Paper : https://arxiv.org/pdf/1907.11692.pdf Code : https://github.com/pytorch/fairseq GitHub - pytorch/fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in Python. Facebook AI Research Sequence-to-Sequence Toolkit written in Python. - GitHub - pytorch/fairseq: Facebook AI Research Sequence-to-Sequence Toolkit written in Py.. 2022. 3. 27.
Python - argparse module part2) In [1]: from IPython.core.display import display, HTML display(HTML("")) View Source Python argparse Part2)¶usuage of argparse python module - Attempt1. Making parser arguments precedes over config.json - Attempt2. Handling multiple parameters for parser argument using json format - Goal. Handling model parameters in depth and changing default setting using config.json Attempt 1. Making parser a.. 2022. 3. 15.