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

N-dimensional input (stacking for convolutional nets) #18

Closed
rohan-dot opened this issue Dec 25, 2018 · 2 comments
Closed

N-dimensional input (stacking for convolutional nets) #18

rohan-dot opened this issue Dec 25, 2018 · 2 comments

Comments

@rohan-dot
Copy link

Hi,
I tried to do stacking by using kerasClassifier with a cnn but i get this error
ValueError: Found array with dim 4. Estimator expected <= 2.

This is my code for the cnn

`def model1():
model = Sequential()
model.add(Conv2D(16, (3, 3), activation='relu', padding="same", input_shape=(train_files.shape[1:])))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(64, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Flatten())  
model.add(Dense(64))
model.add(Activation('relu'))
model.add(Dropout(0.5))
model.add(Dense(1))
model.add(Activation('sigmoid'))
model.compile(loss='binary_crossentropy',
          optimizer='rmsprop',
          metrics=['accuracy'])`
@vecxoz
Copy link
Owner

vecxoz commented Dec 27, 2018

Your neural net architecture is OK. This behavior is a result of inner data checking procedure performed by vecstack. Such behavior is expected because according to scikit-learn convention input arrays should be 2-dimensional.

Of course it would be nice to have ability to stack some convolutional nets. So I created a workaround which makes it possible to pass N-dimensional arrays. It is available only in functional API (i.e. vecstack.stacking function).

You can reinstall patched version directly from github branch:

  • use pip3 for Python 3
  • remove --user option if vecstack was installed for all users

pip install --user --upgrade --force-reinstall --no-deps https://github.com/vecxoz/vecstack/archive/n_dim_input.zip

You can return to stable version anytime you want:

pip install --user --upgrade --force-reinstall --no-deps vecstack

@vecxoz vecxoz changed the title convolution_Stacking N-dimensional input (stacking for convolutional nets) Jan 6, 2019
@vecxoz
Copy link
Owner

vecxoz commented Jan 6, 2019

Branch n_dim_input was merged into master (#20).

@vecxoz vecxoz closed this as completed Jan 6, 2019
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

2 participants