Giter VIP home page Giter VIP logo

Comments (4)

skyduy avatar skyduy commented on August 22, 2024 3

@kaya27
Please paste your code here with the error information.

from cnn_keras.

kaya27 avatar kaya27 commented on August 22, 2024

thank you for your reply, I'm a beginner to CNN networks
here is the code:
graph = Graph()
graph.add_input(name='cap', input_shape=(1,), dtype=int)
graph.add_input(name='pref', input_shape=(1,), dtype=int)
graph.add_input(name="pre_word_emb", input_shape=(None, embeddings_dim), dtype="float")
graph.add_node(Embedding(suff_size, suff_dim, init='glorot_uniform'), name="prefix", input="pref")
graph.add_node(Embedding(cap_size, cap_dim, init='glorot_uniform'), name="capitalization", input="cap")

graph.add_node(Convolution2D(400, 5, 5, activation='relu'), name='conv1', inputs=inputs=["prefix","capitalization","pre_word_emb"])
graph.add_node(MaxPooling2D(pool_size=(2, 2)), name='pool1', input='conv1')
graph.add_node(Convolution2D(44, 3, 3, activation='relu'), name='conv2', input='pool1')
graph.add_node(MaxPooling2D(pool_size=(2, 2)), name='pool2', input='conv2')
graph.add_node(Dropout(0.25), name='drop', input='pool2')
graph.add_node(Flatten(), name='flatten', input='drop')
graph.add_node(Dense(640, activation='relu'), name='ip', input='flatten')
graph.add_node(Dropout(0.5), name='drop_out', input='ip')
graph.add_node(Dense(19, activation='softmax'), name='result', input='drop_out')
graph.add_output(name='output', input='result')
graph.compile(optimizer='adadelta',loss={'output': 'categorical_crossentropy'})
print(graph.summary())

the error message is:
graph.add_node(Convolution2D(400, 5, 5, activation='relu'), name='conv1', inputs=["suff_emb","capitalization","pre_word_emb"])
AssertionError: Incompatible shapes: layer expected input with ndim=4 but previous layer has output_shape (None, None, 310)

thanks in advance

from cnn_keras.

skyduy avatar skyduy commented on August 22, 2024

Sorry but I haven't used the layer inputs with the "layer list" and even the Embedding layer or integrate them, actually I'm a beginner too😄. But the error tip means your inputs is wrong, I guess that after the shape (1,) and (1,) was embedded, it's "dim" may doesn't work, because a dimension with shape 1 can mean no this dimension. another possibility is that the code grammar may be wrong somewhere.
I remember that the layer's input and output can be checked, but I forget how to do that. The keras's Docs may help😁.

from cnn_keras.

kaya27 avatar kaya27 commented on August 22, 2024

thank you for your reply :) I will check the keras Docs
but as I have understand from the error message the problem is on shapes
I will told you when I will solve it (I hope :p )
have great day!

from cnn_keras.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.