Deep Semantic Structured Model (DSSM)¶
The module dssm
provides functions to build a DSSM.
-
dssm.
build_multi_dssm
(input_var=None, num_samples=None, num_entries=6, num_ngrams=74088, num_hid1=300, num_hid2=300, num_out=128)[source]¶ Builds a DSSM structure in a Lasagne/Theano way.
The built DSSM is the neural network that computes the projection of only one paper. The input
input_var
should have two dimensions: (num_samples * num_entries
,num_ngrams
). The output is then computed in a batch way: one paper at a time, but all papers from the same sample in the dataset are grouped (cited papers, citing papers andnum_entries - 2
irrelevant papers).Parameters: - input_var (
theano.tensor.TensorType
or None) – symbolic input variable of the DSSM - num_samples (int) – the number of samples in the batch input dataset (number of rows)
- num_entries (int) – the number of compared papers in the DSSM structure
- num_ngrams (int) – the size of the vocabulary
- num_hid1 (int) – the number of units in the first hidden layer
- num_hid2 (int) – the number of units in the second hidden layer
- num_out (int) – the number of units in the output layer
Returns: the output layer of the DSSM
Return type: lasagne.layers.Layer
- input_var (
-
dssm.
compute_loss
(output, num_samples, num_entries=6, gamma=500.0)[source]¶ Compute the loss of a dataset, given the output of the DSSM.
Parameters: - output (
lasagne.layers.Layer
) – the output of the DSSM - num_samples (int) – the number of samples in the dataset
- num_entries (int) – the number of compared papers in the DSSM structure
- gamma (float) – the coefficient applied in the softmax of the similarities
Returns: the loss of the dataset
Return type: theano.tensor.TensorType
- output (
-
dssm.
iterate_minibatches
(inputs, batchsize, shuffle=False)[source]¶ Produces an batch iterator over the input.
- Usage:
>>> for batch in iterate_minibatches(inputs, batchsize, shuffle): >>> # to stuff
Parameters: - inputs (list) – the input list over which iterate
- batchsize (int) – the size of each batch
- shuffle (bool) – if True,
inputs
is shuffled before iteration