While using function newlvq in net, I encountered the following error:
line 184, in newlvq
layer_out.np['w'][n][st:i].fill(1.0)
TypeError: slice indices must be integers or None or have an index method
on further investigation, I found that this relates to the solution #481.
The array produced by
line 181
inx = np.floor(cn0 * pc.cumsum())
needs to be changed from float64 to integers to be used as the i inputs in line 184.
while I would not call this an elegant solution, it does resolve the type issue:
def newlvq(minmax, cn0, pc):
pc = np.asfarray(pc)
assert sum(pc) == 1
ci = len(minmax)
cn1 = len(pc)
assert cn0 > cn1
layer_inp = layer.Competitive(ci, cn0)
layer_out = layer.Perceptron(cn0, cn1, trans.PureLin())
layer_out.initf = None
layer_out.np['b'].fill(0.0)
layer_out.np['w'].fill(0.0)
inx = np.floor(cn0 * pc.cumsum())
Modification begins
**v = 0
new = []
for i in inx:
new.append(int(i))
v += 1**
for n, i in enumerate(**new**):
st = 0 if n == 0 else **new**[n - 1]
layer_out.np['w'][n:st:i].fill(1.0)
End of modification
net = Net(minmax, cn1, [layer_inp, layer_out],
[[-1], [0], [1]], train.train_lvq, error.MSE())
return net
Thanks,
Jonathan
While using function newlvq in net, I encountered the following error:
line 184, in newlvq
layer_out.np['w'][n][st:i].fill(1.0)
TypeError: slice indices must be integers or None or have an index method
on further investigation, I found that this relates to the solution #481.
The array produced by
line 181
inx = np.floor(cn0 * pc.cumsum())
needs to be changed from float64 to integers to be used as the i inputs in line 184.
while I would not call this an elegant solution, it does resolve the type issue:
def newlvq(minmax, cn0, pc):
Modification begins
End of modification
Thanks,
Jonathan