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

problem with crf layer #2

Open
jozi opened this issue Jan 22, 2018 · 0 comments
Open

problem with crf layer #2

jozi opened this issue Jan 22, 2018 · 0 comments

Comments

@jozi
Copy link

jozi commented Jan 22, 2018

this is my model

    model = Sequential()
    model.add(Bidirectional(LSTM(CONFIG.hidden_size, return_sequences=True),input_shape=(CONFIG.max_input_len,CONFIG.number_of_chars)))
    model.add(Dropout(CONFIG.amount_of_dropout))
    model.add(TimeDistributed(Dense(n_classes, activation='softmax'),input_shape=(CONFIG.max_input_len, CONFIG.number_of_chars)))
    model.add(Dropout(0.2))
    crf = CRFLayer()
    model.add(crf(inputs=[CONFIG.max_input_len,CONFIG.number_of_chars]))
    model.compile(loss=crf.loss, optimizer='rmsprop', metrics=['accuracy'])

and get a error
ValueError: Layer crf_layer_1 was called with an input that isn't a symbolic tensor. Received type: <class 'int'>. Full input: [60, 53]. All inputs to the layer should be tensors.
below work nice without crf

    model = Sequential()
    model.add(Bidirectional(LSTM(CONFIG.hidden_size, return_sequences=True),input_shape=(CONFIG.max_input_len,CONFIG.number_of_chars)))
    model.add(Dropout(CONFIG.amount_of_dropout))
    model.add(TimeDistributed(Dense(n_classes,activation='softmax'), input_shape=(CONFIG.max_input_len, CONFIG.number_of_chars)))

    model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['categorical_accuracy'])


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

1 participant