rfho/save_and_load.py
def save(self, step=None, session=None, append_string="", do_print=None, collect_data=None,
             processed_items=None, _res=None):
        """
        Builds and save a dictionary with the keys and values specified at construction time or by method
        `add_items`

        :param processed_items: optional, processed item list (returned by add_items)
                                if None uses internally stored items
        :param session: Optional tensorflow session, otherwise uses default session
        :param step: optional step, if None (default) uses internal step
                        (int preferred, otherwise does not work well with `pack_save_dictionaries`).
        :param append_string: (optional str) string to append at the file name to `str(step)`
        :param do_print: (default as object field)
        :param collect_data: (default as object field)
        :param _res: used internally by context managers

        :return: the dictionary
        """
        from tensorflow import get_default_session
        if step is None:
            self._step += 1
            step = self._step
        if not processed_items: processed_items = self._processed_items

        if do_print is None: do_print = self.do_print
        if collect_data is None: collect_data = self.collect_data

        if session:
            ss = session
        else:
            ss = get_default_session()
        if ss is None and do_print: print('WARNING, No tensorflow session available')

        if self.timer: self.timer.stop()

        def _maybe_call(_method):
            if not callable(_method): return _method
            if len(signature(_method).parameters) == 0:
                return _method()
            elif len(signature(_method).parameters) == 1:
                return _method(step)
            else:  # complete signature?
                return _method(step, _res)

        save_dict = OrderedDict([(pt[0], _maybe_call(pt[1]) if callable(pt[1])
                                else ss.run(pt[1], feed_dict=_maybe_call(pt[2]),
                                            options=pt[4], run_metadata=pt[5])
                                  if _maybe_call(pt[2 if callable(pt[1]) else 3]) else Saver.SKIP)
                                for pt in processed_items]
                                )

        if self.timer: save_dict['Elapsed time (%s)' % self.timer.unit] = self.timer.elapsed_time()

        if do_print:
            if tabulate:
                print(tabulate(save_dict.items(), headers=('Step %s' % step, 'Values'), floatfmt='.5f'))
            else:
                print('SAVE DICT:')
                for key, v in save_dict.items():
                    print(key, v, sep=': ')
                print()
        if collect_data:
            self.save_obj(save_dict, str(step) + append_string)

        if self.timer: self.timer.start()

        return save_dict

        Builds and save a dictionary with the keys and values specified at construction time or by method
        `add_items`

        :param processed_items: optional, processed item list (returned by add_items)
                                if None uses internally stored items
        :param session: Optional tensorflow session, otherwise uses default session
        :param step: optional step, if None (default) uses internal step
                        (int preferred, otherwise does not work well with `pack_save_dictionaries`).
        :param append_string: (optional str) string to append at the file name to `str(step)`
        :param do_print: (default as object field)
        :param collect_data: (default as object field)
        :param _res: used internally by context managers

        :return: the dictionary
        
Builds and save a dictionary with the keys and values specified at construction time or by method
`add_items`
Builds and save a dictionary with the keys and values specified at construction time or by method ` add_items `
def save(self, step=None, session=None, append_string="", do_print=None, collect_data=None,
             processed_items=None, _res=None):
        from tensorflow import get_default_session
        if step is None:
            self._step += 1
            step = self._step
        if not processed_items: processed_items = self._processed_items
        if do_print is None: do_print = self.do_print
        if collect_data is None: collect_data = self.collect_data
        if session:
            ss = session
        else:
            ss = get_default_session()
        if ss is None and do_print: print('WARNING, No tensorflow session available')
        if self.timer: self.timer.stop()
        def _maybe_call(_method):
            if not callable(_method): return _method
            if len(signature(_method).parameters) == 0:
                return _method()
            elif len(signature(_method).parameters) == 1:
                return _method(step)
            else:  
                return _method(step, _res)
        save_dict = OrderedDict([(pt[0], _maybe_call(pt[1]) if callable(pt[1])
                                else ss.run(pt[1], feed_dict=_maybe_call(pt[2]),
                                            options=pt[4], run_metadata=pt[5])
                                  if _maybe_call(pt[2 if callable(pt[1]) else 3]) else Saver.SKIP)
                                for pt in processed_items]
                                )
        if self.timer: save_dict['Elapsed time (%s)' % self.timer.unit] = self.timer.elapsed_time()
        if do_print:
            if tabulate:
                print(tabulate(save_dict.items(), headers=('Step %s' % step, 'Values'), floatfmt='.5f'))
            else:
                print('SAVE DICT:')
                for key, v in save_dict.items():
                    print(key, v, sep=': ')
                print()
        if collect_data:
            self.save_obj(save_dict, str(step) + append_string)
        if self.timer: self.timer.start()
        return save_dict
def save ( self , step = None , session = None , append_string = "" , do_print = None , collect_data = None , processed_items = None , _res = None ) : from tensorflow import get_default_session if step is None : self . _step += 1 step = self . _step if not processed_items : processed_items = self . _processed_items if do_print is None : do_print = self . do_print if collect_data is None : collect_data = self . collect_data if session : ss = session else : ss = get_default_session ( ) if ss is None and do_print : print ( 'WARNING, No tensorflow session available' ) if self . timer : self . timer . stop ( ) def _maybe_call ( _method ) : if not callable ( _method ) : return _method if len ( signature ( _method ) . parameters ) == 0 : return _method ( ) elif len ( signature ( _method ) . parameters ) == 1 : return _method ( step ) else : return _method ( step , _res ) save_dict = OrderedDict ( [ ( pt [ 0 ] , _maybe_call ( pt [ 1 ] ) if callable ( pt [ 1 ] ) else ss . run ( pt [ 1 ] , feed_dict = _maybe_call ( pt [ 2 ] ) , options = pt [ 4 ] , run_metadata = pt [ 5 ] ) if _maybe_call ( pt [ 2 if callable ( pt [ 1 ] ) else 3 ] ) else Saver . SKIP ) for pt in processed_items ] ) if self . timer : save_dict [ 'Elapsed time (%s)' % self . timer . unit ] = self . timer . elapsed_time ( ) if do_print : if tabulate : print ( tabulate ( save_dict . items ( ) , headers = ( 'Step %s' % step , 'Values' ) , floatfmt = '.5f' ) ) else : print ( 'SAVE DICT:' ) for key , v in save_dict . items ( ) : print ( key , v , sep = ': ' ) print ( ) if collect_data : self . save_obj ( save_dict , str ( step ) + append_string ) if self . timer : self . timer . start ( ) return save_dict
Builds and save a dictionary with the keys and values specified at construction time or by method
`add_items`
Builds and save a dictionary with the keys and values specified at construction time or by method ` add_items `
"""
        Builds and save a dictionary with the keys and values specified at construction time or by method
        `add_items`

        :param processed_items: optional, processed item list (returned by add_items)
                                if None uses internally stored items
        :param session: Optional tensorflow session, otherwise uses default session
        :param step: optional step, if None (default) uses internal step
                        (int preferred, otherwise does not work well with `pack_save_dictionaries`).
        :param append_string: (optional str) string to append at the file name to `str(step)`
        :param do_print: (default as object field)
        :param collect_data: (default as object field)
        :param _res: used internally by context managers

        :return: the dictionary
        """ # complete signature?
None
self
step
optional step, if None (default) uses internal step
(int preferred, otherwise does not work well with `pack_save_dictionaries`).
optional step if None ( default ) uses internal step ( int preferred otherwise does not work well with ` pack_save_dictionaries ` ) .
session
Optional tensorflow session, otherwise uses default session
Optional tensorflow session otherwise uses default session
append_string
(optional str) string to append at the file name to `str(step)`
( optional str ) string to append at the file name to ` str ( step ) `
do_print
(default as object field)
( default as object field )
collect_data
(default as object field)
( default as object field )
processed_items
optional, processed item list (returned by add_items)
if None uses internally stored items
optional processed item list ( returned by add_items ) if None uses internally stored items
_res
used internally by context managers
used internally by context managers