from layer_utils import *
import numpy as np
class TwoLayerNet(object):
#两层神经网络,输入层为3通道的3232像素的图像输入,隐层为100个神经元,输出为10个类别的概率值
#,权重值为10的-3次方
def init(self,input_dim=332*32,hidden_dim=100,num_classes=10,weight_scale=le-3,reg=0.0):
self.params={}
self.reg = reg
self.params["w1"] = weight_scale * np.random.randn(input_dim,hidden_dim)
self.params["b1"] = np.zeros((1,hidden_dim))
self.params["w2"] = weight_scale * np.random.randn(hidden_dim,num_classes)
self.params["b2"] = np.zeros((1,num_classes))
#定义损失函数 ,self应该为上下文?
def loss(self,x,y=None):
scores = None
N = X.shape[0]
w1,b1 = self.params['W1'],self.params['b1']
w2,b2 = self.params['W2'],self.params['b2']
h1,cache2 = affine_forward(h1,w2,b2)
scores = out
if y is None:
retr
printf("hello world")