MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / from_config

Method from_config

tensorflow/python/keras/layers/core.py:859–887  ·  view source on GitHub ↗
(cls, config, custom_objects=None)

Source from the content-addressed store, hash-verified

857
858 @classmethod
859 def from_config(cls, config, custom_objects=None):
860 config = config.copy()
861 function = cls._parse_function_from_config(
862 config, custom_objects, 'function', 'module', 'function_type')
863
864 output_shape = cls._parse_function_from_config(
865 config, custom_objects, 'output_shape', 'output_shape_module',
866 'output_shape_type')
867 if 'mask' in config:
868 mask = cls._parse_function_from_config(
869 config, custom_objects, 'mask', 'mask_module', 'mask_type')
870 else:
871 mask = None
872
873 config['function'] = function
874 config['output_shape'] = output_shape
875 config['mask'] = mask
876
877 # If arguments were numpy array, they have been saved as
878 # list. We need to recover the ndarray
879 if 'arguments' in config:
880 for key in config['arguments']:
881 if isinstance(config['arguments'][key], dict):
882 arg_dict = config['arguments'][key]
883 if 'type' in arg_dict and arg_dict['type'] == 'ndarray':
884 # Overwrite the argument with its numpy translation
885 config['arguments'][key] = np.array(arg_dict['value'])
886
887 return cls(**config)
888
889 @classmethod
890 def _parse_function_from_config(

Calls 2

copyMethod · 0.45