Suppose the input is a index of 3 items such as (1,2,3), I want to get 3 embedding vector corresponding to the 3 items and then get the average of 3 vectors. Here are two method:
method 1:
item1_input = Input(shape=(1,), dtype='int32', name = 'item1_input')
item2_input = Input(shape=(1,), dtype='int32', name = 'item2_input')
item3_input = Input(shape=(1,), dtype='int32', name = 'item3_input')
Embedding_Item = Embedding(input_dim = num_items, output_dim = layers[0]/2, name = 'item_embedding',init = init_normal, W_regularizer = l2(reg_layers[0]), input_length=1)
item1_latent = Flatten()(Embedding_Item(item1_input))
item2_latent = Flatten()(Embedding_Item(item2_input))
item3_latent = Flatten()(Embedding_Item(item3_input))
itemset_latent = merge([item1_latent, item2_latent, item3_latent], mode = 'ave')
which uses a shared embbedings to get 3 vectors.
method 2:
item_input = Input(shape=(3,), dtype='int32', name = 'item_input')
Embedding_Item = Embedding(input_dim = num_items+1, output_dim = layers[0]/2, name = 'item_embedding',
init = init_normal, W_regularizer = l2(reg_layers[0]), input_length=3, mask_zero=True)
item_zeroed = ZeroMaskedEntries()(Embedding_Item(item_input))
lambda_mean = Lambda(mask_aware_mean,mask_aware_mean_output_shape)(item_zeroed)
which use a lambda layer to get the average value of the 3 item embeddings from the same embedding layer.(copied from the question Average of non-zero word embeddings [https://github.com/keras-team/keras/issues/1579])
Question: Is there any difference between the two method? What's the differences if there exits?