TensorFlow 不仅仅可以用于机器学习。在此教程中,我们所举的例子(较为寻常)是使用 TensorFlow 模拟偏微分方程的行为(https://en.wikipedia.org/wiki/Partial_differential_equation)。我们将模拟几个雨滴落在方形池塘水面的情形。基本设置需要导入一些库。#Import libraries for simulationimport tensorflow as tfimport numpy as np#Imports for visualizationimport PIL.Imagefrom io import BytesIOfrom IPython.display import clear_output, Image, display将池塘水面的状态显示为图像的函数。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()))接下来,我们发起一个互动式 Tensor
………………………………