Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while executing net #39

Open
WinterHolidays opened this issue Jul 3, 2018 · 0 comments
Open

Error while executing net #39

WinterHolidays opened this issue Jul 3, 2018 · 0 comments

Comments

@WinterHolidays
Copy link

WinterHolidays commented Jul 3, 2018

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

@WinterHolidays WinterHolidays changed the title Error while executing core Error while executing net Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant