-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Labels
Description
It is quite common in data science apps to use numpy arrays and pandas dataframes. Unfortunately when you try to create Instance using numpy array of shape (1,x) your code creates in one of the places array of shape (nobs, x, 1) which does not work in dot when multiplied by array of shape (x, nlayers). It could be easily checked with the verify_dataset_shape_and_modify. Here's some snippet:
def mult(x):
res = x[0]
for a in x[1:]:
res *= a
return res
[...]
def verify_dataset_shape_and_modify(...)
[...]
data = np.array( [instance.features.reshape((mult(instance.features.shape),) \
if type(instance.features) == np.ndarray\ #more generalization perhaps?
else instance.features\
for instance in dataset ] )whith this snippet even accidentally passing arrays of shape (x,1) will work.