'' 'シミュレーションのためのインポートライブラリ' ''は<IPython.core.display.Imageオブジェクト>
import tensorflow as tf
import numpy as np
'' '可視化のための輸入'」であります「
from PIL.Image
from io import BytesIO
from IPython.display import Image, display
『』」今、我々は 反復回数「」」
def DisplayFractal(a, fmt='jpeg'):
img =np.concatenate([10+20*np.cos(a_cyclic),30+50*np.sin(a_cyclic),155-
80*np.cos(a_cyclic)], 2)
img[a==a.max()] = 0
a = img
a = np.uint8(np.clip(a, 0, 255))
f = BytesIO()
PIL.Image.fromarray(a).save(f, fmt)
display(Image(data=f.getvalue()))
sess = tf.InteractiveSession()
# Use NumPy to create a 2D array of complex numbers
Y, X = np.mgrid[-1.3:1.3:0.005, -2:1:0.005]
Z = X+1j*Y
print(Z)
#Now we define and initialize TensorFlow tensors.
xs = tf.constant(Z.astype(np.complex64))
zs = tf.Variable(xs)
ns = tf.Variable(tf.zeros_like(xs, tf.float32))
tf.global_variables_initializer().run()
zs_ = zs*zs + xs
print(zs)
# Have we diverged with this new value?
not_diverged = tf.abs(zs_) < 4
を持っていたら、実際に画像を表示する機能を定義します10
'' ' zsと反復回数を更新する操作。 注:コンピューティングzは分岐した後も維持されます。この は非常に無駄です!少しでも良い場合は、 シンプルで、これを行う方法があります。 ''」 ステップ= tf.group(zs.assign(zs_)、ns.assign_add(tf.cast(not_diverged、 tf.float32)))
for i in range(200): step.run()
DisplayFractal(ns.eval())
質問する必要がある質問についての適切な説明を追加してください。 – Surajano
@Surajanoよろしく! Mandlebrot tensorflow(リンクhttps://www.tensorflow.org/tutorials/mandelbrot)のちょうどそのプログラムは、彼らの.. ..私はちょうど正しい出力(画像として)を得る方法を取得したいです。 –
@Surajanoコードは前述のものと同じですが、エラーはありませんが、出力は説明通りではありません –