(self, weights)
| 175 | )) |
| 176 | |
| 177 | def set_weights(self, weights): |
| 178 | params = self.weights |
| 179 | # If the weights are generated by Keras V1 optimizer, it includes vhats |
| 180 | # even without amsgrad, i.e, V1 optimizer has 3x + 1 variables, while V2 |
| 181 | # optimizer has 2x + 1 variables. Filter vhats out for compatibility. |
| 182 | num_vars = int((len(params) - 1) / 2) |
| 183 | if len(weights) == 3 * num_vars + 1: |
| 184 | weights = weights[:len(params)] |
| 185 | super(Adam, self).set_weights(weights) |
| 186 | |
| 187 | def _resource_apply_dense(self, grad, var, apply_state=None): |
| 188 | var_device, var_dtype = var.device, var.dtype.base_dtype |
no outgoing calls