// The case in which layer_dict represents an "atomic" layer
layer_dict.pop("name")
if "parameters" in layer_dict:
params = layer_dict.get("parameters")
layer_dict.pop("parameters")
hasParams = True
for k, v in layer_dict.items():
// For now, this can only happen for regularizers and constraints
if isinstance(v, dict):
vname = v.get("name")
v.pop("name")
if vname in [x for x, y in inspect.getmembers(constraints, predicate=inspect.isclass)]:
layer_dict[k] = constraints.get(vname, v)
if vname in [x for x, y in inspect.getmembers(regularizers, predicate=inspect.isclass)]:
layer_dict[k] = regularizers.get(vname, v)
base_layer = get_layer(name, layer_dict)
if hasParams:
shaped_params = []
for param in params:
data = np.asarray(param.get("data"))
shape = tuple(param.get("shape"))
shaped_params.append(data.reshape(shape))
base_layer.set_weights(shaped_params)
return base_layer
After Change
def container_from_config(original_layer_dict):
layer_dict = copy.deepcopy(original_layer_dict)
name = layer_dict.get("name")
if name == "Merge":
mode = layer_dict.get("mode")