forked from huawei/mindspore2022
clean nn codec check
This commit is contained in:
parent
5bcaae94a7
commit
b16d7cd28f
|
|
@ -368,20 +368,7 @@ class Adam(Optimizer):
|
|||
"""
|
||||
If the input value is set to "CPU", the parameters will be updated on the host using the Fused
|
||||
optimizer operation."""
|
||||
if not isinstance(value, str):
|
||||
raise TypeError("The value must be str type, but got value type is {}".format(type(value)))
|
||||
|
||||
if value not in ('CPU', 'Ascend', 'GPU'):
|
||||
raise ValueError("The value must be 'CPU', 'Ascend' or 'GPU', but got value {}".format(value))
|
||||
|
||||
if self._target == "CPU" and value in ('Ascend', 'GPU'):
|
||||
raise ValueError("In the CPU environment, target cannot be set to 'GPU' and 'Ascend'.")
|
||||
|
||||
if self._target == "Ascend" and value == 'GPU':
|
||||
raise ValueError("In the Ascend environment, target cannot be set to 'GPU'.")
|
||||
|
||||
self._is_device = (value != 'CPU')
|
||||
self._target = value
|
||||
self._set_base_target(value)
|
||||
|
||||
|
||||
class AdamWeightDecay(Optimizer):
|
||||
|
|
|
|||
|
|
@ -286,17 +286,4 @@ class LazyAdam(Optimizer):
|
|||
"""
|
||||
If the input value is set to "CPU", the parameters will be updated on the host using the Fused
|
||||
optimizer operation."""
|
||||
if not isinstance(value, str):
|
||||
raise TypeError("The value must be str type, but got value type is {}".format(type(value)))
|
||||
|
||||
if value not in ('CPU', 'Ascend', 'GPU'):
|
||||
raise ValueError("The value must be 'CPU', 'Ascend' or 'GPU', but got value {}".format(value))
|
||||
|
||||
if self._target == "CPU" and value in('Ascend', 'GPU'):
|
||||
raise ValueError("In the CPU environment, target cannot be set to 'GPU' and 'Ascend'.")
|
||||
|
||||
if self._target == "Ascend" and value == 'GPU':
|
||||
raise ValueError("In the Ascend environment, target cannot be set to 'GPU'.")
|
||||
|
||||
self._is_device = (value != 'CPU')
|
||||
self._target = value
|
||||
self._set_base_target(value)
|
||||
|
|
|
|||
|
|
@ -248,6 +248,25 @@ class Optimizer(Cell):
|
|||
optimizer operation."""
|
||||
raise NotImplementedError
|
||||
|
||||
def _set_base_target(self, value):
|
||||
"""
|
||||
If the input value is set to "CPU", the parameters will be updated on the host using the Fused
|
||||
optimizer operation."""
|
||||
if not isinstance(value, str):
|
||||
raise TypeError("The value must be str type, but got value type is {}".format(type(value)))
|
||||
|
||||
if value not in ('CPU', 'Ascend', 'GPU'):
|
||||
raise ValueError("The value must be 'CPU', 'Ascend' or 'GPU', but got value {}".format(value))
|
||||
|
||||
if self._target == "CPU" and value in ('Ascend', 'GPU'):
|
||||
raise ValueError("In the CPU environment, target cannot be set to 'GPU' and 'Ascend'.")
|
||||
|
||||
if self._target == "Ascend" and value == 'GPU':
|
||||
raise ValueError("In the Ascend environment, target cannot be set to 'GPU'.")
|
||||
|
||||
self._is_device = (value != 'CPU')
|
||||
self._target = value
|
||||
|
||||
def decay_weight(self, gradients):
|
||||
"""
|
||||
Weight decay.
|
||||
|
|
|
|||
Loading…
Reference in New Issue