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

Type Errors with Numpy on CPU #358

Open
nsutphen1 opened this issue Jul 3, 2020 · 2 comments
Open

Type Errors with Numpy on CPU #358

nsutphen1 opened this issue Jul 3, 2020 · 2 comments
Labels
usage General Thinc usage

Comments

@nsutphen1
Copy link

I am attempting to build a model that takes in Array2D for the features and Array1D for the labels.

The feature vectors are numpy arrays stored in a python list, and the labels are one-hot encoded arrays in a numpy array.

The error comes when I attempt to use the parametric attention layer. It says that y must be a ragged list, but there aren't any layers that affect y to my knowledge.

Been working on this for a while, any input would be great.

@svlandeg
Copy link
Member

svlandeg commented Jul 8, 2020

Can you provide a minimal code snippet that exhibits the error, and paste the error trace?

@svlandeg svlandeg added the usage General Thinc usage label Jul 8, 2020
@nsutphen1
Copy link
Author

Model:

with Model.define_operators({'>>': chain, '|': concatenate}):
  model = (thinc.api.list2ragged()
          >>thinc.api.ParametricAttention()
          >>reduce_max()
          >>expand_window(window_size=1)
          >>reduce_max()
          >>Softmax(nO=nr_classes))

optimizer = Adam(learn_rate)

Where the error occurs:
model.initialize(dummy_x,dummy_y_2)

Traceback:


ValidationError                           Traceback (most recent call last)

/usr/local/lib/python3.6/dist-packages/thinc/util.py in validate_fwd_input_output(name, func, X, Y)
    420     try:
--> 421         ArgModel.parse_obj(args)
    422     except ValidationError as e:

14 frames

ValidationError: 1 validation error for ArgModel
Y -> 0
  instance of Ragged expected (type=type_error.arbitrary_type; expected_arbitrary_type=Ragged)


During handling of the above exception, another exception occurred:

DataValidationError                       Traceback (most recent call last)

/usr/local/lib/python3.6/dist-packages/thinc/util.py in validate_fwd_input_output(name, func, X, Y)
    421         ArgModel.parse_obj(args)
    422     except ValidationError as e:
--> 423         raise DataValidationError(name, X, Y, e.errors())
    424 
    425 

DataValidationError: 

Data validation error in 'para-attn'
X: <class 'thinc.types.Ragged'> Y: <class 'list'>

Y -> 0   instance of Ragged expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usage General Thinc usage
Projects
None yet
Development

No branches or pull requests

2 participants