我正在制作MNIST神经网络模型,而不导入除CSV之外的任何其他模块,例如numpy,sci-kit学习等。但是我很难做到这一点。我正在逐步进行。
Mnist_test
Wx+b
data=[]
f = open("mnist_test_s.csv",'r')
crf= csv.reader(f)
for line in crf:
data.append(list(map(float, line)))
f.close()
mnist_test_s = data
# mnist_test_s data is 100*784
# W1 is 784*256
# W2 is 256*256
# W3 is 256*10
# my class
class Layer:
def __init__(self,weight,bias,relu):
self.W = W1
self.b = b1
# normalization = (x-min(x))/(max(x)-min(x))
# normalization = mnist_test_s/253
myList = mnist_test_s
myInt = 253
newList = [x / myInt for x in myList]
newList
# Matrix dot product to Wx+b
def mat_mult(a,b):
result=[]
result1=[]
while len(a)>0:
d=0
a1=a[:1:]
c=True
while d<len(a1):
for x in b:
for x1 in x:
result.append(x1*a1[0][d])
d=d+1
a.pop(0)
result=[result[i:i+len(b[0])] for i in range(0, len(result), len(b[0]))]
#print(result)
sum=0
while len(result)>0:
for X in range(len(result[0])):
for Y in range(len(b)):
sum = sum+result[Y][X]
result1.append(sum)
#print(result1)
sum = 0
for s in range(len(b)):
result.pop(0)
result1 =[result1[i:i+len(b[0])] for i in range(0, len(result1), len(b[0]))]
return (result1)
我遇到此错误:
在/的不支持的操作数类型:归一化部分中的“列表”和“整数”。
列表索引超出范围
Wx+b
中即使他们可以做点积。