home scroll deno

AI learning blog April 2026

April 2, 2026

The example for text vectorization:
https://www.tensorflow.org/tutorials/load_data/text

links to a colab page:
https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/load_data/text.ipynb

Even the colab page does not work!

First line
!pip install "tensorflow-text==2.13.*"
causes error
ERROR: Could not find a version that satisfies the requirement tensorflow-text==2.13.* (from versions: 2.18.1, 2.19.0rc0, 2.19.0, 2.20.0, 2.20.1)
ERROR: No matching distribution found for tensorflow-text==2.13.*

April 2, 2026

Attempt with newer software versions
conda create -n tf-text python=3.13.11
Then activate this environment before installing packages!
conda activate tf-text
Then install via pip
pip install tensorflow-text
and
conda install -c conda-forge matplotlib -y
pip install tensorflow_datasets
This gets rid of the Protobuf gencode error, but
still causes the End of sequence error
tensorflow/core/framework/local_rendezvous.cc:407] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence

April 3, 2026

The example at
https://colab.research.google.com/github/tensorflow/datasets/blob/master/docs/_index.ipynb
causes the errors
tensorflow/core/kernels/data/tf_record_dataset_op.cc:396] The default buffer size is 262144, which is overridden by the user specified `buffer_size` of 8388608
tensorflow/core/kernels/data/cache_dataset_ops.cc:917] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset will be discarded. This can happen if you have an input pipeline similar to `dataset.cache().take(k).repeat()`. You should use `dataset.take(k).cache().repeat()` instead.
tensorflow/core/framework/local_rendezvous.cc:407] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence


An error that was described on github:
https://github.com/tensorflow/tensorflow/issues/62963
I was able to reproduce the error.

Previous page refers to (link named issue)
https://github.com/tensorflow/tensorflow/issues/68593

A post on March 2 says that tensorflow 2.21 resolves the issue.
It refers to a gist
https://colab.research.google.com/gist/Venkat6871/fdd5ded66d27bf590c8b3e52f60a5115/68593_tf_2-21-0-rc0-nightly-v.ipynb
To get a newer tensorflow:
pip uninstall tensorflow -y && pip install tf-nightly


April 4, 2026

This package configuration lets the example at
https://colab.research.google.com/gist/Venkat6871/fdd5ded66d27bf590c8b3e52f60a5115/68593_tf_2-21-0-rc0-nightly-v.ipynb
run without error:
conda create -n tf-new python=3.13.11
Then activate this environment before installing packages!
conda activate tf-new
pip uninstall tensorflow -y && pip install tf-nightly
The code
print(f"Tensor Flow Version: {tf.__version__}")
will now report
Tensor Flow Version: 2.22.0-dev20260404

Both
conda list
pip list
report
tf_nightly 2.22.0.dev20260404
but no tensorflow package.


If I try to run the example
https://www.tensorflow.org/tutorials/load_data/text
python complains:
ModuleNotFoundError: No module named 'tensorflow_text'
When I install tensorflow-text with
pip install tensorflow-text
the command will unfortunately also install tensorflow version 2.20
tensorboard 2.20.0 pypi_0 pypi
and
print(f"Tensor Flow Version: {tf.__version__}")
will report
Tensor Flow Version: 2.20.0
in other words, the tensorflow-text install has ruined the configuration and the End of Sequence error is back.


Lets try the latest release:

Tensorflow Releases:
https://github.com/tensorflow/tensorflow/releases

conda create -n tf-new python=3.13.11
Then activate this environment before installing packages!
conda activate tf-new
Checking the version:
pip install tensorflow==2.21.0
print(f"Tensor Flow Version: {tf.__version__}")
will report
Tensor Flow Version: 2.21.0
The example at
https://colab.research.google.com/gist/Venkat6871/fdd5ded66d27bf590c8b3e52f60a5115/68593_tf_2-21-0-rc0-nightly-v.ipynb
runs without error.
pip install tensorflow_datasets
will work, but
pip install tensorflow-text
will downgrade tensorflow to version 2.20

and the End of sequence error is back.


Is there an older version of the packages that works?

Note: https://github.com/tensorflow/text
requests that the same version of tensorflow-text is installed as tensorflow.
Tried Tensorflow 2.18, 2.14, 2.11, 2.10,
None of them worked.


April 5, 2026

More examples: Attention and Transformers
"Understanding and Coding the Self-Attention Mechanism of Large Language Models From Scratch"
https://sebastianraschka.com/blog/2023/self-attention-from-scratch.html

English-Spanish Translation: Transformer
https://www.kaggle.com/code/lonnieqin/english-spanish-translation-transformer

The Illustrated Transformer
https://jalammar.github.io/illustrated-transformer/

The Annotated Transformer
https://nlp.seas.harvard.edu/2018/04/03/attention.html


English-Portugal Translation using Transformers
https://www.kaggle.com/code/dnayan/english-portugal-translation-using-transformers
Online Courses
Coursera Sequence Models
https://www.coursera.org/learn/nlp-sequence-models#modules

April 7, 2026

Example from Kaggle:

English-Spanish Translation: Transformer
https://www.kaggle.com/code/lonnieqin/english-spanish-translation-transformer


April 13, 2026

The English-Spanish Translation: Transformer example on Kaggle works, except for the saving and loading process of the model.

The code does not have an explicit save instruction, rather intermediate progress is saved in the tf.keras.callbacks.ModelCheckpoint callback of the model.fit() call.

When I run the code as is, the checkpoint saving results in a directory named model.tf being created, however loading the model leads to an error.

The following applies to loading inside the training block

The original combination
filepath="model.tf",
..
transformer.load_weights("model.tf")
leads to an error
tensorflow/core/util/tensor_slice_reader.cc:98] Could not open model.tf: FAILED_PRECONDITION: model.tf; Is a directory: perhaps your file is in a different file format and you need to use a different restore operator?

The combination
filepath="model.tf",
..
transformer.load_model("model.tf")
leads to an error
AttributeError: 'Functional' object has no attribute 'load_model'

The API documentation of tf.keras.callbacks.ModelCheckpoint at
https://www.tensorflow.org/api_docs/python/tf/keras/callbacks/ModelCheckpoint
mentions only files for saving weights or the model, but not a folder:
- weights.h5 for saving weights only
- model.keras for saving the whole model.

The combination
filepath="model.keras",
..
transformer.load_model("model.keras")
leads to an error
AttributeError: 'Functional' object has no attribute 'load_model'

The combination
filepath="model.keras",
..
transformer.load_weights("model.keras")
works, and the translation is successful.





April 14, 2026

The transformer can also be saved explicitly, outside of the checkpoint callback.

transformer.save("model.keras")
However, loading the transformer
transformer.load_model("model.keras")
leads to the error
TypeError: Cannot deserialize object of type `PositionalEmbedding`. If `PositionalEmbedding` is a custom class, please register it using the `@keras.saving.register_keras_serializable()` decorator.


This problem can be solved by declaring the classes
transformer = load_model(
 checkpoint_filepath,
 custom_objects={
  "PositionalEmbedding": PositionalEmbedding,
  "TransformerEncoder": TransformerEncoder,
  "TransformerDecoder": TransformerDecoder,
 }
)
"save and load keras transformer model"
https://stackoverflow.com/questions/78396871/save-and-load-keras-transformer-model

April 17, 2026

When loading the transformer that was trained with English-Spanish language data, it is necesseray to provide the vocabulary with which the transformer was trained to the code.


This can be done by using the same steps in the training for the original input data:

- load into Pandas dataframe
- strip punctuation characters
- standardize
- TextVectorization
- adapt



April 18, 2026

Datasets for translation:
Tab-delimited Bilingual Sentence Pairs
https://www.manythings.org/anki/


Follow Me

discord