python贝叶斯网络与自定义损失函数

2021-01-14 10:35:48 浏览数 (1)

贝叶斯网络

source coding

代码语言:javascript复制
# -*- coding:utf-8 -*-
# /usr/bin/python
'''
@Author:  Yan Errol  @Email:2681506@gmail.com   
@Date:  2019-06-03  16:17
@File:Bayesian neural newwork
@Describe:贝叶斯神经网络
@Evn:
'''

import edward as ed
from edward.models import Normal

n_samples = x.shape[0]  # number of samples, equal N
n_input = 1  # number of input neurons

for my_num_hidden, my_subplot_num in zip([1, 2, 4, 16], range(1, 5, 1)):

    n_hidden = my_num_hidden  # number of hidden neurons
    print('Fitting curve with {} hidden neurons Bayesian Neural Network'.format(my_num_hidden))

    W_0 = Normal(loc=tf.zeros([n_input, n_hidden]), scale=tf.ones([n_input, n_hidden]))
    W_1 = Normal(loc=tf.zeros([n_hidden, n_input]), scale=tf.ones([n_hidden, n_input]))
    b_0 = Normal(loc=tf.zeros(n_hidden), scale=tf.ones(n_hidd

0 人点赞