MCPcopy Create free account
hub / github.com/JunlingWang/Neuronetwork_with_python / main

Function main

your_first_network.py:248–281  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246
247#-------------MAIN-------------------------
248def main():
249 global current_loss
250 data = cp.creat_data(800) #生成数据
251 cp.plot_data(data, "Right classification")
252
253 #选择起始网络
254 use_this_network = 'n' #No
255 while use_this_network != 'Y' and use_this_network != 'y':
256 network = Network(NETWORK_SHAPE)
257 inputs = data[:, (0, 1)]
258 outputs = network.network_forward(inputs)
259 classification = classify(outputs[-1])
260 data[:, 2] = classification
261 cp.plot_data(data, "Choose network")
262 use_this_network = input("Use this network? Y to yes, N to No \n")
263
264 #进行训练
265 do_train = input("Train? Y to yes, N to No \n")
266 while do_train == 'Y' or do_train == 'y' or do_train.isnumeric() == True:
267 if do_train.isnumeric() == True:
268 n_entries = int(do_train)
269 else:
270 n_entries = int(input("Enter the number of data entries used to train. \n"))
271
272 network.train(n_entries)
273 do_train = input("Train? Y to yes, N to No \n")
274
275 #演示训练效果
276 inputs = data[:, (0, 1)]
277 outputs = network.network_forward(inputs)
278 classification = classify(outputs[-1])
279 data[:, 2] = classification
280 cp.plot_data(data, "After training")
281 print("谢谢,再见!")
282#----------------TEST-------------------------
283def test():
284 pass

Callers 1

Calls 4

network_forwardMethod · 0.95
trainMethod · 0.95
NetworkClass · 0.85
classifyFunction · 0.85

Tested by

no test coverage detected