본문 바로가기
728x90
반응형
SMALL

Python Library180

[Matplotlib] WARNING:matplotlib.font_manager:findfont: Font family 'NanumGothic' not found 폰트 깨짐 문제 한글 폰트를 설정해 주지 않으면 한국어가 깨져서 나오는 문제가 발생한다. 폰트 설치 !apt-get -qq install fonts-nanum 예제 import os import matplotlib.pyplot as plt from matplotlib import font_manager import matplotlib.font_manager as fm fe = fm.FontEntry( fname=r'/usr/share/fonts/truetype/nanum/NanumGothic.ttf', # ttf 파일이 저장되어 있는 경로 name='NanumGothic') # 원하는 폰트 설정 fm.fontManager.ttflist.insert(0, fe) # Matplotlib에 폰트 추가 plt... 2024. 4. 12.
[Keras] 모델 플롯 유틸리티 plot_model 함수 keras.utils.plot_model( model, to_file="model.png", show_shapes=False, show_dtype=False, show_layer_names=False, rankdir="TB", expand_nested=False, dpi=200, show_layer_activations=False, show_trainable=False, **kwargs ) model_to_dot 함수 keras.utils.model_to_dot( model, show_shapes=False, show_dtype=False, show_layer_names=True, rankdir="TB", expand_nested=False, dpi=200, subgraph=Fa.. 2024. 4. 2.
[Keras] 멀티모달 함의 분류 (2) 데이터 입력 파이프라인 구축 TensorFlow Hub는 다양한 BERT 계열의 모델을 제공한다. 각 모델에는 해당하는 전처리 계층이 함께 제공된다. 리소스에서 이러한 모델과 해당 전처리 계층에 대해 더 자세히 알 수 있다. 런타임을 짧게 하기 위해 원래 BERT 모델의 더 작은 변형을 사용한다. # Define TF Hub paths to the BERT encoder and its preprocessor bert_model_path = ( "https://tfhub.dev/tensorflow/small_bert/bert_en_uncased_L-2_H-256_A-4/1" ) bert_preprocess_path = "https://tfhub.dev/tensorflow/bert_en_uncased_pre.. 2024. 4. 2.
[Keras] 멀티모달 함의 분류 (1) 멀티모달 함의 분류 멀티모달 함의를 예측하기 위한 모델을 구축하고 훈련한다. Google Research에서 소개한 다중 모드 수반성 데이터 세트 multimodal entailment dataset를 사용한다. 멀티모달 함의란 소셜 미디어 플랫폼에서는 콘텐츠를 감사하고 중간 정도의 콘텐츠를 제공하기 위해 거의 실시간으로 다음 질문에 대한 답을 찾고자 할 수 있다. 주어진 정보는 다른 정보와 모순 (contradict) 되는지? 주어진 정보는 다른 정보를 의미 ( imply)하는지? 자연어 처리에서 이 작업은 텍스트 함의 분석이라고 한다. 이것은 정보가 텍스트 콘텐츠에서 나올 때만 해당된다. 실제로 사용 가능한 정보는 텍스트 콘텐츠뿐만 아니라 텍스트, 이미지, 오디오, 비디오 등의 멀티모달 조합에서 나오.. 2024. 3. 30.
[PyTorch] AssertionError: Torch not compiled with CUDA enabled 소제목 입력 torch와 cuda 버전이 맞지 않아 출력되는 에러이다. 따라서, 공식 홈페이지에서 가이드대로 설치를 진행한다. 현재 Windows의 PyTorch는 Python 3.8 ~ 3.11만 지원하고 Python 2.x는 지원되지 않으므로 torch 가상 환경으로 파이썬 버전을 설치한다. conda create --name torch python=3.9 torch 가상 환경을 활성화하고 CUDA 11.8 또는 12.1을 설치한다. pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 그 다음, GPU를 사용하는 확인하기 위해 device를 출력해 본다. import torch devic.. 2024. 3. 19.
[Windows] NVIDIA GPU 사용을 위한 WSL2에 Tensorflow 및 Keras 설치 NVIDIA Driver NVIDIA에서 제품에 맞는 드라이버를 설치한다. WSL2 설치 PowerShell에서 WLS2를 설치한다. wls --install PowerShell에서 nvidia-smi 명령으로 GPU 서버를 확인한다. nvidia-smi Miniconda 설치 Miniconda Windows 프로그램을 설치한다. 콘다 환경 만들기 다음 명령을 사용하여 tf 라는 새 conda 환경을 만든다. conda create --name tf python=3.9 가상 환경 활성화에서 에러가 발생한다면 PowerShell 실행 정책을 변경해야 한다. CommandNotFoundError: Your shell has not been properly configured to use 'conda acti.. 2024. 2. 15.
ITK ITK ITK (Insight Toolkit)는 N차원 과학 이미지 처리, 분할 및 registration을 위한 오픈 소스 크로스 플랫폼 도구 키트이다. 모두를 위한 리소스이며 ITK 고급 알고리즘의 모든 기능을 활용하는 데 도움이 되는 튜토리얼, 예제 및 모범 사례가 포함되어 있다. pip install itk https://docs.itk.org/en/latest/download.html Download ITK 💾 Current release: More information on this release can be found in the release notes. Python packages: To install the ITK Python packages, Additionally, wheels fo.. 2023. 11. 29.
[Keras] ImageDataGenerator class weight ImageDataGenerator class weight 딥러닝시 이미지 데이터의 불균형 문제를 해결하기 위해 class에 따른 가중치를 다르게 부여할 수 있다. from sklearn.utils import compute_class_weight import numpy as np train_classes = train_generator.classes class_weights = compute_class_weight( class_weight = "balanced", classes = np.unique(train_classes), y = train_classes ) class_weights = dict(zip(np.unique(train_classes), class_weights)) model.fit_gen.. 2023. 9. 8.
[Matplotlib] 초기화 메서드 cla() cla() 명령은 Matplotlib에서 현재 축을 지우는 데 사용된다. ‘축’은 단순히 그림의 일부이며 일반적으로 서브 플롯과 세부 정보이다. import math import numpy as np import matplotlib.pyplot as plt x=np.linspace(0,2*math.pi,100) y1=np.sin(x) y2=np.cos(x) fig,ax=plt.subplots(2,1) ax[0].plot(x,y1) ax[0].set_xlabel("x") ax[0].set_ylabel("sinx") ax[0].set_title("Plot of sinx") ax[1].plot(x,y2) ax[1].set_xlabel("x") ax[1].set_ylabel("cosx") ax[1]... 2023. 9. 4.
[SciPy] 사비츠키-골레이 필터 (Savitzky-Golay Filter) 사비츠키-골레이 필터 (Savitzky-Golay Filter) 사비츠키-골레이 (Savitzky-Golay) 평활화 필터는 잡음이 일부 섞여 있지만 잡음 없는 영역이 주파수 범위의 큰 부분을 차지하는 신호를 "평활화"하는 데 사용된다. 이 필터는 디지털 평활화 다항식 필터 또는 최소제곱 평활화 필터라고도 한다. 사비츠키-골레이 평활화 필터는 표준 평균 FIR 필터보다 신호의 고주파 성분을 적게 제거하는 경향이 있다. 일부 응용 사례에서는 표준 평균 FIR 필터보다 사비츠키-골레이 필터가 성능이 더 좋다. 표준 평균 FIR 필터는 잡음과 함께 고주파 성분도 필터링하는 경향이 있다. 그러나 잡음 수준이 특히 높은 경우 잡음 제거 측면에서는 표준 평균 FIR 필터보다 효율이 떨어진다. 사비츠키-골레이 필터는.. 2023. 8. 3.
728x90
반응형
LIST