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

Cannot load trained model #3

Open
chessgenius opened this issue Oct 19, 2021 · 0 comments
Open

Cannot load trained model #3

chessgenius opened this issue Oct 19, 2021 · 0 comments

Comments

@chessgenius
Copy link

chessgenius commented Oct 19, 2021

Dear author,

I use this code

import sentencepiece as spm
# import tensorflow_hub as hub
import tensorflow as tf

sp = spm.SentencePieceProcessor(model_file='assets/albertvi_30k-clean.model')

input_ids = sp.encode("Tui rất là đẹp trai.")


tags = set()
# if is_training:
#   tags.add("train")
# albert_module = hub.Module("./base", tags=tags,
#                            trainable=False)
with tf.Session() as sess:
    saver = tf.compat.v1.train.import_meta_graph('base/model.ckpt-1015000.meta')
    saver.restore(sess, 'base/model.ckpt-1015000.data-00000-of-00001')

    # graph = tf.get_default_graph()

    albert_inputs = dict(
        input_ids=input_ids,
        # input_mask=input_mask,
        # segment_ids=segment_ids
    )
    # albert_outputs = model(
    #     inputs=albert_inputs,
    #     signature="tokens",
    #     as_dict=True)

# If you want to use the token-level output, use
# albert_outputs["sequence_output"] instead.
#     output_layer = albert_outputs["pooled_output"]


But It has an error

err, "a mismatch between the current graph and the graph")

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