r""" **continuous_value_model layers** Now, this OP is used in CTR project to remove or dispose show and click value in :attr:`input`. :attr:`input` is an embedding vector including show and click value, whose shape is :math:`[N, D]` (N is batch size. D is `2 + embedding dim` ). Show
(input, cvm, use_cvm=True)
| 415 | |
| 416 | @static_only |
| 417 | def continuous_value_model(input, cvm, use_cvm=True): |
| 418 | r""" |
| 419 | **continuous_value_model layers** |
| 420 | Now, this OP is used in CTR project to remove or dispose show and click value in :attr:`input`. |
| 421 | :attr:`input` is an embedding vector including show and click value, whose shape is :math:`[N, D]` (N is batch size. D is `2 + embedding dim` ). |
| 422 | Show and click at first two dims of embedding vector D. |
| 423 | If :attr:`use_cvm` is True, it will calculate :math:`log(show)` and :math:`log(click)` , and output shape is :math:`[N, D]` . |
| 424 | If :attr:`use_cvm` is False, it will remove show and click from :attr:`input` , and output shape is :math:`[N, D - 2]` . |
| 425 | :attr:`cvm` is show_click info, whose shape is :math:`[N, 2]` . |
| 426 | Args: |
| 427 | input (Variable): The input variable. A 2-D DenseTensor with shape :math:`[N, D]` , where N is the batch size, D is `2 + the embedding dim` . `lod level = 1` . |
| 428 | A Tensor with type float32, float64. |
| 429 | cvm (Variable): Show and click variable. A 2-D Tensor with shape :math:`[N, 2]` , where N is the batch size, 2 is show and click. |
| 430 | A Tensor with type float32, float64. |
| 431 | use_cvm (bool): Use show_click or not. if use, the output dim is the same as input. |
| 432 | if not use, the output dim is `input dim - 2` (remove show and click) |
| 433 | Returns: |
| 434 | Variable: A 2-D DenseTensor with shape :math:`[N, M]` . if :attr:`use_cvm` = True, M is equal to input dim D. if False, M is equal to `D - 2`. \ |
| 435 | A Tensor with same type as input. |
| 436 | Examples: |
| 437 | .. code-block:: pycon |
| 438 | |
| 439 | >>> import paddle |
| 440 | |
| 441 | >>> paddle.enable_static() |
| 442 | >>> input = paddle.static.data(name="input", shape=[64, 1], dtype="int64") |
| 443 | >>> label = paddle.static.data(name="label", shape=[64, 1], dtype="int64") |
| 444 | >>> w0 = paddle.full(shape=(100, 1), fill_value=2).astype(paddle.float32) |
| 445 | >>> embed = paddle.nn.functional.embedding(input, w0) |
| 446 | >>> ones = paddle.full_like(label, 1, dtype="int64") |
| 447 | >>> show_clk = paddle.cast(paddle.concat([ones, label], axis=1), dtype='float32') |
| 448 | >>> show_clk.stop_gradient = True |
| 449 | >>> input_with_cvm = paddle.static.nn.continuous_value_model(embed[:, 0], show_clk, True) |
| 450 | """ |
| 451 | helper = LayerHelper('cvm', **locals()) |
| 452 | out = helper.create_variable(dtype=input.dtype) |
| 453 | check_variable_and_dtype( |
| 454 | input, 'input', ['float16', 'float32', 'float64'], 'cvm' |
| 455 | ) |
| 456 | helper.append_op( |
| 457 | type='cvm', |
| 458 | inputs={'X': [input], 'CVM': [cvm]}, |
| 459 | outputs={'Y': [out]}, |
| 460 | attrs={"use_cvm": use_cvm}, |
| 461 | ) |
| 462 | return out |
| 463 | |
| 464 | |
| 465 | def group_norm( |
nothing calls this directly
no test coverage detected