def save_weights_as_checkpoint(self, filename, mapping=None, dtype=None):
    '根据mapping将权重保存为checkpoint格式\n        '
    mapping = (mapping or self.variable_mapping())
    mapping = {self.prefixed(k): v for (k, v) in mapping.items()}
    mapping = {k: v for (k, v) in mapping.items() if (k in self.layers)}
    with tf.Graph().as_default():
        (all_variables, all_values) = ([], [])
        for (layer, variables) in mapping.items():
            layer = self.layers[layer]
            values = K.batch_get_value(layer.trainable_weights)
            for (name, value) in zip(variables, values):
                (variable, value) = self.create_variable(name, value, dtype)
                all_variables.append(variable)
                all_values.append(value)
        with tf.Session() as sess:
            K.batch_set_value(zip(all_variables, all_values))
            saver = tf.train.Saver()
            saver.save(sess, filename)
根据mapping将权重保存为checkpoint格式
def save_weights_as_checkpoint(self, filename, mapping=None, dtype=None):
    '\n        '
    mapping = (mapping or self.variable_mapping())
    mapping = {self.prefixed(k): v for (k, v) in mapping.items()}
    mapping = {k: v for (k, v) in mapping.items() if (k in self.layers)}
    with tf.Graph().as_default():
        (all_variables, all_values) = ([], [])
        for (layer, variables) in mapping.items():
            layer = self.layers[layer]
            values = K.batch_get_value(layer.trainable_weights)
            for (name, value) in zip(variables, values):
                (variable, value) = self.create_variable(name, value, dtype)
                all_variables.append(variable)
                all_values.append(value)
        with tf.Session() as sess:
            K.batch_set_value(zip(all_variables, all_values))
            saver = tf.train.Saver()
            saver.save(sess, filename)