jupyter ipython display_Tensorflow从jupyter / Ipython运行动画

本文档展示了如何在Jupyter环境中利用Tensorflow实现水波涟漪的动态模拟。通过导入相关库,定义函数以及设置参数,利用深度学习库Tensorflow进行2D拉普拉斯方程的离散化PDE更新规则,最终在交互式会话中通过运行代码单元格生成涟漪动画。在遇到问题时,讨论了如何在Jupyter notebook中正确导入和运行代码。
摘要由CSDN通过智能技术生成

我正在通过水上的水滴的tensorflow示例,代码:

#Import libraries for simulation

import tensorflow as tf

import numpy as np

#Imports for visualization

import PIL.Image

from io import BytesIO

from IPython.display import clear_output, Image, display

#A function for displaying the state of the pond's surface as an image.

def DisplayArray(a, fmt='jpeg', rng=[0,1]):

"""Display an array as a picture."""

a = (a - rng[0])/float(rng[1] - rng[0])*255

a = np.uint8(np.clip(a, 0, 255))

f = BytesIO()

PIL.Image.fromarray(a).save(f, fmt)

clear_output(wait = True)

display(Image(data=f.getvalue()))

sess = tf.InteractiveSession()

def make_kernel(a):

"""Transform a 2D array into a convolution kernel"""

a =

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值