import tensorflow as tf

            return True
        else:
            return self._optimistic_restore_model(sess)

    def _optimistic_restore_model(self, sess):
        """
        restore weights of same names with model.
        :param sess:
        :return:
        """
        if self.restore_ckpt_file is None:
            logger.warn(Color.yellow('No ckpt file for restore vars, ckpt file is None'))
            return False
        reader = tf.train.NewCheckpointReader(self.restore_ckpt_file)
        saved_shapes = reader.get_variable_to_shape_map()
        if self._var_list is None:
            restore_key2vars = {var.name.split(':')[0]: var for var in tf.global_variables()}
        elif isinstance(self._var_list, list):
            restore_key2vars = {var.name.split(':')[0]: var for var in self._var_list}
        elif isinstance(self._var_list, dict):
            restore_key2vars = self._var_list
        else:
            raise RuntimeError('type error {}'.format(self._var_list))
        assert len(restore_key2vars) > 0
        restore_key2vars = sorted([(k, v) for k, v in restore_key2vars.items() if k in saved_shapes])
        msg = []
