标签:bin one red def cti shared nump 激励 __init__
1. 代码如下:
#!/usr/bin/env python #! _*_ coding:UTF-8 _*_ import numpy as np import theano.tensor as T import theano class Layer(object): ‘‘‘ 定义一个神经层 ‘‘‘ def __init__(self, inputs, in_size, out_size, activation_function=None): ‘‘‘神经层的初始化方法‘‘‘ self.W = theano.shared(np.random.normal(0, 1, (in_size, out_size))) self.b = theano.shared(np.zeros((out_size, ) + 0.1)) self.Wx_plus_b = T.dot(inputs, self.W) + self.b self.activation_function = activation_function # 增加激励函数的处理 if activation_function is None: self.outputs = self.Wx_plus_b else: self.outputs = self.activation_function(self.Wx_plus_b)
标签:bin one red def cti shared nump 激励 __init__
原文地址:https://www.cnblogs.com/liuzhiqaingxyz/p/9508392.html