Python中文
首页
教程
问答
标签
搜索
登录
注册
如何在Mandlebrot tensorflow中显示图像程序。当前输出是<IPython.core.display.图像对象>
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>“导入模拟库”</p> <pre><code>import tensorflow as tf import numpy as np </code></pre> <p>“可视化导入”</p> ^{pr2}$ <p>'''现在我们将定义一个函数来实际显示图像 迭代计数“”</p> <pre><code>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 </code></pre> <p>''' 更新zs和迭代计数的操作。 注意:我们会在Z偏离后继续计算它们!这个 太浪费了!有更好的,如果有一点 不那么简单的方法。 ''' 步骤=tf.集团(zs.分配(zs),ns.assign U添加(转铁器铸造(没有发散, tf.float32型)))在</p> <pre><code>for i in range(200): step.run() DisplayFractal(ns.eval()) </code></pre>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>我也有同样的问题。您必须在Jupyter笔记本中运行TensorFlow示例: <a href="http://jupyter.org/" rel="nofollow noreferrer">http://jupyter.org/</a></p> <p>如果您从其他ide(比如Spyder)运行它,那么您将在控制台中看到<code><IPython.core.display.Image object></code>。</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
Python闭包能否存储和更改外部标量?
10 回答
python闭包行为怪异
3 回答
python闭包问题源代码编译器
1 回答
Python问gam
1 回答
Python问答游戏逻辑E
4 回答
Python问答程序。你能帮我找出哪里出了问题吗?谢谢
10 回答
Python问答程序问题与分数
7 回答
Python问题
6 回答
Python问题 | 在https://www.testdome.com开发的代码测试分数有bug吗
6 回答
Python问题,上载文件的名称和缩略图
5 回答
python问题,将img的相对url连接到绝对url
1 回答
Python问题,机械化机器人
5 回答
Python问题,用不同的模板发送大量电子邮件?
7 回答
Python问题,类型错误:“float对象不能解释为integer”。无法在“for”循环中返回函数的值
3 回答
Python问题:“overflowerr:Python int太大,无法转换为C long”
8 回答
Python问题:“空数据帧的绑定方法NDFrame.head”
9 回答
Python问题:AttributeError:'_io.TextIOWrapper'对象没有属性'split'
5 回答
Python问题:AttributeError:'dict'对象没有'upper'属性
4 回答
Python问题:CS圆7C循环,正方形普查
10 回答
Python问题:ODE系统的参数估计,例如系数是函数
9 回答