MCPcopy
hub / github.com/MrNothing/AI-Blocks / Run

Function Run

Sources/scripts/predictor.py:16–56  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

14save_path = ""
15
16def Run(self):
17
18 #defining the model...
19 self.X = tf.placeholder(tf.float32, shape=[None, self._input.input_size], name="x_input")
20
21 _y = self._model.Run(self.X)
22
23
24 instance = AIBlocks.InitModel(load_path=self.save_path)
25 Log("Model initialized!")
26
27 batch = self._input.getTestBatch()
28 X_batch = batch[0]
29 Y_batch = batch[1]
30
31 prediction = instance.Run(_y, feed_dict={self.X: X_batch})
32
33 found=0
34 failed=0
35 for i in range(len(prediction)):
36 assert1 = self.max_index(Y_batch[i])
37 assert2 = self.max_index(prediction[i])
38
39 tmp = "Found"
40 color = "#00ff00"
41 if assert1!=assert2:
42 tmp = "Failed"
43 color = "#ff0000"
44 failed+=1
45 else:
46 found+=1
47
48 SendPieData(self.id, tmp, color);
49 SetState(self.id, i/len(prediction))
50 time.sleep(0.1)
51
52 Log("Accuracy: "+str(found/(failed+found)*100)+"%")
53
54 AIBlocks.CloseInstance(instance)
55
56 SetState(self.id, 1)
57
58def predict(self, input):
59 return sess.run(_y, feed_dict={self.X: input})

Callers

nothing calls this directly

Calls 6

LogFunction · 0.85
SendPieDataFunction · 0.85
SetStateFunction · 0.85
InitModelMethod · 0.80
CloseInstanceMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected