October 2018
Intermediate to advanced
472 pages
10h 57m
English
Our images and captions are ready! Next, let's create a tf.data dataset (https://www.tensorflow.org/api_docs/python/tf/data/Dataset) to use for training our model. Now we will prepare the pipeline for an image and the text model by performing transformations and batching on them:
# Defining parametersBATCH_SIZE = 64BUFFER_SIZE = 1000embedding_dim = 256units = 512vocab_size = len(tokenizer.word_index)# shape of the vector extracted from Inception-V3 is (64, 2048)# these two variables represent thatfeatures_shape = 2048attention_features_shape = 64# loading the numpy files def map_func(img_name, cap): img_tensor = np.load(img_name.decode('utf-8')+'.npy') return img_tensor, cap#We use the from_tensor_slices to load ...Read now
Unlock full access