내용으로 건너뛰기
Out of the Box
사용자 도구
로그인
사이트 도구
검색
도구
문서 보기
이전 판
역링크
Fold/unfold all
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
추적:
example:qd_grid_visualize
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== Example: QD Grid visualize ====== <code python qd_grid_plot.py> import itertools import matplotlib.pyplot as plt import numpy as np from IPython import embed if __name__ == '__main__': V = [ (0, 0.1), # dim 1 (0, 0.05, 0.1), # dim 2 (-0.05, 0, 0.05, 0.1), # dim 3 (-0.1, -0.05, 0, 0.05, 0.1), # dim 4 (-0.01, 0.0, 0.1), # dim 5 (-0.01, 0.0, 0.1), # dim 6 ] shape = [len(v) for v in V] X = np.array(list(itertools.product(*(range(a) for a in shape)))) hparams = [[v[x[i]] for i, v in enumerate(V)] for x in X] width, height = shape[0::2], shape[1::2] buffer = np.zeros((np.product(height), np.product(width))) def func(xs): return np.sum(xs) def get_idx(idx): assert len(idx) % 2 == 0 y, x = 0, 0 wi, hi = idx[0::2], idx[1::2] # x = idx[0] * width[-1] + idx[2] * 1 # y = idx[1] * height[-1] + idx[3] * 1 # x = wi[-2] * width[-1] + wi[-1] * 1 # y = hi[-2] * height[-1] + idx[-1] * 1 # x = wi[-3] * width[-2] * width[-1] + wi[-2] * width[-1] + wi[-1] * 1 # y = hi[-3] * height[-2] * height[-1] + hi[-2] * height[-1] + idx[-1] * 1 for level in range(len(idx) // 2): dt = np.product(width[-level:]) if level > 0 else 1 x += wi[-(level+1)] * dt dt = np.product(height[-level:]) if level > 0 else 1 y += hi[-(level+1)] * dt return y, x for x, hparam in zip(X, hparams): buffer[get_idx(x)] = func(hparam) plt.imshow(buffer) for level in range(len(height)-1): dt = np.product(height[-(level+1):]) for j in range(buffer.shape[0]): if j % dt == 0: plt.axhline(y=j-0.5, color='k', linewidth=level+1) for level in range(len(width)-1): d = np.product(width[-(level+1):]) for j in range(buffer.shape[1]): if j % d == 0: plt.axvline(x=j-0.5, color='k', linewidth=level+1) plt.show() </code> {{tag>example QD EA visualize}}
example/qd_grid_visualize.txt
· 마지막으로 수정됨:
2024/03/23 02:42
저자
127.0.0.1
문서 도구
문서 보기
이전 판
역링크
Fold/unfold all
맨 위로