| 311 | return mse |
| 312 | |
| 313 | def predict(self, datas_test): |
| 314 | # model predict |
| 315 | produce_out = [] |
| 316 | print("-------------------Start Testing-------------------------") |
| 317 | print((" - - Shape: Test_Data ", np.shape(datas_test))) |
| 318 | for p in range(len(datas_test)): |
| 319 | data_test = np.asmatrix(datas_test[p]) |
| 320 | _data_focus1, data_conved1 = self.convolute( |
| 321 | data_test, |
| 322 | self.conv1, |
| 323 | self.w_conv1, |
| 324 | self.thre_conv1, |
| 325 | conv_step=self.step_conv1, |
| 326 | ) |
| 327 | data_pooled1 = self.pooling(data_conved1, self.size_pooling1) |
| 328 | data_bp_input = self._expand(data_pooled1) |
| 329 | |
| 330 | bp_out1 = data_bp_input |
| 331 | bp_net_j = bp_out1 * self.vji.T - self.thre_bp2 |
| 332 | bp_out2 = self.sig(bp_net_j) |
| 333 | bp_net_k = bp_out2 * self.wkj.T - self.thre_bp3 |
| 334 | bp_out3 = self.sig(bp_net_k) |
| 335 | produce_out.extend(bp_out3.getA().tolist()) |
| 336 | res = [list(map(self.do_round, each)) for each in produce_out] |
| 337 | return np.asarray(res) |
| 338 | |
| 339 | def convolution(self, data): |
| 340 | # return the data of image after convoluting process so we can check it out |