Functional interface for the densely-connected layer. 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, a
(
inputs, units,
activation=None,
use_bias=True,
kernel_initializer=None,
bias_initializer=init_ops.zeros_initializer(),
kernel_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None,
bias_constraint=None,
trainable=True,
name=None,
reuse=None)
| 114 | date=None, instructions='Use keras.layers.Dense instead.') |
| 115 | @tf_export(v1=['layers.dense']) |
| 116 | def dense( |
| 117 | inputs, units, |
| 118 | activation=None, |
| 119 | use_bias=True, |
| 120 | kernel_initializer=None, |
| 121 | bias_initializer=init_ops.zeros_initializer(), |
| 122 | kernel_regularizer=None, |
| 123 | bias_regularizer=None, |
| 124 | activity_regularizer=None, |
| 125 | kernel_constraint=None, |
| 126 | bias_constraint=None, |
| 127 | trainable=True, |
| 128 | name=None, |
| 129 | reuse=None): |
| 130 | """Functional interface for the densely-connected layer. |
| 131 | |
| 132 | This layer implements the operation: |
| 133 | `outputs = activation(inputs * kernel + bias)` |
| 134 | where `activation` is the activation function passed as the `activation` |
| 135 | argument (if not `None`), `kernel` is a weights matrix created by the layer, |
| 136 | and `bias` is a bias vector created by the layer |
| 137 | (only if `use_bias` is `True`). |
| 138 | |
| 139 | Arguments: |
| 140 | inputs: Tensor input. |
| 141 | units: Integer or Long, dimensionality of the output space. |
| 142 | activation: Activation function (callable). Set it to None to maintain a |
| 143 | linear activation. |
| 144 | use_bias: Boolean, whether the layer uses a bias. |
| 145 | kernel_initializer: Initializer function for the weight matrix. |
| 146 | If `None` (default), weights are initialized using the default |
| 147 | initializer used by `tf.compat.v1.get_variable`. |
| 148 | bias_initializer: Initializer function for the bias. |
| 149 | kernel_regularizer: Regularizer function for the weight matrix. |
| 150 | bias_regularizer: Regularizer function for the bias. |
| 151 | activity_regularizer: Regularizer function for the output. |
| 152 | kernel_constraint: An optional projection function to be applied to the |
| 153 | kernel after being updated by an `Optimizer` (e.g. used to implement |
| 154 | norm constraints or value constraints for layer weights). The function |
| 155 | must take as input the unprojected variable and must return the |
| 156 | projected variable (which must have the same shape). Constraints are |
| 157 | not safe to use when doing asynchronous distributed training. |
| 158 | bias_constraint: An optional projection function to be applied to the |
| 159 | bias after being updated by an `Optimizer`. |
| 160 | trainable: Boolean, if `True` also add variables to the graph collection |
| 161 | `GraphKeys.TRAINABLE_VARIABLES` (see `tf.Variable`). |
| 162 | name: String, the name of the layer. |
| 163 | reuse: Boolean, whether to reuse the weights of a previous layer |
| 164 | by the same name. |
| 165 | |
| 166 | Returns: |
| 167 | Output tensor the same shape as `inputs` except the last dimension is of |
| 168 | size `units`. |
| 169 | |
| 170 | Raises: |
| 171 | ValueError: if eager execution is enabled. |
| 172 | """ |
| 173 | layer = Dense(units, |