Densely-connected layer class. This layer implements the operation: `outputs = activation(inputs * kernel + bias)` Where `activation` is the activation function passed as the `activation` argument (if not `None`), `kernel` is a weights matrix created by the layer, and `bias` is a bias vec
| 31 | |
| 32 | @tf_export(v1=['layers.Dense']) |
| 33 | class Dense(keras_layers.Dense, base.Layer): |
| 34 | """Densely-connected layer class. |
| 35 | |
| 36 | This layer implements the operation: |
| 37 | `outputs = activation(inputs * kernel + bias)` |
| 38 | Where `activation` is the activation function passed as the `activation` |
| 39 | argument (if not `None`), `kernel` is a weights matrix created by the layer, |
| 40 | and `bias` is a bias vector created by the layer |
| 41 | (only if `use_bias` is `True`). |
| 42 | |
| 43 | Arguments: |
| 44 | units: Integer or Long, dimensionality of the output space. |
| 45 | activation: Activation function (callable). Set it to None to maintain a |
| 46 | linear activation. |
| 47 | use_bias: Boolean, whether the layer uses a bias. |
| 48 | kernel_initializer: Initializer function for the weight matrix. |
| 49 | If `None` (default), weights are initialized using the default |
| 50 | initializer used by `tf.compat.v1.get_variable`. |
| 51 | bias_initializer: Initializer function for the bias. |
| 52 | kernel_regularizer: Regularizer function for the weight matrix. |
| 53 | bias_regularizer: Regularizer function for the bias. |
| 54 | activity_regularizer: Regularizer function for the output. |
| 55 | kernel_constraint: An optional projection function to be applied to the |
| 56 | kernel after being updated by an `Optimizer` (e.g. used to implement |
| 57 | norm constraints or value constraints for layer weights). The function |
| 58 | must take as input the unprojected variable and must return the |
| 59 | projected variable (which must have the same shape). Constraints are |
| 60 | not safe to use when doing asynchronous distributed training. |
| 61 | bias_constraint: An optional projection function to be applied to the |
| 62 | bias after being updated by an `Optimizer`. |
| 63 | trainable: Boolean, if `True` also add variables to the graph collection |
| 64 | `GraphKeys.TRAINABLE_VARIABLES` (see `tf.Variable`). |
| 65 | name: String, the name of the layer. Layers with the same name will |
| 66 | share weights, but to avoid mistakes we require reuse=True in such cases. |
| 67 | _reuse: Boolean, whether to reuse the weights of a previous layer |
| 68 | by the same name. |
| 69 | |
| 70 | Properties: |
| 71 | units: Python integer, dimensionality of the output space. |
| 72 | activation: Activation function (callable). |
| 73 | use_bias: Boolean, whether the layer uses a bias. |
| 74 | kernel_initializer: Initializer instance (or name) for the kernel matrix. |
| 75 | bias_initializer: Initializer instance (or name) for the bias. |
| 76 | kernel_regularizer: Regularizer instance for the kernel matrix (callable) |
| 77 | bias_regularizer: Regularizer instance for the bias (callable). |
| 78 | activity_regularizer: Regularizer instance for the output (callable) |
| 79 | kernel_constraint: Constraint function for the kernel matrix. |
| 80 | bias_constraint: Constraint function for the bias. |
| 81 | kernel: Weight matrix (TensorFlow variable or tensor). |
| 82 | bias: Bias vector, if applicable (TensorFlow variable or tensor). |
| 83 | """ |
| 84 | |
| 85 | def __init__(self, units, |
| 86 | activation=None, |
| 87 | use_bias=True, |
| 88 | kernel_initializer=None, |
| 89 | bias_initializer=init_ops.zeros_initializer(), |
| 90 | kernel_regularizer=None, |