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 export a slightly customized XLMRoberta model from keras_nlp #1863

Closed
YangIsNotAvailable opened this issue May 16, 2024 · 1 comment
Closed
Assignees

Comments

@YangIsNotAvailable
Copy link

Issue Type

Bug

Source

source

Keras Version

3.3.3

Custom Code

Yes

OS Platform and Distribution

Ubuntu 20.04.6 LTS

Python version

3.10

GPU model and memory

No response

Current Behavior?

Cannot export the model.

Standalone code to reproduce the issue or tutorial link

import keras
from keras_nlp.models import XLMRobertaPreprocessor, XLMRobertaBackbone
import tensorflow as tf

preprocessor = XLMRobertaPreprocessor.from_preset("xlm_roberta_base_multi")
backbone = XLMRobertaBackbone.from_preset("xlm_roberta_base_multi")

inputs = keras.Input(shape=(), dtype=tf.string)
x = preprocessor(inputs)
x = backbone(x)
x = keras.layers.GlobalAveragePooling1D()(x)
outputs = keras.layers.Dense(10)(x)
model = keras.Model(inputs, outputs)

model.compile(optimizer=keras.optimizers.AdamW())

model.export("./test.tfsm")


### Relevant log output

```shell
AssertionError: Tried to export a function which references an 'untracked' resource. TensorFlow objects (e.g. tf.Variable) captured by functions must be 'tracked' by assigning them to an attribute of a tracked object or assigned to an attribute of the main object directly. See the information below:
        Function name = b'__inference_signature_wrapper___call___11987'
        Captured Tensor = <ResourceHandle(name="_0_SentencepieceOp", device="/job:localhost/replica:0/task:0/device:CPU:0", container="localhost", type="tensorflow::text::(anonymous namespace)::SentencepieceResource", dtype and shapes : "[  ]")>
        Trackable referencing this tensor = <tensorflow_text.python.ops.sentencepiece_tokenizer._SentencepieceModelResource object at 0x7fe279bef640>
        Internal Tensor = Tensor("11587:0", shape=(), dtype=resource)
@YangIsNotAvailable
Copy link
Author

Submitted the issue to keras-nlp instead.

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