■ 쥘리아 집합을 출력하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import matplotlib.pyplot as pp import numpy as np import tensorflow as tf yNDArray, xNDArray = np.mgrid[-2:2:0.005, -2:2:0.005] zNDArray = xNDArray + 1j * yNDArray zTensor = tf.constant(zNDArray.astype("complex64")) zsVariable = tf.Variable(zTensor) nsVariable = tf.Variable(tf.zeros_like(zTensor, "float32")) tf.InteractiveSession() tf.global_variables_initializer().run() cComplex = complex(0.0, 0.75) zsTensor = zsVariable * zsVariable - cComplex notDivergedTensor = tf.abs(zsTensor) < 4 stepOperation = tf.group(zsVariable.assign(zsTensor), nsVariable.assign_add(tf.cast(notDivergedTensor, "float32"))) for i in range(200): stepOperation.run() pp.imshow(nsVariable.eval()) pp.show() |