본문 바로가기

분류 전체보기

(7)
python , typing Annotated , function as argument how to use Annotated[ some_data_type , some_function ] from typing import Annotated# 검증 함수 정의 , define validation function for Annotated type argumentdef validate_positive(value: int) -> int: if value None: validated_value = int_val.__args__[0](value) print(f"Processed value: {validated_value}")try: # 유효한 값 예제, example of valid input value process_value(10) # 출력: Processed value..
Ipopt install on ubuntu , linux , python optimization Ubuntu에서 Ipopt 라이브러리를 설치하는 방법은 크게 두 가지로 나눌 수 있습니다: 패키지 관리자를 통한 설치와 소스 코드에서 직접 빌드하는 방법입니다. 아래에서 두 가지 방법을 단계별로 설명하겠습니다.1. 패키지 관리자를 통한 설치 (권장)Ipopt는 Ubuntu의 패키지 관리자를 통해 쉽게 설치할 수 있습니다. 이 방법은 가장 간단하며, 추가적인 의존성 설치가 필요하지 않습니다.단계별 설치 방법:패키지 업데이트 및 의존성 설치:sudo apt updatesudo apt install -y wgetIpopt 설치:sudo apt install -y coinor-libipopt-dev이 명령은 Ipopt의 개발 라이브러리를 설치하며, 이후 Python과 같은 다른 언어에서 Ipopt를 사용할 수 ..
How to change git branch name and push to remote git repository How to change git branch name and push to remote git repository#git 브랜치 이름 변경 방법 Description:There is a "branch_a".You want to change the name to "branch_b" and push it to remote git repository step #0: open your command terminal and go to your code folder( "git" must be installed ) step #1: checkout to main branchgit checkout main  step #2: Verify current branchesgit branch  step #3 : change lo..
Trains DCGAN on MNIST using Keras '''Trains DCGAN on MNIST using Keras DCGAN is a Generative Adversarial Network (GAN) using CNN. The generator tries to fool the discriminator by generating fake images. The discriminator learns to discriminate real from fake images. The generator + discriminator form an adversarial network. DCGAN trains the discriminator and adversarial networks alternately. During training, not only the discrim..
numpy polynomial evaluation , polyeval usage , drawing with pyplot In [1]: '''Utility for plotting a 2nd deg polynomial and its derivative ''' from __future__ import absolute_import from __future__ import division from __future__ import print_function import numpy as np import matplotlib.pyplot as plt In [5]: # plt.style.use('grayscale') plt.style.use('ggplot') x = np.arange(-1, 2, 0.1) In [6]: # polynomial coefficients c..
matplotlib , pyplot , draw mutile images as N x N square # Let draw images as size 5 x 5 usgin matplotlib , pyplot # result will be like this # Assume you have images to display in 'images'images = x_train[samples] # 25 images in this example # plot the 25 mnist digit images as 5x5import matplotlib.pyplot as pltimport numpy as np plt.figure(figsize=(10,10)) # image sizefor i in range(len(samples)): plt.subplot(5, 5, i + 1) # 5 x 5 format , (i+1)-th po..
Keras , Model Visualization in jupyter notebook & Save to Image File # assume your keras neural net model is 'model' # Display Model in Jupyter notebook# Display Model in Jupyter notebook from IPython.display import SVG from keras.utils.vis_utils import model_to_dot def plot_keras_model(model,show_shapes=True,show_layer_names=True): return SVG(model_to_dot(model,show_shapes=show_shapes,show_layer_names=show_layer_names).create(prog='dot',format='svg')) plot_keras..