Views
No views yet
keras-hub-nightly package. Use pip install keras-hub-nightly to try this model.from_preset() constructor.pip install -U -q keras-hub
pip install -U -q keras80.max_encoder_sequence_length // 2 as the sequence length for the
positional embedding layer.1import keras_hub
2import keras_core as keras
3import numpy as np1input_data = {
2 "encoder_features": np.ones(shape=(1, 12, 80), dtype="int32"),
3 "decoder_token_ids": np.ones(shape=(1, 12), dtype="int32"),
4 "decoder_padding_mask": np.array(
5 [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]]
6 ),
7}
8
9# Randomly initialized Whisper encoder-decoder model with a custom config.
10model = keras_hub.models.WhisperBackbone(
11 vocabulary_size=51864,
12 num_layers=4,
13 num_heads=4,
14 hidden_dim=256,
15 intermediate_dim=512,
16 max_encoder_sequence_length=128,
17 max_decoder_sequence_length=128,
18)
19model(input_data)1import keras_hub
2import keras_core as keras
3import numpy as np1input_data = {
2 "encoder_features": np.ones(shape=(1, 12, 80), dtype="int32"),
3 "decoder_token_ids": np.ones(shape=(1, 12), dtype="int32"),
4 "decoder_padding_mask": np.array(
5 [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]]
6 ),
7}
8
9# Randomly initialized Whisper encoder-decoder model with a custom config.
10model = keras_hub.models.WhisperBackbone(
11 vocabulary_size=51864,
12 num_layers=4,
13 num_heads=4,
14 hidden_dim=256,
15 intermediate_dim=512,
16 max_encoder_sequence_length=128,
17 max_decoder_sequence_length=128,
18)
19model(input_data)