continuous_value_model

paddle.fluid.layers.nn. continuous_value_model ( input, cvm, use_cvm=True ) [source]

continuous_value_model layers

Now, this OP is used in CTR project to remove or dispose show and click value in input.

input is an embedding vector including show and click value, whose shape is \([N, D]\) (N is batch size. D is 2 + embedding dim ). Show and click at first two dims of embedding vector D. If use_cvm is True, it will calculate \(log(show)\) and \(log(click)\) , and output shape is \([N, D]\) . If use_cvm is False, it will remove show and click from input , and output shape is \([N, D - 2]\) . cvm is show_click info, whose shape is \([N, 2]\) .

Parameters
  • input (Variable) – The input variable. A 2-D LoDTensor with shape \([N, D]\) , where N is the batch size, D is 2 + the embedding dim . lod level = 1 .

  • float32 (A Tensor with type) –

  • float64.

  • cvm (Variable) – Show and click variable. A 2-D Tensor with shape \([N, 2]\) , where N is the batch size, 2 is show and click.

  • float32

  • float64.

  • use_cvm (bool) – Use show_click or not. if use, the output dim is the same as input. if not use, the output dim is input dim - 2 (remove show and click)

Returns

A 2-D LodTensor with shape \([N, M]\) . if use_cvm = True, M is equal to input dim D. if False, M is equal to D - 2. A Tensor with same type as input.

Return type

Variable

Examples

import paddle.fluid as fluid
input = fluid.data(name="input", shape=[64, 1], dtype="int64")
label = fluid.data(name="label", shape=[64, 1], dtype="int64")
embed = fluid.layers.embedding(
                  input=input,
                  size=[100, 11],
                  dtype='float32')
ones = fluid.layers.fill_constant_batch_size_like(input=label, shape=[-1, 1], dtype="int64", value=1)
show_clk = fluid.layers.cast(fluid.layers.concat([ones, label], axis=1), dtype='float32')
show_clk.stop_gradient = True
input_with_cvm = fluid.layers.continuous_value_model(embed, show_clk, True)