private void _init_from_proto(VariableDef variable_def, string import_scope = "") { var g = ops.get_default_graph(); _variable = g.as_graph_element( ops.prepend_name_scope(variable_def.VariableName, import_scope: import_scope)) as Tensor; _initializer_op = g.as_graph_element( ops.prepend_name_scope(variable_def.InitializerName, import_scope: import_scope)) as Operation; // Tests whether initial_value_name exists first for backwards compatibility. if (!string.IsNullOrEmpty(variable_def.InitialValueName)) { _initial_value = g.as_graph_element( ops.prepend_name_scope(variable_def.InitialValueName, import_scope: import_scope)) as Tensor; } else { _initial_value = null; } _trainable = variable_def.Trainable; _snapshot = g.as_graph_element( ops.prepend_name_scope(variable_def.SnapshotName, import_scope: import_scope)) as Tensor; if (variable_def.SaveSliceInfoDef != null) { throw new NotImplementedException("save_slice_info_def"); } else { ;// _save_slice_info = null; } //_caching_device = null; //_constraint = null; }
public VariableDef to_proto(string export_scope) { if (string.IsNullOrEmpty(export_scope) || _variable.name.StartsWith(export_scope)) { var var_def = new VariableDef(); var_def.VariableName = ops.strip_name_scope(_variable.name, export_scope); if (_initial_value != null) { var_def.InitialValueName = ops.strip_name_scope(_initial_value.name, export_scope); } var_def.Trainable = _trainable; var_def.InitializerName = ops.strip_name_scope(initializer.name, export_scope); var_def.SnapshotName = ops.strip_name_scope(_snapshot.name, export_scope); if (_save_slice_info) { throw new NotImplementedException("to_proto _save_slice_info"); } return(var_def); } throw new NotImplementedException("to_proto RefVariable"); }
public ResourceVariable(object initial_value = null, bool trainable = true, List <string> collections = null, bool validate_shape = true, string caching_device = "", string name = null, VariableDef variable_def = null, TF_DataType dtype = TF_DataType.DtInvalid, string import_scope = "", TensorShape shape = null) : base(initial_value, trainable, collections, validate_shape, caching_device, name, dtype) { if (variable_def != null) { if (initial_value != null) { throw new ValueError("variable_def and initial_value are mutually exclusive."); } _init_from_proto(variable_def, import_scope: import_scope); } else { _init_from_args(initial_value: initial_value, trainable: trainable, collections: collections, caching_device: caching_device, name: name, dtype: dtype, shape: shape); } }
public T from_proto <T>(VariableDef variable_def, string import_scope) { throw new NotImplementedException(); }