Open Oliver-0423 opened 1 year ago
in cell 10,line25:
num_nodes = len(list(filter(lambda x: x == 0, data.batch)))
make an error :
TypeError: 'NoneType' object is not iterable
change cell10,line24
if hasattr(data, 'batch'):
into this:
if data.batch is not None:
can solve this error
TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_5548/1338493251.py in
25 for i in range(NUM_SELF_GAMES):
26 A = generate_graph(TRAIN_GRAPH_SIZE)
---> 27 records.extend(self_play(A, net, num_rollouts = 50, net_weight = NETWORK_WEIGHT))
28 if i % (NUM_SELF_GAMES/5) == (NUM_SELF_GAMES/5)-1:
29 print(" Generated game %d" % (i+1))
~\AppData\Local\Temp/ipykernel_5548/3440311384.py in self_play(G, net, num_rollouts, netweight) 8 break 9 for in range(num_rollouts): ---> 10 tree.do_rollout(board) 11 12 possibilities = board.possible_moves
~\AppData\Local\Temp/ipykernel_5548/2307546588.py in do_rollout(self, node) 43 path = self._select(node) 44 leaf = path[-1] ---> 45 self._expand(leaf) 46 reward = self._simulate(leaf) 47 self._backpropagate(path, reward)
~\AppData\Local\Temp/ipykernel_5548/2307546588.py in _expand(self, node) 68 self.children[node] = children 69 if children: ---> 70 all_priors = self.net.predict(node) 71 all_priors *= len(all_priors) 72 self.priors[node] = [all_priors[i] for i in vertices]
~\AppData\Local\Temp/ipykernel_5548/1432866499.py in predict(self, instance) 30 def predict(self, instance): 31 data = from_networkx(instance.graph) ---> 32 return self.forward(data).flatten().tolist() 33
~\AppData\Local\Temp/ipykernel_5548/1432866499.py in forward(self, data) 23 x = self.conv_prob(x, edge_index) 24 if hasattr(data, 'batch'): ---> 25 num_nodes = len(list(filter(lambda x: x == 0, data.batch))) 26 x = x.view(-1,num_nodes) 27
TypeError: 'NoneType' object is not iterable