-
Keras installation in RPython 2023. 4. 11. 08:45
# install the Tensorflow R package install.packages("tensorflow") # configure R with a Python installation library(reticulate) path_to_python % layer_dense(units = 1, activation = "linear") summary(network) Reference [1] https://tensorflow.rstudio.com/install/ TensorFlow for R - Quick start Prior to using the tensorflow R package you need to install a version of Python and TensorFlow on your sys..
-
Run Python using a Shell ScriptPython 2021. 5. 17. 06:08
Let's say we have the following three files: config.py, main.py and experiments/test.sh. config.py is in charge of (hyper-)parameters in main.py and we'd like to run main.py using test.sh. # config.py import argparse def load_args(): parser = argparse.ArgumentParser() parser.add_argument('--lr', default=1e-3, type=float) parser.add_argument('--h_layers', default=[2, 2, 2], type=lambda s: [int(it..
-
multi processing, threading, multi threadingPython 2020. 9. 11. 20:33
Multiprocessing Pros Separate memory space Code is usually straightforward Takes advantage of multiple CPUs & cores Avoids GIL limitations for cPython Eliminates most needs for synchronization primitives unless if you use shared memory (instead, it's more of a communication model for IPC) Child processes are interruptible/killable Python multiprocessing module includes useful abstractions with a..
-
Regular ExpressionPython 2020. 9. 11. 19:40
문법 설명 예시 . 임의의 한 문자가 존재 .{3} : 문자가 3개 존재 ? 바로 앞의 문자가 존재하거나 존재하지 않음 \d? : 숫자가 하나 있거나 없어야 함 * 바로 앞의 문자가 존재하지 않거나 무한대로 존재 \d* : 숫자가 없거나 하나 이상 + 바로 앞의 문자가 한번 이상 존재 \d+ : 숫자가 하나 이상 ^ 바로 뒤의 문자로 문자열이 시작해야됨 ^abc : abc로 시작해야됨 $ 바로 앞의 문자로 문자열이 끝나야됨 xyz$ : xyz 로 끝나야됨 {숫자} 숫자만큼 반복 \d{3} : 숫자가 3개 있어야됨 {숫자,} 숫자 이상만큼 반복 {숫자1, 숫자2} 숫자1 이상, 숫자2 이하 만큼 반복 \d{3,5} : 숫자가 3|4|5 개 여야됨 (문자열) 문자나 문자열을 묶음 grouping에 사용, e..