Enable ruff NPY002 rule (#11336)

This commit is contained in:
Maxim Smolskiy
2024-04-01 22:39:31 +03:00
committed by GitHub
parent 39daaf8248
commit f8a948914b
9 changed files with 32 additions and 25 deletions

View File

@ -41,15 +41,16 @@ class CNN:
self.size_pooling1 = size_p1
self.rate_weight = rate_w
self.rate_thre = rate_t
rng = np.random.default_rng()
self.w_conv1 = [
np.asmatrix(-1 * np.random.rand(self.conv1[0], self.conv1[0]) + 0.5)
np.asmatrix(-1 * rng.random((self.conv1[0], self.conv1[0])) + 0.5)
for i in range(self.conv1[1])
]
self.wkj = np.asmatrix(-1 * np.random.rand(self.num_bp3, self.num_bp2) + 0.5)
self.vji = np.asmatrix(-1 * np.random.rand(self.num_bp2, self.num_bp1) + 0.5)
self.thre_conv1 = -2 * np.random.rand(self.conv1[1]) + 1
self.thre_bp2 = -2 * np.random.rand(self.num_bp2) + 1
self.thre_bp3 = -2 * np.random.rand(self.num_bp3) + 1
self.wkj = np.asmatrix(-1 * rng.random((self.num_bp3, self.num_bp2)) + 0.5)
self.vji = np.asmatrix(-1 * rng.random((self.num_bp2, self.num_bp1)) + 0.5)
self.thre_conv1 = -2 * rng.random(self.conv1[1]) + 1
self.thre_bp2 = -2 * rng.random(self.num_bp2) + 1
self.thre_bp3 = -2 * rng.random(self.num_bp3) + 1
def save_model(self, save_path):
# save model dict with pickle