Imagination is more important than knowledge (지식보다 상상)

Sources

Posts

97 posts

가장 쉬운 국소 최소화 [python]

가장 쉬운 국소 최소화 [python] 목적함수의 일차 도함수를 알수 있는 경우, 해석적으로 알 수 있는 경우, 국소 최소화는 아주 빨리 마무리 될 수 있다.일차 도함수가 알려지지 않은 경우, 별도의 알고리듬을 활용한다. import numpy as npfrom scipy.optimize import minimizedef rosen(x): """The Rosenbrock function""" return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)def rosen_der(x): xm = x[1:-1] xm_m1 = x[:-2] xm_p1 = x[2:] der = np.zeros_like(x) der[1:-1

가장 쉬운 출력문 [f-string in python 3.6]

가장 쉬운 출력문 [f-string in python 3.6]파이썬 출력의 새로운 유형, f-string. f-string을 활용하면 파이썬에서 출력이 보다 더 편리할 수 있다.또한, 출력에 소모되는 시간도 줄일 수 있다. 파이썬 2.x 시대는 지나가고 있다. 파이썬 3.6 시대가 도래했다. f-stringThe f in f-strings may as well stand for “fast.” # notice that it adds spaces to reach the number of characters specified by widthIn [1]: f'{1 + 3 * 1.5:10.3f}'Out[1]: ' 5.500'# notice that it uses more characters than

가장 쉬운 차분 진화 (differential evolution) [python]

가장 쉬운 차분 진화 (differential evolution) [python] import random from scipy.optimize import minimize import numpy as np def functuser(x): case=3 if case == 1: total=0. for j in range(len(x)): total+=(x[j])**2 if case == 2: # Rastrigin total=10.*len(x) for j in range(len(x)): total+=x[j]**2-10.*np.cos(2.*np.pi*x[j])

가장 쉬운 입자군집 최적화 (PSO) 예제 [python]

가장 쉬운 입자군집 최적화 (PSO) 예제 [python]particle swarm optimization algorithm ------------------------------------------------------------------------------------------------------------------------import random import numpy as np from scipy.optimize import minimize def functuser(x): case=3 if case == 1: total=0. for j in range(len(x)): total+=(x[j])**2

가장 쉬운 CNN (convolutional neural network) 예제

가장 쉬운 CNN (convolutional neural network) 예제 Source: ------------------------------------------------------------------------------------------------------------------------import numpy as npfrom keras.models import Sequentialfrom keras.layers import Dense, Dropout, Activation, Flatten, Conv2D, poolingfrom keras.utils import np_utilsfrom keras.datasets import mnist np.random.seed(123)