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

reshape error after embedding layer ... #6175

Closed
saikswaroop opened this issue Aug 16, 2018 · 6 comments

Comments

@saikswaroop
Copy link

commented Aug 16, 2018

Im trying to reshape output of embedding layer , but its giving me following error ,can some one throw light on this

Exception in thread "main" java.lang.IllegalStateException: Input shape [1, 512,
1] and output shape[1] do not match
at org.deeplearning4j.nn.modelimport.keras.preprocessors.ReshapePreprocessor.pr
eProcess(ReshapePreprocessor.java:102)
at org.deeplearning4j.nn.graph.vertex.impl.PreprocessorVertex.doForward(Preproc
essorVertex.java:60)
at org.deeplearning4j.nn.graph.ComputationGraph.outputOfLayersDetached(Computat
ionGraph.java:2287)
at org.deeplearning4j.nn.graph.ComputationGraph.output(ComputationGraph.java:16
98)
at org.deeplearning4j.nn.graph.ComputationGraph.output(ComputationGraph.java:16
48)
at org.deeplearning4j.nn.graph.ComputationGraph.output(ComputationGraph.java:16
29)
at dl4j.dl4j_test.App.main(App.java:62)
@ @maxpumperla

@saikswaroop

This comment has been minimized.

Copy link
Author

commented Aug 16, 2018

Below is the code used for generating the model

 
auxiliary_input = Input(shape=(150,), name='aux_input')
nsfw_input = Input(shape=(2,), name='nsfw_input') 
 

x = Embedding(output_dim=512, input_dim=lenuniqclients, input_length=1)(main_input)
x= Reshape(( 512,), input_shape=( None ,1, 512))(x) 
x = keras.layers.concatenate([x, auxiliary_input, nsfw_input])

x = Dense(662, activation='relu' )(x)
x = Dense(320, activation='relu')(x)
 


pv_branch1 = Dense(120, activation='relu', name='pv_branch1')(x)
pv_branch2 = Dense(32, activation='relu', name='pv_branch2')(pv_branch1)


dislike_branch1 = Dense(120, activation='relu', name='dislike_branch1')(x)
dislike_branch2 = Dense(32, activation='relu', name='dislike_branch2')(dislike_branch1)


pv_output = Dense(1, activation='sigmoid', name='pv_output')(pv_branch2)
dislike_output = Dense(1, activation='sigmoid', name='dislike_output')(dislike_branch2)
@AlexDBlack

This comment has been minimized.

Copy link
Contributor

commented Aug 16, 2018

@saikswaroop What version of DL4J are you using?
If you're not on 1.0.0-beta2, upgrade to that first.

@saikswaroop

This comment has been minimized.

Copy link
Author

commented Aug 16, 2018

@AlexDBlack
Im using 1.0.0-beta2 ... specifically iam using the following jars from dl4j-examples repo and adding them to my classpath.
dl4j-examples-1.0.0-beta2.jar
dl4j-examples-1.0.0-beta2-bin.jar

@maxpumperla

This comment has been minimized.

Copy link

commented Aug 16, 2018

@saikswaroop I'll take a look. From the model it's not quite clear why you don't just use a a Flatten layer instead? Reshape is the layer that we have most issues with as it's too flexible for DL4J standards. easy to misuse.

@maxpumperla

This comment has been minimized.

Copy link

commented Aug 20, 2018

@saikswaroop I ran into a similar issue that I fixed in #6212 and I think it closes your issue as well. Feel free to reopen, if not (I can't execute your snippet, please provide a standalone script that reproduces your problem in that case)

@lock

This comment has been minimized.

Copy link

commented Sep 21, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Sep 21, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.