Browse Source

Add data type check

tags/v1.0.0
lilei 5 years ago
parent
commit
509e497fec
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      mindspore/common/initializer.py

+ 4
- 0
mindspore/common/initializer.py View File

@@ -457,6 +457,10 @@ def initializer(init, shape=None, dtype=mstype.float32):
elif isinstance(shape, numbers.Number):
shape = (shape,)

for value in shape if shape is not None else ():
if not isinstance(value, int) or value <= 0:
raise ValueError(f"shape is invalid, shape value must be positive integer, shape:{shape}")

if isinstance(init, Initializer):
init.shape = init.shape if init.shape is not None else shape
init.dtype = init.dtype if init.dtype is not None else dtype


Loading…
Cancel
Save