I want to fix the unexpected EOF while parsing error

Asked 2 years ago, Updated 2 years ago, 422 views

Currently, I am using a library called [bindnet][1] to create a Recurrent Spiking Neuralnet, and I would like to load the training data (npz file) (values of x and y) for simulation, but when I try to extract it with the enumerate function, I get an "unexpected EOF while parsing" error.npz file.Thank you very much for your instruction..
I use a library called bindesnet.
[1] https://bindsnet-docs.readthedocs.io/bindsnet.analysis.html

The training data is based on the GitHub code [2]. This is train_set.npz on the link. I'm trying to convert this git code to current spiking neural net using bindsnet.
I'd like to extract the values of x and y from train_set.npz.
[2] https://github.com/exelban/myo-armband-nn

Code related to tain_set.npz (data.py in include directory)

import numpy as np
default_data_set(name="train"):
x = None
y = None
if name is "train":
    npzfile=np.load("C:/Users/namae/Desktop/myo-python-1.0.4/myo-armband-nn-master/data/train_set.npz")
    #("C:/Users/namae/Desktop/myo-python-1.0.4/myo-armband-nn-master/data/train_set.npz")
    #("./data/train_set.npz")
    x = npzfile ['x']
    y=npzfile['y']
elif name is "test":
    npzfile=np.load("./data_set/test_set.npz")
    #("C:/Users/namae/Desktop/myo-python-1.0.4/myo-armband-nn-master/data/train_set.npz")
    #("./data_set/test_set.npz")
    x = npzfile ['x']
    y=npzfile['y']
  return x,y

The part of the code where the error occurs (I changed the error from errate to range or put the element name of numpy, but it didn't work) I think the error is probably the last line.
Reference Code
 
error statement
 

 C:\Python36\python.exe C:/Users/namae/Desktop/myo-python-1.0.4/bindsnet-
  master/bindsnet/preRSNN.py 


File "C:/Users/namae/Desktop/myo-python-1.0.4/bindsnet master/bindsnet/preRSNN.py", line84SyntaxError: unexpected EOF while parsing

Error points

for i,(x,y)in enumerate(get_data_set("train")):

The following is the code currently being implemented. The error is the last minute.
 

import torch
from bindsnet.network import Network
from bindsnet.network.nodes import Input, LIFNodes
from bindsnet.network.topology import Connection
from bindsnet.network.monitors import Monitor
from bindsnet.analysis.plotting importplot_spikes,plot_voltages
import matplotlib.pyplot asplt
from include.model import model
from include.data import get_data_set
import numpy as np 
x,y,output,global_step,y_pred_cls=model(6)
test_x, test_y=get_data_set()
test_l = ["Relax", "Ok", "Fist", "Like", "Rock", "Spock" ]
train_x, train_y=get_data_set()
time = 500
network=Network()
source_layer=Input (n=100, sum_input=True)
target_layer=LIFNodes(n=1000, sum_input=True)
network.add_layer(
    layer=source_layer,name='A'
)
network.add_layer(
    layer=target_layer,name='B'
)
forward_connection=Connection(
source=source_layer,
target=target_layer,
w=0.05+0.1*torch.randn(source_layer.n, target_layer.n),
) 
network.add_connection(
    connection=forward_connection, source='A', target='B'
) 
current_connection=Connection(
   source=source_layer,
   target=target_layer,
    w=0.025*(torch.eye(target_layer.n)-1),
)
network.add_connection(
   connection=current_connection, source="B", target="B")  
source_monitor=Monitor(
   obj=source_layer,
   state_vars=("s",), 
   time = time, )
target_monitor=Monitor(
   obj=target_layer,
   state_vars=("s", "v"), #Spike and Voltage Recording
   time = time, )
network.add_monitor(monitor=source_monitor,name="A")
network.add_monitor(monitor=target_monitor, name="B")
for lin network.layers:# monitor state variable
    m=Monitor(network.layers[l], state_vars=['s'], time=time)
    network.add_monitor(m,name=l)
x,y=get_data_set("C:/Users/namae/Desktop/myo-python-1.0.4/myo-armband-nn- 
                    master/data/train_set.npz")
grads = {}
lr,lr_decay = 1e-2,0.95
criterion=torch.nn.CrossEntropyLoss()#Error Calculation
spoke_ims, spoke_axes, weights_im = None, None, None 
for i,(x,y) in enumerate(get_data_set("train")):

python network numpy pytorch

2022-09-30 21:53

1 Answers

get_data_set("C:/Users/namae/Desktop/myo-python-1.0.4/myo-armband-nn-master/data/train_set.npz")

instead of

get_data_set("train")

I think so.If you look at the source code, you expect a string of "train" or "test" instead of the path to the dataset file.


2022-09-30 21:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.