tensorflow学习笔记:偏微分方程

本文通过TensorFlow实现了一个偏微分方程的模拟,利用深度学习中的卷积操作来求解。首先定义了偏微分方程的初始条件和边界,然后创建卷积核并应用到数据上,通过不断迭代更新状态,最终展示了仿真过程中的结果图像。
摘要由CSDN通过智能技术生成
# -*- 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],
                
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值