Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tensorflow DisplayFractal(ns.eval()) fails in docker image #8

Open
tobigithub opened this issue Nov 26, 2015 · 3 comments
Open

tensorflow DisplayFractal(ns.eval()) fails in docker image #8

tobigithub opened this issue Nov 26, 2015 · 3 comments

Comments

@tobigithub
Copy link
Owner

tensorflow DisplayFractal(ns.eval()) fails in docker image.

>>> DisplayFractal(ns.eval())
<IPython.core.display.Image object>

What can I say. Release early, fix often.

@Kingburrito777
Copy link

print(DisplayFractal(ns.eval())
should work. If not, create it in a directory or try different file form

@yannickscholz
Copy link

import tensorflow as tf
import numpy as np

from PIL import Image

def DisplayFractal(a):
    a_cyclic = (6.28*a/20.0).reshape(list(a.shape)+[1])
    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
    im = Image.fromarray(np.uint8(np.clip(a, 0, 255)))
    im.show()

sess = tf.InteractiveSession()

Y, X = np.mgrid[-1.3:1.3:0.005, -2:1:0.005]
Z = X+1j*Y

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

not_diverged = tf.abs(zs_) < 4

step = tf.group(
    zs.assign(zs_),
    ns.assign_add(tf.cast(not_diverged, tf.float32))
)

for i in range(200): step.run()

DisplayFractal(ns.eval())

@gopi77
Copy link

gopi77 commented Feb 22, 2017

Thanks YannickS94, works fine :)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants