rfho/save_and_load.py
def tensors(*tensors, key=None, scope=None, name_contains=None,
                rec_name='', op=tf.identity, fd=None,
                condition=True):
        """
        Little more difficult... attempts to record tensor named name

        :param name_contains: record all tensors which name contains this string. Can be a list.
        :type condition: bool | function
        :param condition: optional condition for triggering the saving of tensors, can have different
                            signatures
        :param tensors: varargs of tensor names
        :param scope: optional for collections
        :param key: to record collections
        :param op: optional operation to apply to each tensor
        :param rec_name: optional name to prepend to all tensors recorded by this
        :param fd: # given to _process_feed_dicts_for_rec
        :return:
        """
        if rec_name: rec_name += '::'  # maybe find a better way

        def _call(*args, **_kwargs):
            if tensors:
                _tensors = [tf.get_default_graph().get_tensor_by_name(tns + ':0') if isinstance(tns, str)
                            else tns for tns in tensors]
            elif key:
                _tensors = tf.get_collection(key, scope=scope)
            elif name_contains:
                _names = rf.flatten_list([[n.name for n in tf.get_default_graph().as_graph_def().node
                                           if nc in n.name] for nc in as_list(name_contains)])
                return Records.tensors(*_names, rec_name=rec_name, op=op, fd=fd, condition=True)(*args, **_kwargs)
            else:
                raise NotImplemented('One between key and names should be given')
            # try with dictionary of form (string (simple name of placeholder), data)
            _rs2 = rf.flatten_list([rec_name + rf.simple_name(tns.name),
                                    op(tns),
                                    Records._process_feed_dicts_for_rec(fd, *args, **_kwargs),
                                    condition]
                                   for tns in _tensors)
            return _rs2

        return _call

        Little more difficult... attempts to record tensor named name

        :param name_contains: record all tensors which name contains this string. Can be a list.
        :type condition: bool | function
        :param condition: optional condition for triggering the saving of tensors, can have different
                            signatures
        :param tensors: varargs of tensor names
        :param scope: optional for collections
        :param key: to record collections
        :param op: optional operation to apply to each tensor
        :param rec_name: optional name to prepend to all tensors recorded by this
        :param fd: # given to _process_feed_dicts_for_rec
        :return:
        
Little more difficult... attempts to record tensor named name
Little more difficult ... attempts to record tensor named name
def tensors(*tensors, key=None, scope=None, name_contains=None,
                rec_name='', op=tf.identity, fd=None,
                condition=True):
        if rec_name: rec_name += '::'  
        def _call(*args, **_kwargs):
            if tensors:
                _tensors = [tf.get_default_graph().get_tensor_by_name(tns + ':0') if isinstance(tns, str)
                            else tns for tns in tensors]
            elif key:
                _tensors = tf.get_collection(key, scope=scope)
            elif name_contains:
                _names = rf.flatten_list([[n.name for n in tf.get_default_graph().as_graph_def().node
                                           if nc in n.name] for nc in as_list(name_contains)])
                return Records.tensors(*_names, rec_name=rec_name, op=op, fd=fd, condition=True)(*args, **_kwargs)
            else:
                raise NotImplemented('One between key and names should be given')
            _rs2 = rf.flatten_list([rec_name + rf.simple_name(tns.name),
                                    op(tns),
                                    Records._process_feed_dicts_for_rec(fd, *args, **_kwargs),
                                    condition]
                                   for tns in _tensors)
            return _rs2
        return _call
def tensors ( * tensors , key = None , scope = None , name_contains = None , rec_name = '' , op = tf . identity , fd = None , condition = True ) : if rec_name : rec_name += '::' def _call ( * args , ** _kwargs ) : if tensors : _tensors = [ tf . get_default_graph ( ) . get_tensor_by_name ( tns + ':0' ) if isinstance ( tns , str ) else tns for tns in tensors ] elif key : _tensors = tf . get_collection ( key , scope = scope ) elif name_contains : _names = rf . flatten_list ( [ [ n . name for n in tf . get_default_graph ( ) . as_graph_def ( ) . node if nc in n . name ] for nc in as_list ( name_contains ) ] ) return Records . tensors ( * _names , rec_name = rec_name , op = op , fd = fd , condition = True ) ( * args , ** _kwargs ) else : raise NotImplemented ( 'One between key and names should be given' ) _rs2 = rf . flatten_list ( [ rec_name + rf . simple_name ( tns . name ) , op ( tns ) , Records . _process_feed_dicts_for_rec ( fd , * args , ** _kwargs ) , condition ] for tns in _tensors ) return _rs2 return _call
Little more difficult... attempts to record tensor named name
Little more difficult ... attempts to record tensor named name
"""
        Little more difficult... attempts to record tensor named name

        :param name_contains: record all tensors which name contains this string. Can be a list.
        :type condition: bool | function
        :param condition: optional condition for triggering the saving of tensors, can have different
                            signatures
        :param tensors: varargs of tensor names
        :param scope: optional for collections
        :param key: to record collections
        :param op: optional operation to apply to each tensor
        :param rec_name: optional name to prepend to all tensors recorded by this
        :param fd: # given to _process_feed_dicts_for_rec
        :return:
        """ # maybe find a better way # try with dictionary of form (string (simple name of placeholder), data)
None
key
to record collections
to record collections
scope
optional for collections
optional for collections
name_contains
record all tensors which name contains this string. Can be a list.
record all tensors which name contains this string . Can be a list .
rec_name
optional name to prepend to all tensors recorded by this
optional name to prepend to all tensors recorded by this
op
optional operation to apply to each tensor
optional operation to apply to each tensor
fd
given to _process_feed_dicts_for_rec
given to _process_feed_dicts_for_rec
condition
optional condition for triggering the saving of tensors, can have different
signatures
optional condition for triggering the saving of tensors can have different signatures
tensors
varargs of tensor names
varargs of tensor names