From 9994040cd365eb4723fdd7b4321b0dea99762748 Mon Sep 17 00:00:00 2001 From: weilinquan <352977670@qq.com> Date: Fri, 23 Dec 2022 16:38:08 +0800 Subject: [PATCH] weilinquan update --- __pycache__/Tensor.cpython-39.pyc | Bin 1058 -> 1054 bytes nn/__pycache__/Linear.cpython-39.pyc | Bin 1363 -> 1359 bytes nn/__pycache__/Lossfunction.cpython-39.pyc | Bin 2194 -> 2190 bytes nn/__pycache__/Module.cpython-39.pyc | Bin 1360 -> 1356 bytes nn/__pycache__/Parameter.cpython-39.pyc | Bin 546 -> 542 bytes nn/function/__pycache__/relu.cpython-39.pyc | Bin 1167 -> 1163 bytes .../__pycache__/optimizer.cpython-39.pyc | Bin 2164 -> 2184 bytes nn/optimizer/optimizer.py | 6 +++--- tests/test_minist.py | 14 ++++++++++++++ 9 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 tests/test_minist.py diff --git a/__pycache__/Tensor.cpython-39.pyc b/__pycache__/Tensor.cpython-39.pyc index 022dbe23c81b07786d4d0a55ddfa7e0d81455ce6..093d33824460470abfab7109e8149ff66fe92c7e 100644 GIT binary patch delta 41 vcmZ3)F^_{ck(ZZ?0SGF!s*`VT5?_>BkiS`*@jDX$-#`pU delta 45 zcmbQov512=k(ZZ?0SItYr2e8H6GE4MwLGJmr=<98+iJSY%% diff --git a/nn/__pycache__/Linear.cpython-39.pyc b/nn/__pycache__/Linear.cpython-39.pyc index 6521538e8bf75edc23b0f4a934338a3a6df7e581..c449d33b98303b40650c137bdc37c15fa6cada9f 100644 GIT binary patch delta 39 tcmcc2b)Jhmk(ZZ?0SGp2Yuv~^nUVLGu8UPndS*#{QEEZ{=JkwAm;vfr4DkQ} delta 43 xcmX@lb(xDhk(ZZ?0SE-!>o;;wW)%FY2jsX|#XMgy<@w5O&!^1ayqa+dGXM{U4?O?? diff --git a/nn/__pycache__/Lossfunction.cpython-39.pyc b/nn/__pycache__/Lossfunction.cpython-39.pyc index d2f28f51148d5890cb933dd9152065724f8c00d1..1d60f89f3daa1cd6ae4344396b5b3842d6017cc8 100644 GIT binary patch delta 39 tcmbOv*eA%H$ji&c00f)1HE!gd%ENj#vWfc5s0_3<@#XMgy<@w5O&!^1ayq57H8vqP=50C%= diff --git a/nn/__pycache__/Module.cpython-39.pyc b/nn/__pycache__/Module.cpython-39.pyc index 1cb836f26d92b9c29d3e65fddb0ec522aa3362f6..c238e9f2e5758a52db619a19e85aa6e420bf9a15 100644 GIT binary patch delta 39 tcmcb>b%u*Ok(ZZ?0SGp2Yuw0P$jJLk*TpI(J+mafD77Geb1&mzW&q}648{Ne delta 43 xcmX@Zb%BdJk(ZZ?0SN3`>o;;2G75gx19DufVxBLU@_gmC=Tqiy?qod73;+-M4?O?? diff --git a/nn/__pycache__/Parameter.cpython-39.pyc b/nn/__pycache__/Parameter.cpython-39.pyc index d81d1032a702d530ec4e20a3e9acb72be8d3ce93..8d0b139bc44c68ddb8a3a9a286597adba63072ec 100644 GIT binary patch delta 40 ucmZ3)GLMBfk(ZZ?0SKzJs*~4j5?_>BkU!aj@fHBk2@Dbd delta 44 ycmbQovWSH@k(ZZ?0SNr^>XSEb&_LUohqQ%5Bf5%%AMScnbgwC=XKr diff --git a/nn/function/__pycache__/relu.cpython-39.pyc b/nn/function/__pycache__/relu.cpython-39.pyc index 01174fbf039bbfebfa61899d8b9768d033f9817c..32d977deb54b4f415587a92a41f7091b10c380d9 100644 GIT binary patch delta 39 tcmeC@?B?W7LG0zuFdA@Sn^C|N;>oLYM0|5NU4iW$W diff --git a/nn/optimizer/__pycache__/optimizer.cpython-39.pyc b/nn/optimizer/__pycache__/optimizer.cpython-39.pyc index e5a6c9dbb2eec0c97d8b5c96af2bc880d338e059..ed1c514a7359fd721c0876f0cecfdc4f47dffbde 100644 GIT binary patch delta 163 zcmew&&>_g1$ji&c00cMFmL``>&zf4U;5;2tx{(FTqg5n8GXx6%%KG$lHKu4j^U*shvEXO@R%>v|*UM ilg&p6qQ8W30XJL)Kl?sT9Y!N21x5)bv&q-k=K%mZttL4D delta 138 zcmeAW{35`c$ji&c00cLx>XVZu@_rEfY7OMMSj9YFFy;BmZO^C7-^|6x%*rS*nU5_@ ze@87-4MP??5HpA{q=4BH3^j}?%#sW>Op-t`afTX(cp%Q=0Al9J^Vt-b;+ZEOW%J<@ dVJKl-zzr5vX5YuD!l=chz$n3_H~AI&JOGimBh&x@ diff --git a/nn/optimizer/optimizer.py b/nn/optimizer/optimizer.py index bbf20ea..f4412df 100644 --- a/nn/optimizer/optimizer.py +++ b/nn/optimizer/optimizer.py @@ -61,13 +61,13 @@ def __call__(self, params): self.n += 1 for i in range(len(params['parameter'])): - self.m = self.beta1 * self.m + (1 - self.beta1) * params['gradient'][i] - self.v = self.beta2 * self.v + (1 - self.beta2) * np.square(params['gradient'][i]) + self.m[i] = self.beta1 * self.m[i] + (1 - self.beta1) * params['gradient'][i] + self.v[i] = self.beta2 * self.v[i] + (1 - self.beta2) * np.square(params['gradient'][i]) alpha = self.lr * np.sqrt(1 - np.power(self.beta2, self.n)) alpha = alpha / (1 - np.power(self.beta1, self.n)) - params['parameter'][i].data -= alpha * self.m / (np.sqrt(self.v) + self.eps) + params['parameter'][i].data -= alpha * self.m[i] / (np.sqrt(self.v[i]) + self.eps) """ self.m = self.beta1 * self.m + (1 - self.beta1) * grads diff --git a/tests/test_minist.py b/tests/test_minist.py new file mode 100644 index 0000000..69ff8cf --- /dev/null +++ b/tests/test_minist.py @@ -0,0 +1,14 @@ +import sys +sys.path.append("..") +from nn.function.relu import ReLu +import nn +from nn.Linear import Linear +from Tensor import Tensor +from nn.Lossfunction import MSELoss +from nn.optimizer.optimizer import SGD +import numpy +from matplotlib import pyplot + +class model(nn.Module.Module): + def __init__(self): + self.conv1 = \ No newline at end of file