# -*- coding:utf-8 -*-
#偏微分方程
import tensorflow as tf
import numpy as np
import PIL.Image
from io import StringIO
from IPython.display import clear_output, Image, display
def DisplayArray(a, fmt='jpeg', rng=[0,1]):
a = (a - rng[0])/float(rng[1] - rng[0])*255
a = np.uint8(np.clip(a, 0, 255))
f = StringIO()
PIL.Image.fromarray(a).save('test',fmt)
display(Image(data=f.getvalue()))
if __name__ == '__main__':
sess = tf.InteractiveSession()
def make_kernel(a):
a = np.asarray(a)
a = a.reshape(list(a.shape)+[1,1])
return tf.constant(a,dtype=1)
def simple_conv(x, k):
x = tf.expand_dims(tf.expand_dims(x, 0), -1)
y = tf.nn.depthwise_conv2d(x, k, [1, 1, 1, 1], padding='SAME')
return y[0,:,:,0]
def laplace(x):
laplace_k = make_kernel([[0.5, 1.0, 0.5],
tensorflow学习笔记:偏微分方程
最新推荐文章于 2024-03-13 17:18:16 发布
本文通过TensorFlow实现了一个偏微分方程的模拟,利用深度学习中的卷积操作来求解。首先定义了偏微分方程的初始条件和边界,然后创建卷积核并应用到数据上,通过不断迭代更新状态,最终展示了仿真过程中的结果图像。
摘要由CSDN通过智能技术生成