This means the newly created layers will share variables with the original
ones.
if tfe.in_eager_mode():
raise ValueError("copy() is not supported in eager mode")
if self in replacements:
return replacements[self]
copied_inputs = [
layer.copy(replacements, variables_graph, shared)
for layer in self.in_layers
]
if shared:
copy = self.shared(copied_inputs)
else:
copy = self.clone(copied_inputs)
if variables_graph is not None:
if shared:
raise ValueError("Cannot specify variables_graph when shared==True")
variables = variables_graph.get_layer_variables(self)
if len(variables) > 0:
with variables_graph._get_tf("Graph").as_default():
values = variables_graph.session.run(variables)
copy.set_variable_initial_values(values)
return copy
def _as_graph_element(self):