r'''Build a SavedModel from variables in checkpoint. Args: export_dir_base: A string containing a directory to write the exported graph and checkpoints. checkpoint_path: A path to a checkpoint. signature_defs_and_main_op_fn: Function returns signa
(
export_dir_base,
checkpoint_path,
signature_defs_and_main_op_fn,
assets_extra=None,
as_text=False,
clear_devices=True,
strip_default_attrs=True,
modes=None,
**kwargs)
| 657 | ##################### Estimator ########################## |
| 658 | |
| 659 | def export_all( |
| 660 | export_dir_base, |
| 661 | checkpoint_path, |
| 662 | signature_defs_and_main_op_fn, |
| 663 | assets_extra=None, |
| 664 | as_text=False, |
| 665 | clear_devices=True, |
| 666 | strip_default_attrs=True, |
| 667 | modes=None, |
| 668 | **kwargs): |
| 669 | r'''Build a SavedModel from variables in checkpoint. |
| 670 | |
| 671 | Args: |
| 672 | export_dir_base: A string containing a directory to write the exported |
| 673 | graph and checkpoints. |
| 674 | checkpoint_path: A path to a checkpoint. |
| 675 | signature_defs_and_main_op_fn: Function returns signature defs and main_op. |
| 676 | assets_extra: A dict specifying how to populate the assets.extra directory |
| 677 | within the exported SavedModel. Each key should give the destination |
| 678 | path (including the filename) relative to the assets.extra directory. |
| 679 | The corresponding value gives the full path of the source file to be |
| 680 | copied. For example, the simple case of copying a single file without |
| 681 | renaming it is specified as |
| 682 | `{'my_asset_file.txt': '/path/to/my_asset_file.txt'}`. |
| 683 | as_text: Whether or not to write the SavedModel proto in text format. |
| 684 | clear_devices: Whether or not to clear the device field. |
| 685 | strip_default_attrs: Whether or not to remove default-valued attributes |
| 686 | from the NodeDefs. |
| 687 | modes: List contains PREDICT, TRAIN or TEST. |
| 688 | |
| 689 | Returns: |
| 690 | Export directory if it's chief. |
| 691 | ''' |
| 692 | if HvdContext.get().rank != 0: |
| 693 | return None |
| 694 | |
| 695 | export_dir = get_timestamped_export_dir(export_dir_base) |
| 696 | with ops.Graph().as_default(): |
| 697 | with HvdContext.scope(): |
| 698 | # Build graph. |
| 699 | signature_def_map = signature_defs_and_main_op_fn() |
| 700 | main_op = None |
| 701 | if isinstance(signature_def_map, (tuple, list)): |
| 702 | if len(signature_def_map) > 1: |
| 703 | main_op = signature_def_map[1] |
| 704 | signature_def_map = signature_def_map[0] |
| 705 | if not main_op: |
| 706 | main_op = _monitored_session.Scaffold.default_local_init_op() |
| 707 | if modes is None: |
| 708 | modes = [ModeKeys.PREDICT, ModeKeys.TRAIN, ModeKeys.EVAL] |
| 709 | modes = [ |
| 710 | m for m in modes |
| 711 | if SIGNATURE_KEY_MAP[m] in signature_def_map] |
| 712 | signature_def_map = { |
| 713 | k: signature_def_map[k] for k in signature_def_map |
| 714 | if k in [SIGNATURE_KEY_MAP[m] for m in modes]} |
| 715 | signature_tags = [EXPORT_TAG_MAP[m][0] for m in modes] |
| 716 |
no test coverage detected