├── .gitattributes ├── .github └── workflows │ ├── bot-pr-new.yaml │ ├── ci.yaml │ └── stale.yaml ├── .gitignore ├── AUTHORS ├── CODEOWNERS ├── CONTRIBUTING.md ├── LICENSE ├── MANIFEST.in ├── README.md ├── setup.py ├── site └── en │ ├── README.md │ ├── about │ ├── _menu_toc.yaml │ └── bib.md │ ├── community │ ├── _toc.yaml │ ├── contribute │ │ ├── code.md │ │ ├── code_style.md │ │ ├── community.md │ │ ├── docs.md │ │ ├── docs_ref.md │ │ ├── docs_style.md │ │ ├── index.md │ │ ├── rfc_process.md │ │ ├── sigs.md │ │ └── tests.md │ ├── mailing-lists.md │ └── sig_playbook.md │ ├── guide │ ├── _index.yaml │ ├── _toc.yaml │ ├── advanced_autodiff.ipynb │ ├── autodiff.ipynb │ ├── basic_training_loops.ipynb │ ├── basics.ipynb │ ├── checkpoint.ipynb │ ├── core │ │ ├── distribution.ipynb │ │ ├── index.md │ │ ├── logistic_regression_core.ipynb │ │ ├── matrix_core.ipynb │ │ ├── mlp_core.ipynb │ │ ├── optimizers_core.ipynb │ │ └── quickstart_core.ipynb │ ├── create_op.md │ ├── data.ipynb │ ├── data_performance.ipynb │ ├── data_performance_analysis.md │ ├── distributed_training.ipynb │ ├── dtensor_overview.ipynb │ ├── effective_tf2.ipynb │ ├── estimator.ipynb │ ├── extension_type.ipynb │ ├── function.ipynb │ ├── gpu.ipynb │ ├── gpu_performance_analysis.md │ ├── graph_optimization.ipynb │ ├── images │ │ ├── data_performance │ │ │ ├── cached_dataset.svg │ │ │ ├── naive.svg │ │ │ ├── parallel_interleave.svg │ │ │ ├── parallel_map.svg │ │ │ ├── prefetched.svg │ │ │ ├── scalar_map.svg │ │ │ ├── sequential_interleave.svg │ │ │ ├── sequential_map.svg │ │ │ └── vectorized_map.svg │ │ ├── data_performance_analysis │ │ │ ├── async_long_name.png │ │ │ ├── example_1_cropped.png │ │ │ ├── example_2_cropped.png │ │ │ ├── get_next_fast.png │ │ │ ├── get_next_slow.png │ │ │ ├── map_long_name.png │ │ │ ├── prefetch.png │ │ │ └── trace_viewer.png │ │ ├── gpu_perf_analysis │ │ │ ├── gpu_kernels.png │ │ │ ├── input_pipeline_analyzer.png │ │ │ ├── opp_placement.png │ │ │ ├── overview_page.png │ │ │ ├── performance_summary.png │ │ │ ├── tensorflow_stats_page.png │ │ │ ├── traceview_excessive_copy.png │ │ │ ├── traceview_gpu_idle.png │ │ │ ├── traceview_host_contention.png │ │ │ ├── traceview_ideal.png │ │ │ ├── traceview_kernel_gaps.png │ │ │ ├── traceview_multi_gpu.png │ │ │ └── traceview_step_gaps.png │ │ ├── graph_optimization │ │ │ ├── meta_optimizer_disabled.png │ │ │ ├── meta_optimizer_enabled.png │ │ │ ├── optimized_graph.png │ │ │ └── user_defined_graph.png │ │ ├── intro_to_graphs │ │ │ └── two-layer-network.png │ │ ├── new_type_promotion │ │ │ ├── type_promotion_lattice.png │ │ │ └── type_promotion_table.png │ │ ├── sparse_tensor.png │ │ ├── tensor │ │ │ ├── 3-axis_block.png │ │ │ ├── 3-axis_front.png │ │ │ ├── 3-axis_numpy.png │ │ │ ├── 3-axis_stack.png │ │ │ ├── 4-axis_block.png │ │ │ ├── broadcasting.png │ │ │ ├── index1.png │ │ │ ├── index2.png │ │ │ ├── matrix.png │ │ │ ├── ragged.png │ │ │ ├── reshape-bad.png │ │ │ ├── reshape-bad2.png │ │ │ ├── reshape-bad3.png │ │ │ ├── reshape-bad4.png │ │ │ ├── reshape-before.png │ │ │ ├── reshape-good1.png │ │ │ ├── reshape-good2.png │ │ │ ├── scalar.png │ │ │ ├── shape.png │ │ │ ├── shape2.png │ │ │ ├── sparse.png │ │ │ ├── string-split.png │ │ │ ├── strings.png │ │ │ └── vector.png │ │ ├── tensorboard_graph.png │ │ ├── tf_profiler │ │ │ ├── capture_profile.png │ │ │ ├── gpu_kernel_stats.png │ │ │ ├── input_op_stats.png │ │ │ ├── input_pipeline_analyzer.png │ │ │ ├── memory_breakdown_table.png │ │ │ ├── memory_profile_summary.png │ │ │ ├── memory_timeline_graph.png │ │ │ ├── memory_timeline_graph_popup.png │ │ │ ├── overview_page.png │ │ │ ├── pod_viewer.png │ │ │ ├── python_tracer.png │ │ │ ├── tf_data_all_hosts.png │ │ │ ├── tf_data_graph.png │ │ │ ├── tf_data_graph_selector.png │ │ │ ├── tf_data_summary.png │ │ │ ├── tf_stats.png │ │ │ └── trace_viewer.png │ │ └── tf_slicing │ │ │ ├── gather_1.png │ │ │ ├── gather_2.png │ │ │ ├── gather_nd_sparse.png │ │ │ ├── slice_1d_1.png │ │ │ ├── slice_1d_2.png │ │ │ ├── slice_1d_3.png │ │ │ └── slice_2d_1.png │ ├── intro_to_graphs.ipynb │ ├── intro_to_modules.ipynb │ ├── jax2tf.ipynb │ ├── keras.md │ ├── keras │ │ └── README.md │ ├── migrate │ │ ├── _index.yaml │ │ ├── _toc.yaml │ │ ├── canned_estimators.ipynb │ │ ├── checkpoint_saver.ipynb │ │ ├── early_stopping.ipynb │ │ ├── evaluator.ipynb │ │ ├── fault_tolerance.ipynb │ │ ├── images │ │ │ ├── tensorboard_TF1.png │ │ │ └── tensorboard_TF2.png │ │ ├── logging_stop_hook.ipynb │ │ ├── metrics_optimizers.ipynb │ │ ├── migrate_tf2.md │ │ ├── migrating_checkpoints.ipynb │ │ ├── migrating_estimator.ipynb │ │ ├── migrating_feature_columns.ipynb │ │ ├── migration_debugging.ipynb │ │ ├── mirrored_strategy.ipynb │ │ ├── model_mapping.ipynb │ │ ├── multi_worker_cpu_gpu_training.ipynb │ │ ├── saved_model.ipynb │ │ ├── sessionrunhook_callback.ipynb │ │ ├── tensorboard.ipynb │ │ ├── tf1_vs_tf2.ipynb │ │ ├── tflite.ipynb │ │ ├── tpu_embedding.ipynb │ │ ├── tpu_estimator.ipynb │ │ ├── upgrade.ipynb │ │ └── validate_correctness.ipynb │ ├── mixed_precision.ipynb │ ├── profiler.md │ ├── ragged_tensor.ipynb │ ├── random_numbers.ipynb │ ├── saved_model.ipynb │ ├── sparse_tensor.ipynb │ ├── tensor.ipynb │ ├── tensor_slicing.ipynb │ ├── tf_numpy.ipynb │ ├── tf_numpy_type_promotion.ipynb │ ├── tpu.ipynb │ ├── variable.ipynb │ └── versions.md │ ├── hub │ ├── _book.yaml │ ├── _index.yaml │ ├── _redirects.yaml │ ├── build_from_source.md │ ├── caching.md │ ├── common_issues.md │ ├── common_saved_model_apis │ │ ├── images.md │ │ ├── index.md │ │ └── text.md │ ├── common_signatures │ │ ├── images.md │ │ ├── index.md │ │ └── text.md │ ├── community.md │ ├── contribute.md │ ├── hosting.md │ ├── images │ │ ├── action_recognition.gif │ │ ├── bert.png │ │ ├── bert_preprocess.png │ │ ├── bert_preprocess_wide.png │ │ ├── bit_blog.jpg │ │ ├── boundless.png │ │ ├── colab_logo.svg │ │ ├── food.png │ │ ├── gan_faces.gif │ │ ├── github_icon.svg │ │ ├── guide_basics.png │ │ ├── image_classification.png │ │ ├── interpolation.png │ │ ├── library_download_cache.png │ │ ├── object_detection.png │ │ ├── odml.png │ │ ├── similarity.png │ │ ├── spice_blog.png │ │ ├── spice_color.png │ │ ├── stackoverflow_icon.svg │ │ ├── style_transfer.png │ │ ├── super_resolution.png │ │ ├── text_video.gif │ │ └── yamnet.png │ ├── installation.md │ ├── lib_overview.md │ ├── migration_tf2.md │ ├── model_compatibility.md │ ├── model_formats.md │ ├── overview.md │ ├── portability_and_deletion.md │ ├── publish.md │ ├── reusable_saved_models.md │ ├── tf1_hub_module.md │ ├── tf2_saved_model.md │ └── tutorials │ │ ├── _index.yaml │ │ ├── _toc.yaml │ │ ├── action_recognition_with_tf_hub.ipynb │ │ ├── bangla_article_classifier.ipynb │ │ ├── bert_experts.ipynb │ │ ├── bigbigan_with_tf_hub.ipynb │ │ ├── biggan_generation_with_tf_hub.ipynb │ │ ├── bird_vocalization_classifier.ipynb │ │ ├── boundless.ipynb │ │ ├── cord_19_embeddings.ipynb │ │ ├── cord_19_embeddings_keras.ipynb │ │ ├── cropnet_cassava.ipynb │ │ ├── cropnet_on_device.ipynb │ │ ├── cross_lingual_similarity_with_tf_hub_multilingual_universal_encoder.ipynb │ │ ├── hrnet_semantic_segmentation.ipynb │ │ ├── image_classification.ipynb │ │ ├── image_enhancing.ipynb │ │ ├── image_feature_vector.ipynb │ │ ├── movenet.ipynb │ │ ├── movinet.ipynb │ │ ├── object_detection.ipynb │ │ ├── retrieval_with_tf_hub_universal_encoder_qa.ipynb │ │ ├── s3gan_generation_with_tf_hub.ipynb │ │ ├── semantic_approximate_nearest_neighbors.ipynb │ │ ├── semantic_similarity_with_tf_hub_universal_encoder.ipynb │ │ ├── semantic_similarity_with_tf_hub_universal_encoder_lite.ipynb │ │ ├── senteval_for_universal_sentence_encoder_cmlm.ipynb │ │ ├── spice.ipynb │ │ ├── text_classification_with_tf_hub_on_kaggle.ipynb │ │ ├── text_cookbook.md │ │ ├── text_to_video_retrieval_with_s3d_milnce.ipynb │ │ ├── tf2_arbitrary_image_stylization.ipynb │ │ ├── tf2_image_retraining.ipynb │ │ ├── tf2_object_detection.ipynb │ │ ├── tf2_semantic_approximate_nearest_neighbors.ipynb │ │ ├── tf2_text_classification.ipynb │ │ ├── tf_hub_delf_module.ipynb │ │ ├── tf_hub_film_example.ipynb │ │ ├── tf_hub_generative_image_module.ipynb │ │ ├── tweening_conv3d.ipynb │ │ ├── wav2vec2_saved_model_finetuning.ipynb │ │ ├── wiki40b_lm.ipynb │ │ └── yamnet.ipynb │ ├── install │ ├── _index.yaml │ ├── _toc.yaml │ ├── docker.md │ ├── errors.md │ ├── gpu_plugins.md │ ├── lang_c.ipynb │ ├── lang_java_legacy.md │ ├── pip.md │ ├── source.md │ └── source_windows.md │ ├── r1 │ ├── README.md │ ├── guide │ │ ├── README.md │ │ ├── autograph.ipynb │ │ ├── checkpoints.md │ │ ├── custom_estimators.md │ │ ├── datasets.md │ │ ├── datasets_for_estimators.md │ │ ├── debugger.md │ │ ├── distribute_strategy.ipynb │ │ ├── eager.ipynb │ │ ├── embedding.md │ │ ├── estimators.md │ │ ├── extend │ │ │ ├── architecture.md │ │ │ ├── bindings.md │ │ │ ├── cc.md │ │ │ ├── filesystem.md │ │ │ ├── formats.md │ │ │ ├── model_files.md │ │ │ └── op.md │ │ ├── feature_columns.md │ │ ├── graph_viz.md │ │ ├── graphs.md │ │ ├── keras.ipynb │ │ ├── low_level_intro.md │ │ ├── performance │ │ │ ├── benchmarks.md │ │ │ ├── datasets.md │ │ │ └── overview.md │ │ ├── premade_estimators.md │ │ ├── ragged_tensors.ipynb │ │ ├── saved_model.md │ │ ├── tensorboard_histograms.md │ │ ├── tensors.md │ │ ├── using_gpu.md │ │ ├── using_tpu.md │ │ ├── variables.md │ │ └── version_compat.md │ └── tutorials │ │ ├── README.md │ │ ├── _index.ipynb │ │ ├── distribute │ │ ├── keras.ipynb │ │ ├── tpu_custom_training.ipynb │ │ └── training_loops.ipynb │ │ ├── eager │ │ ├── README.md │ │ ├── automatic_differentiation.ipynb │ │ ├── custom_layers.ipynb │ │ ├── custom_training.ipynb │ │ ├── custom_training_walkthrough.ipynb │ │ └── eager_basics.ipynb │ │ ├── images │ │ ├── deep_cnn.md │ │ ├── hub_with_keras.ipynb │ │ ├── image_recognition.md │ │ ├── images │ │ │ ├── before_fine_tuning.png │ │ │ └── fine_tuning.png │ │ └── transfer_learning.ipynb │ │ ├── keras │ │ ├── README.md │ │ ├── basic_classification.ipynb │ │ ├── basic_regression.ipynb │ │ ├── basic_text_classification.ipynb │ │ ├── overfit_and_underfit.ipynb │ │ └── save_and_restore_models.ipynb │ │ ├── load_data │ │ ├── images.ipynb │ │ └── tf_records.ipynb │ │ ├── non-ml │ │ ├── mandelbrot.ipynb │ │ └── pdes.ipynb │ │ ├── representation │ │ ├── kernel_methods.md │ │ ├── linear.md │ │ ├── unicode.ipynb │ │ └── word2vec.md │ │ └── sequences │ │ ├── audio_recognition.md │ │ ├── images │ │ ├── text_generation_sampling.png │ │ └── text_generation_training.png │ │ ├── recurrent.md │ │ ├── recurrent_quickdraw.md │ │ └── text_generation.ipynb │ └── tutorials │ ├── _index.yaml │ ├── _toc.yaml │ ├── audio │ ├── music_generation.ipynb │ ├── simple_audio.ipynb │ └── transfer_learning_audio.ipynb │ ├── customization │ ├── basics.ipynb │ ├── custom_layers.ipynb │ ├── custom_training_walkthrough.ipynb │ └── images │ │ ├── full_network_penguin.png │ │ └── penguins_ds_species.png │ ├── distribute │ ├── custom_training.ipynb │ ├── dtensor_keras_tutorial.ipynb │ ├── dtensor_ml_tutorial.ipynb │ ├── images │ │ └── tensorboard_distributed_training_with_keras.png │ ├── input.ipynb │ ├── keras.ipynb │ ├── multi_worker_with_ctl.ipynb │ ├── multi_worker_with_estimator.ipynb │ ├── multi_worker_with_keras.ipynb │ ├── parameter_server_training.ipynb │ └── save_and_load.ipynb │ ├── estimator │ ├── keras_model_to_estimator.ipynb │ ├── linear.ipynb │ └── premade.ipynb │ ├── generative │ ├── adversarial_fgsm.ipynb │ ├── autoencoder.ipynb │ ├── cvae.ipynb │ ├── cyclegan.ipynb │ ├── data_compression.ipynb │ ├── dcgan.ipynb │ ├── deepdream.ipynb │ ├── images │ │ ├── Green_Sea_Turtle_grazing_seagrass.jpg │ │ ├── adversarial_example.png │ │ ├── cvae_latent_space.jpg │ │ ├── cycle_loss.png │ │ ├── cyclegan_model.png │ │ ├── dis.png │ │ ├── dogception.png │ │ ├── gan1.png │ │ ├── gan2.png │ │ ├── gan_diagram.png │ │ ├── gen.png │ │ ├── horse2zebra_1.png │ │ ├── horse2zebra_2.png │ │ ├── image_denoise_fmnist_results.png │ │ ├── intro_autoencoder_result.png │ │ ├── kadinsky-turtle.png │ │ ├── kadinsky.jpg │ │ └── stylized-image.png │ ├── pix2pix.ipynb │ └── style_transfer.ipynb │ ├── images │ ├── classification.ipynb │ ├── cnn.ipynb │ ├── data_augmentation.ipynb │ ├── images │ │ ├── before_fine_tuning.png │ │ ├── fine_tuning.png │ │ └── tensorboard_transfer_learning_with_hub.png │ ├── index.md │ ├── segmentation.ipynb │ ├── transfer_learning.ipynb │ └── transfer_learning_with_hub.ipynb │ ├── interpretability │ ├── images │ │ └── IG_fireboat.png │ └── integrated_gradients.ipynb │ ├── keras │ ├── classification.ipynb │ ├── keras_tuner.ipynb │ ├── overfit_and_underfit.ipynb │ ├── regression.ipynb │ ├── save_and_load.ipynb │ ├── text_classification.ipynb │ └── text_classification_with_hub.ipynb │ ├── load_data │ ├── csv.ipynb │ ├── images.ipynb │ ├── images │ │ └── csv │ │ │ ├── Titanic.jpg │ │ │ ├── fonts.jpg │ │ │ └── traffic.jpg │ ├── numpy.ipynb │ ├── pandas_dataframe.ipynb │ ├── text.ipynb │ ├── tfrecord.ipynb │ └── video.ipynb │ ├── optimization │ └── compression.ipynb │ ├── quickstart │ ├── advanced.ipynb │ ├── beginner.ipynb │ └── images │ │ └── beginner │ │ └── run_cell_icon.png │ ├── reinforcement_learning │ ├── actor_critic.ipynb │ └── images │ │ └── cartpole-v0.gif │ ├── structured_data │ ├── feature_columns.ipynb │ ├── images │ │ ├── baseline.png │ │ ├── conv_window.png │ │ ├── last_window.png │ │ ├── lstm_1_window.png │ │ ├── lstm_many_window.png │ │ ├── multistep_autoregressive.png │ │ ├── multistep_conv.png │ │ ├── multistep_dense.png │ │ ├── multistep_last.png │ │ ├── multistep_lstm.png │ │ ├── multistep_repeat.png │ │ ├── narrow_window.png │ │ ├── raw_window.png │ │ ├── raw_window_1h.png │ │ ├── raw_window_24h.png │ │ ├── residual.png │ │ ├── split_window.png │ │ ├── wide_conv_window.png │ │ └── wide_window.png │ ├── imbalanced_data.ipynb │ ├── preprocessing_layers.ipynb │ └── time_series.ipynb │ ├── tensorflow_text │ └── README.md │ ├── text │ └── index.md │ ├── understanding │ ├── images │ │ └── sngp.png │ └── sngp.ipynb │ └── video │ ├── transfer_learning_with_movinet.ipynb │ └── video_classification.ipynb └── tools ├── linkcheckerrc ├── release_tools ├── push_version_to_github.sh └── update_versions.py ├── spelltest ├── spelltest.sh ├── tmpl │ ├── html.tpl │ └── md.tpl └── wordlist.txt ├── templates ├── build_docs.py ├── notebook.ipynb ├── subsite │ ├── README.md │ └── g3doc │ │ ├── _book.yaml │ │ ├── _index.yaml │ │ ├── api_docs │ │ ├── README.md │ │ └── python │ │ │ ├── _toc.yaml │ │ │ └── index.md │ │ ├── bar_guide.md │ │ ├── examples │ │ ├── baz_example.md │ │ └── index.md │ │ ├── overview.md │ │ └── tutorials │ │ ├── foo_tutorial.md │ │ ├── index.md │ │ └── notebook.ipynb └── tflite_model_page_template.md └── tensorflow_docs ├── __init__.py ├── api_generator ├── __init__.py ├── compat_test │ ├── __init__.py │ └── estimator.py ├── config.py ├── doc_controls.py ├── doc_controls_test.py ├── doc_generator_visitor.py ├── doc_generator_visitor_test.py ├── gen_java │ ├── __init__.py │ ├── run-javadoc-for-tf.sh │ └── templates │ │ ├── class.cs │ │ ├── classes.cs │ │ ├── head_tag.cs │ │ ├── header.cs │ │ ├── left-nav-android.cs │ │ ├── macros.cs │ │ ├── navtree_data.cs │ │ ├── package-descr.cs │ │ ├── package-list.cs │ │ ├── package.cs │ │ ├── packages.cs │ │ ├── screen.css │ │ └── yaml_navtree.cs ├── generate_lib.py ├── generate_lib_test.py ├── get_source.py ├── obj_type.py ├── parser.py ├── parser_test.py ├── pretty_docs │ ├── __init__.py │ ├── base_page.py │ ├── class_page.py │ ├── docs_for_object.py │ ├── function_page.py │ ├── module_page.py │ ├── pretty_docs_test.py │ ├── templates │ │ ├── class.jinja │ │ ├── function.jinja │ │ ├── module.jinja │ │ ├── page.jinja │ │ ├── root.jinja │ │ └── type_alias.jinja │ └── type_alias_page.py ├── public_api.py ├── public_api_test.py ├── reference_resolver.py ├── reference_resolver_test.py ├── report │ ├── __init__.py │ ├── linter.py │ ├── linter_test.py │ ├── schema │ │ ├── __init__.py │ │ ├── api_report.proto │ │ ├── api_report_generated_319_pb2.py │ │ └── api_report_generated_pb2.py │ └── utils.py ├── signature.py ├── signature_test.py ├── toc.py ├── toc_processing.py ├── toc_processing_test.py ├── toc_test.py ├── traverse.py ├── traverse_test.py └── utils.py ├── modeling └── __init__.py ├── plots └── __init__.py ├── tools ├── .pre-commit-hooks.yaml ├── README.md ├── __init__.py ├── nbcp │ ├── __init__.py │ └── __main__.py ├── nbfmt │ ├── __init__.py │ ├── __main__.py │ ├── nbfmtmain_test.py │ ├── notebook_utils.py │ └── notebook_utils_test.py └── nblint │ ├── __init__.py │ ├── __main__.py │ ├── decorator.py │ ├── fix.py │ ├── linter.py │ └── style │ ├── __init__.py │ ├── gemini_cookbook.py │ ├── google.py │ ├── tensorflow.py │ └── tensorflow_docs_l10n.py └── vis ├── __init__.py └── embed.py /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ipynb text eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/bot-pr-new.yaml: -------------------------------------------------------------------------------- 1 | # Greet new pull requests with a welcome comment and apply labels. 2 | # This workflow must initiate from an authenticated bot repo collaborator. 3 | # Webhook events: Pull requests 4 | name: New pull request 5 | on: 6 | repository_dispatch: 7 | types: [opened, reopened] 8 | 9 | permissions: 10 | contents: read # to fetch code (actions/checkout) 11 | 12 | jobs: 13 | comment-welcome: 14 | permissions: 15 | contents: read # to fetch code (actions/checkout) 16 | pull-requests: write # to comment on pull-request 17 | 18 | if: ${{ github.actor == 'tfdocsbot' }} 19 | runs-on: ubuntu-latest 20 | steps: 21 | - name: Fetch pull request branch 22 | uses: actions/checkout@v2 23 | with: 24 | repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} 25 | ref: ${{ github.event.client_payload.pull_request.head.sha }} 26 | - name: Fetch base master branch 27 | run: git fetch -u "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" master:master 28 | - name: Create message 29 | env: 30 | HEAD_REPOSITORY: ${{ github.event.client_payload.pull_request.head.repo.full_name }} 31 | HEAD_REF: ${{ github.event.client_payload.pull_request.head.ref }} 32 | PR_NUM: ${{ github.event.client_payload.pull_request.number }} 33 | run: | 34 | # Preview links and tool usage only needed for notebook changes. 35 | readarray -t changed_notebooks < <(git diff --name-only master | grep '\.ipynb$' || true) 36 | if [[ ${#changed_notebooks[@]} == 0 ]]; then 37 | echo "No notebooks modified in this pull request." 38 | else 39 | msg="

Preview

\n" 40 | msg+="Preview and run these notebook edits with Google Colab:\n\n" 48 | 49 | reviewnb_url="https://app.reviewnb.com/${GITHUB_REPOSITORY}/pull/${PR_NUM}/files/" 50 | msg+="Rendered notebook diffs available on ReviewNB.com.\n" 51 | 52 | msg+="

Format and style

\n" 53 | msg+="Use the TensorFlow docs notebook tools to format for consistent source diffs and lint for style:\n" 54 | msg+="
\n$ python3 -m pip install -U --user git+https://github.com/tensorflow/docs\n
" 55 | msg+="$ python3 -m tensorflow_docs.tools.nbfmt notebook.ipynb\n
" 56 | msg+="$ python3 -m tensorflow_docs.tools.nblint --arg=repo:tensorflow/docs notebook.ipynb\n
\n" 57 | 58 | msg+="If commits are added to the pull request, synchronize your local branch: git pull origin $HEAD_REF\n" 59 | fi 60 | echo "MESSAGE=$msg" >> $GITHUB_ENV 61 | - name: Post comment 62 | env: 63 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 64 | ISSUE_URL: ${{ github.event.client_payload.pull_request.issue_url }} 65 | run: | 66 | # Env var defined in previous step. Escape string for JSON. 67 | body="$(echo -n -e $MESSAGE | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))')" 68 | # Add comment to pull request. 69 | curl -X POST \ 70 | -H "Accept: application/vnd.github.v3+json" \ 71 | -H "Authorization: token $GITHUB_TOKEN" \ 72 | "${ISSUE_URL}/comments" \ 73 | --data "{\"body\": $body}" 74 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | # Pass/fail checks for continuous integration testing. 2 | # Webhook events: Pull requests 3 | name: CI 4 | on: 5 | pull_request: 6 | paths: 7 | - "site/en/**" 8 | 9 | jobs: 10 | nbfmt: 11 | name: Notebook format 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/setup-python@v1 15 | - uses: actions/checkout@v2 16 | - name: Fetch master branch 17 | run: git fetch -u origin master:master 18 | - name: Install tensorflow-docs 19 | run: python3 -m pip install -U git+https://github.com/tensorflow/docs 20 | - name: Check notebook formatting 21 | run: | 22 | # Only check notebooks modified in this pull request. 23 | readarray -t changed_notebooks < <(git diff --name-only master | grep '\.ipynb$' || true) 24 | if [[ ${#changed_notebooks[@]} == 0 ]]; then 25 | echo "No notebooks modified in this pull request." 26 | exit 0 27 | else 28 | echo "Check formatting with nbfmt:" 29 | python3 -m tensorflow_docs.tools.nbfmt --test "${changed_notebooks[@]}" 30 | fi 31 | 32 | nblint: 33 | name: Notebook lint 34 | runs-on: ubuntu-latest 35 | steps: 36 | - uses: actions/setup-python@v1 37 | - uses: actions/checkout@v2 38 | - name: Fetch master branch 39 | run: git fetch -u origin master:master 40 | - name: Install tensorflow-docs 41 | run: python3 -m pip install -U git+https://github.com/tensorflow/docs 42 | - name: Lint notebooks 43 | run: | 44 | # Only check notebooks modified in this pull request. 45 | readarray -t changed_notebooks < <(git diff --name-only master | grep '\.ipynb$' || true) 46 | if [[ ${#changed_notebooks[@]} == 0 ]]; then 47 | echo "No notebooks modified in this pull request." 48 | exit 0 49 | else 50 | echo "Lint check with nblint:" 51 | python3 -m tensorflow_docs.tools.nblint \ 52 | --arg=repo:tensorflow/docs "${changed_notebooks[@]}" 53 | fi 54 | 55 | outputs-removed: 56 | name: Notebook outputs removed 57 | runs-on: ubuntu-latest 58 | steps: 59 | - uses: actions/checkout@v2 60 | - name: Fetch master branch 61 | run: git fetch -u origin master:master 62 | - name: Check for output cells 63 | run: | 64 | # Notebooks that are allowed to save outputs and excluded from test. 65 | EXCLUDED_PATHS=( 66 | site/en/guide/gpu.ipynb 67 | ) 68 | # Only check notebooks modified in this pull request. 69 | readarray -t changed_notebooks < <(git diff --name-only master | grep '\.ipynb$' || true) 70 | if [[ ${#changed_notebooks[@]} == 0 ]]; then 71 | echo "No notebooks modified in this pull request." 72 | exit 0 73 | fi 74 | # Remove notebooks excluded from test. 75 | declare -a tested_notebooks 76 | for fp in "${changed_notebooks[@]}"; do 77 | is_excluded=0 78 | for excluded_fp in "${EXCLUDED_PATHS[@]}"; do 79 | if [[ "$fp" == "$excluded_fp" ]]; then 80 | is_excluded=1 81 | break 82 | fi 83 | done 84 | if [[ $is_excluded == 0 ]]; then 85 | tested_notebooks+=("$fp") 86 | fi 87 | done 88 | # Test notebooks for output cells. 89 | status_code=0 90 | for fp in "${tested_notebooks[@]}"; do 91 | # Output cells use the "output_type" property. 92 | if grep --quiet "\"output_type\":" "$fp"; then 93 | echo "[${GITHUB_WORKFLOW}] Remove output cells from: $fp" >&2 94 | status_code=1 95 | fi 96 | done 97 | if [[ "$status_code" != 0 ]]; then 98 | echo "To remove notebook outputs:" >&2 99 | echo "$ python3 -m tensorflow_docs.tools.nbfmt --remove_outputs notebook.ipynb" >&2 100 | fi 101 | exit "$status_code" 102 | -------------------------------------------------------------------------------- /.github/workflows/stale.yaml: -------------------------------------------------------------------------------- 1 | # This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time. 2 | # 3 | # You can adjust the behavior by modifying this file. 4 | # For more information, see: 5 | # https://github.com/actions/stale 6 | name: Mark stale issues and pull requests 7 | 8 | on: 9 | schedule: 10 | # Scheduled to run at 1.30 UTC everyday 11 | - cron: '30 1 * * *' 12 | workflow_dispatch: 13 | 14 | jobs: 15 | stale: 16 | 17 | runs-on: ubuntu-latest 18 | permissions: 19 | issues: write 20 | pull-requests: write 21 | 22 | steps: 23 | - uses: actions/stale@v9 24 | with: 25 | repo-token: ${{ secrets.GITHUB_TOKEN }} 26 | days-before-issue-stale: 14 27 | days-before-issue-close: 14 28 | stale-issue-label: "status:stale" 29 | close-issue-reason: not_planned 30 | any-of-labels: "awaiting-contributor-response,cla:no" 31 | stale-issue-message: > 32 | Marking this issue as stale since it has been open for 14 days with no activity. 33 | This issue will be closed if no further activity occurs. 34 | close-issue-message: > 35 | This issue was closed because it has been inactive for 28 days. 36 | Please post a new issue if you need further assistance. Thanks! 37 | days-before-pr-stale: 14 38 | days-before-pr-close: 14 39 | stale-pr-label: "status:stale" 40 | stale-pr-message: > 41 | Marking this pull request as stale since it has been open for 14 days with no activity. 42 | This PR will be closed if no further activity occurs. 43 | close-pr-message: > 44 | This pull request was closed because it has been inactive for 28 days. 45 | Please open a new pull request if you need further assistance. Thanks! 46 | # Label that can be assigned to issues to exclude them from being marked as stale 47 | exempt-issue-labels: 'override-stale' 48 | # Label that can be assigned to PRs to exclude them from being marked as stale 49 | exempt-pr-labels: "override-stale" 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.pyc 2 | **/*.rws 3 | **/.DS_Store 4 | **/.idea 5 | **/.ipynb_checkpoints 6 | **/.vscode 7 | **/proofreading 8 | **/venv 9 | **/.python-version 10 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | # This is the official list of TensorFlow authors for copyright purposes. 3 | # This file is distinct from the CONTRIBUTORS files. 4 | # See the latter for an explanation. 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | Google Inc. 9 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # https://help.github.com/articles/about-codeowners/ 2 | # Last matching pattern takes precedence. 3 | 4 | # Default owners for everything in repo. 5 | * @tensorflow/docs-team 6 | 7 | # Install 8 | /site/en/install/ @haifeng-jin @MarkDaoust @8bitmp3 9 | 10 | # Community 11 | /site/en/community/ @ewilderj @theadactyl @joanafilipa 12 | 13 | # Hub 14 | /site/en/hub @gustheman -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | You don't need to be a developer or a technical writer to make a significant 4 | impact on the TensorFlow documentation—just a [GitHub account](https://github.com/). 5 | This guide shows how to make contributions to [tensorflow.org](https://www.tensorflow.org). 6 | 7 | See the 8 | [TensorFlow docs contributor guide](https://www.tensorflow.org/community/contribute/docs) 9 | for guidance. For questions, check out [TensorFlow Forum](https://discuss.tensorflow.org/). 10 | 11 | Questions about TensorFlow usage are better addressed on 12 | [Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow) or the 13 | [discuss@tensorflow.org](https://groups.google.com/a/tensorflow.org/forum/#!forum/discuss) 14 | mailing list. 15 | 16 | To contribute to the TensorFlow code repositories, see the 17 | [TensorFlow code contributor guide](https://www.tensorflow.org/community/contribute/code) 18 | and the 19 | [TensorFlow contribution guidelines](https://github.com/tensorflow/tensorflow/blob/master/CONTRIBUTING.md). 20 | 21 | ## Contributor License Agreements 22 | 23 | We love patches! To publish your changes, you must sign either the individual or 24 | corporate Contributor License Agreement (CLA): 25 | 26 | * If you are an individual writing original documentation or source code and 27 | you're sure you own the intellectual property, sign an 28 | [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). 29 | * If you work for a company that wants to allow you to contribute your work, sign 30 | a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). 31 | 32 | We can accept your pull requests after you sign the CLA. We can only receive 33 | original documentation and source code from you and other people that have 34 | signed the CLA. 35 | 36 | 37 | # About our docs 38 | 39 | The TensorFlow documentation is written in [Markdown](https://commonmark.org/help/) 40 | and [Jupyter/Colab notebooks](https://colab.research.google.com/notebooks/welcome.ipynb). 41 | 42 | The root of [tensorflow.org/](https://www.tensorflow.org/) is found in the 43 | `site/en` directory. 44 | 45 | Not all technical content on tensorflow.org is located in `site/en`. Some 46 | projects have their repositories under 47 | [github.com/tensorflow](https://github.com/tensorflow) and they contain 48 | project-specific documentation. These projects are navigable from the 49 | tensorflow/docs `site/en` directory and include a redirect link to where the 50 | docs can be updated. 51 | 52 | The API reference is generated from the source code located in the core 53 | [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow) repository 54 | and other projects. 55 | 56 | Additionally, some non-technical content, images, and design elements are not 57 | located in the `tensorflow/docs` repository. 58 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include **/templates/* 2 | global-include *.sh -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TensorFlow Documentation 2 | 3 |
4 |

5 |
6 | 7 | These are the source files for the guide and tutorials on 8 | [tensorflow.org](https://www.tensorflow.org/overview). 9 | 10 | To contribute to the TensorFlow documentation, please read 11 | [CONTRIBUTING.md](CONTRIBUTING.md), the 12 | [TensorFlow docs contributor guide](https://www.tensorflow.org/community/contribute/docs), 13 | and the [style guide](https://www.tensorflow.org/community/contribute/docs_style). 14 | 15 | To file a docs issue, use the issue tracker in the 16 | [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow/issues/new?template=20-documentation-issue.md) repo. 17 | 18 | And join the TensorFlow documentation contributors on the 19 | [TensorFlow Forum](https://discuss.tensorflow.org/). 20 | 21 | ## Community translations 22 | 23 | [Community translations](https://www.tensorflow.org/community/contribute/docs#community_translations) 24 | are located in the 25 | [tensorflow/docs-l10n](https://github.com/tensorflow/docs-l10n) repo. These docs 26 | are contributed, reviewed, and maintained by the community as *best-effort*. To 27 | participate as a translator or reviewer, see the `site//README.md`, join 28 | the language mailing list, and submit a pull request. 29 | 30 | ## License 31 | 32 | [Apache License 2.0](LICENSE) 33 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """tensorflow_docs is a package for generating python api-reference docs.""" 16 | 17 | import datetime 18 | import subprocess 19 | import sys 20 | 21 | from setuptools import find_packages 22 | from setuptools import setup 23 | 24 | project_name = 'tensorflow-docs' 25 | 26 | 27 | def get_version() -> str: 28 | ts = int( 29 | subprocess.check_output(['git', 'log', '-1', '--format=%ct', 'tools']) 30 | .decode('utf-8') 31 | .strip() 32 | ) 33 | dt = datetime.datetime.utcfromtimestamp(ts) 34 | sec = 60 * 60 * dt.hour + 60 * dt.minute + dt.second 35 | 36 | # calver.org 37 | return f'{dt.year}.{dt.month}.{dt.day}.{sec}' 38 | 39 | 40 | version = get_version() 41 | 42 | DOCLINES = __doc__.split('\n') 43 | 44 | REQUIRED_PKGS = [ 45 | 'astor', 46 | 'absl-py', 47 | 'jinja2', 48 | 'nbformat', 49 | 'protobuf>=3.12', 50 | 'pyyaml', 51 | ] 52 | 53 | VIS_REQUIRE = [ 54 | 'numpy', 55 | 'PILLOW', 56 | 'webp', 57 | ] 58 | 59 | # https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords 60 | setup( 61 | name=project_name, 62 | python_requires='>=3.9', 63 | version=version, 64 | description=DOCLINES[0], 65 | long_description='\n'.join(DOCLINES[2:]), 66 | author='Google Inc.', 67 | author_email='packages@tensorflow.org', 68 | url='http://github.com/tensorflow/docs', 69 | download_url='https://github.com/tensorflow/docs/tags', 70 | license='Apache 2.0', 71 | packages=find_packages('tools'), 72 | package_dir={'': 'tools'}, 73 | scripts=[], 74 | install_requires=REQUIRED_PKGS, 75 | extras_require={'vis': VIS_REQUIRE}, 76 | classifiers=[ 77 | 'Development Status :: 4 - Beta', 78 | 'Intended Audience :: Developers', 79 | 'License :: OSI Approved :: Apache Software License', 80 | 'Topic :: Scientific/Engineering :: Artificial Intelligence', 81 | ], 82 | keywords='tensorflow api reference', 83 | # Include_package_data is required for setup.py to recognize the MANIFEST.in 84 | # https://python-packaging.readthedocs.io/en/latest/non-code-files.html 85 | include_package_data=True, 86 | ) 87 | -------------------------------------------------------------------------------- /site/en/about/_menu_toc.yaml: -------------------------------------------------------------------------------- 1 | toc: 2 | - column: 3 | - links: 4 | - label: "About" 5 | path: /about/ 6 | - label: "Case studies" 7 | path: /about/case-studies/ 8 | -------------------------------------------------------------------------------- /site/en/community/_toc.yaml: -------------------------------------------------------------------------------- 1 | toc: 2 | - name: "Groups" 3 | contents: 4 | - title: "User groups" 5 | path: /community/groups 6 | - title: "Mailing lists" 7 | path: /community/mailing-lists 8 | 9 | - heading: "Community resources" 10 | - title: "SIG playbook" 11 | path: /community/sig_playbook 12 | 13 | - name: "Contribute" 14 | contents: 15 | - title: "Contribute to TensorFlow" 16 | path: /community/contribute 17 | 18 | - heading: "Code" 19 | - title: "Contribute to code" 20 | path: /community/contribute/code 21 | - title: "Contribute tests" 22 | path: /community/contribute/tests 23 | - title: "Code style" 24 | path: /community/contribute/code_style 25 | 26 | - heading: "Documentation" 27 | - title: "Contribute to documentation" 28 | path: /community/contribute/docs 29 | - title: "Contribute to API documentation" 30 | path: /community/contribute/docs_ref 31 | - title: "Documentation style" 32 | path: /community/contribute/docs_style 33 | 34 | - heading: "Community" 35 | - title: "Contribute to the community" 36 | path: /community/contribute/community 37 | - title: "Contribute to SIGs" 38 | path: /community/contribute/sigs 39 | - title: "RFC process" 40 | path: /community/contribute/rfc_process 41 | -------------------------------------------------------------------------------- /site/en/community/contribute/index.md: -------------------------------------------------------------------------------- 1 | # Contribute to TensorFlow 2 | 3 | The TensorFlow ecosystem can only grow through the contributions of this 4 | community. Thanks so much for your enthusiasm and your work—we appreciate 5 | everything you do! 6 | 7 | ## Community values 8 | 9 | In the interest of fostering an open and welcoming environment, contributors and 10 | maintainers pledge to make participation in our project and our community a 11 | harassment-free experience for everyone—regardless of age, body size, 12 | disability, ethnicity, gender identity and expression, level of experience, 13 | nationality, personal appearance, race, religion, or sexual identity and 14 | orientation. 15 | 16 | Examples of behaviors that contribute to creating a positive environment 17 | include: 18 | 19 | * Use welcome and inclusive language. 20 | * Be respectful of differing viewpoints and experiences. 21 | * Gracefully accept constructive criticism. 22 | * Foster what's best for the community. 23 | * Show empathy for other community members. 24 | 25 | Decisions are made based on technical merit and consensus. The TensorFlow 26 | community aspires to treat everyone equally, and to value all contributions. For 27 | more information on best practices in the TensorFlow community, please review 28 | our 29 | [Code of Conduct](https://github.com/tensorflow/tensorflow/blob/master/CODE_OF_CONDUCT.md). 30 | 31 | ## Make your first contribution 32 | 33 | There are many ways to contribute to TensorFlow! You can contribute code, make 34 | improvements to the TensorFlow API documentation, or add your Jupyter notebooks 35 | to the [tensorflow/examples](http://www.github.com/tensorflow/examples) repo. 36 | This guide provides everything you need to get started. Our most common 37 | contributions include *code*, *documentation*, and *community support*. 38 | 39 | - [Write code](code.md). 40 | - [Improve tests](tests.md). 41 | - [Improve documentation](docs.md). 42 | - Answer questions on 43 | [Stack Overflow](https://stackoverflow.com/questions/tagged/tensorflow). 44 | - Participate in the discussion on our 45 | [mailing lists](../mailing-lists.md). 46 | - Contribute [example notebooks](http://www.github.com/tensorflow/examples). 47 | - Investigate [bugs and issues](https://github.com/tensorflow/tensorflow/issues) 48 | on GitHub. 49 | - Review and comment on 50 | [pull requests](https://github.com/tensorflow/tensorflow/pulls) from other 51 | developers. 52 | - [Report an issue](https://github.com/tensorflow/tensorflow/issues/new/choose). 53 | - Give a “thumbs up” 👍 on issues that are relevant to you. 54 | - Reference TensorFlow in your blogs, papers, and articles. 55 | - Talk about TensorFlow on social media. 56 | - ... even just starring/forking the repos you like on GitHub! 57 | 58 | TensorFlow was originally developed by researchers and engineers from the Google 59 | Brain team within [Google's AI organization](https://ai.google/). Google open 60 | sourced TensorFlow in the hope of sharing technology with the external community 61 | and encouraging collaboration between researchers and industry. Since then, 62 | TensorFlow has grown into a thriving ecosystem of products, on a wide range of 63 | platforms. But our goal is still to make machine learning accessible to anyone, 64 | anywhere. 65 | -------------------------------------------------------------------------------- /site/en/guide/_toc.yaml: -------------------------------------------------------------------------------- 1 | toc: 2 | - title: "TensorFlow guide" 3 | path: /guide/ 4 | 5 | - heading: "TensorFlow basics" 6 | - title: "Overview" 7 | path: /guide/basics 8 | - title: "Tensors" 9 | path: /guide/tensor 10 | - title: "Variables" 11 | path: /guide/variable 12 | - title: "Automatic differentiation" 13 | path: /guide/autodiff 14 | - title: "Graphs and functions" 15 | path: /guide/intro_to_graphs 16 | - title: "Modules, layers, and models" 17 | path: /guide/intro_to_modules 18 | - title: "Training loops" 19 | path: /guide/basic_training_loops 20 | 21 | - heading: "Keras" 22 | - title: "Overview" 23 | path: /guide/keras 24 | - include: /guide/keras/_toc.yaml 25 | 26 | - heading: "Build with Core" 27 | status: new 28 | - title: "Overview" 29 | path: /guide/core/index 30 | - title: "Quickstart for Core" 31 | path: /guide/core/quickstart_core 32 | - title: "Logistic regression" 33 | path: /guide/core/logistic_regression_core 34 | - title: "Multilayer perceptrons" 35 | path: /guide/core/mlp_core 36 | - title: "Matrix approximation" 37 | path: /guide/core/matrix_core 38 | - title: "Custom optimizers" 39 | path: /guide/core/optimizers_core 40 | - title: "DTensor with Core APIs" 41 | path: /guide/core/distribution 42 | status: experimental 43 | 44 | - heading: "TensorFlow in depth" 45 | - title: "Tensor slicing" 46 | path: /guide/tensor_slicing 47 | - title: "Advanced autodiff" 48 | path: /guide/advanced_autodiff 49 | - title: "Ragged tensor" 50 | path: /guide/ragged_tensor 51 | - title: "Sparse tensor" 52 | path: /guide/sparse_tensor 53 | - title: "Random number generation" 54 | path: /guide/random_numbers 55 | - title: "NumPy API" 56 | status: experimental 57 | path: /guide/tf_numpy 58 | - title: "NumPy API Type Promotion" 59 | status: nightly 60 | path: /guide/tf_numpy_type_promotion 61 | - title: "DTensor concepts" 62 | path: /guide/dtensor_overview 63 | status: experimental 64 | - title: "Thinking in TensorFlow 2" 65 | path: /guide/effective_tf2 66 | 67 | - heading: "Customization" 68 | - title: "Create an op" 69 | path: /guide/create_op 70 | - title: "Extension types" 71 | path: /guide/extension_type 72 | status: experimental 73 | 74 | - heading: "Data input pipelines" 75 | - title: "tf.data" 76 | path: /guide/data 77 | - title: "Optimize pipeline performance" 78 | path: /guide/data_performance 79 | - title: "Analyze pipeline performance" 80 | path: /guide/data_performance_analysis 81 | 82 | - heading: "Import and export" 83 | - title: "Checkpoint" 84 | path: /guide/checkpoint 85 | - title: "SavedModel" 86 | path: /guide/saved_model 87 | - title: "Import a JAX model using JAX2TF" 88 | status: new 89 | path: /guide/jax2tf 90 | 91 | - heading: "Accelerators" 92 | - title: "Distributed training" 93 | path: /guide/distributed_training 94 | - title: "GPU" 95 | path: /guide/gpu 96 | - title: "TPU" 97 | path: /guide/tpu 98 | 99 | - heading: "Performance" 100 | - title: "Better performance with tf.function" 101 | path: /guide/function 102 | - title: "Profile TensorFlow performance" 103 | path: /guide/profiler 104 | - title: "Optimize GPU Performance" 105 | path: /guide/gpu_performance_analysis 106 | - title: "Graph optimization" 107 | path: /guide/graph_optimization 108 | - title: "Mixed precision" 109 | path: /guide/mixed_precision 110 | 111 | - heading: "Model Garden" 112 | status: new 113 | - title: "Overview" 114 | path: /tfmodels 115 | - title: "Training with Orbit" 116 | path: /tfmodels/orbit 117 | - title: "TFModels - NLP" 118 | path: /tfmodels/nlp 119 | status: external 120 | - include: /tfmodels/vision/_toc.yaml 121 | 122 | - heading: "Estimators" 123 | status: deprecated 124 | - title: "Estimator overview" 125 | path: /guide/estimator 126 | 127 | - heading: "Appendix" 128 | - title: "Version compatibility" 129 | path: /guide/versions 130 | -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/async_long_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/async_long_name.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/example_1_cropped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/example_1_cropped.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/example_2_cropped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/example_2_cropped.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/get_next_fast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/get_next_fast.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/get_next_slow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/get_next_slow.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/map_long_name.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/map_long_name.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/prefetch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/prefetch.png -------------------------------------------------------------------------------- /site/en/guide/images/data_performance_analysis/trace_viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/data_performance_analysis/trace_viewer.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/gpu_kernels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/gpu_kernels.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/input_pipeline_analyzer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/input_pipeline_analyzer.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/opp_placement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/opp_placement.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/overview_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/overview_page.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/performance_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/performance_summary.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/tensorflow_stats_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/tensorflow_stats_page.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_excessive_copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_excessive_copy.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_gpu_idle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_gpu_idle.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_host_contention.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_host_contention.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_ideal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_ideal.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_kernel_gaps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_kernel_gaps.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_multi_gpu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_multi_gpu.png -------------------------------------------------------------------------------- /site/en/guide/images/gpu_perf_analysis/traceview_step_gaps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/gpu_perf_analysis/traceview_step_gaps.png -------------------------------------------------------------------------------- /site/en/guide/images/graph_optimization/meta_optimizer_disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/graph_optimization/meta_optimizer_disabled.png -------------------------------------------------------------------------------- /site/en/guide/images/graph_optimization/meta_optimizer_enabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/graph_optimization/meta_optimizer_enabled.png -------------------------------------------------------------------------------- /site/en/guide/images/graph_optimization/optimized_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/graph_optimization/optimized_graph.png -------------------------------------------------------------------------------- /site/en/guide/images/graph_optimization/user_defined_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/graph_optimization/user_defined_graph.png -------------------------------------------------------------------------------- /site/en/guide/images/intro_to_graphs/two-layer-network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/intro_to_graphs/two-layer-network.png -------------------------------------------------------------------------------- /site/en/guide/images/new_type_promotion/type_promotion_lattice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/new_type_promotion/type_promotion_lattice.png -------------------------------------------------------------------------------- /site/en/guide/images/new_type_promotion/type_promotion_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/new_type_promotion/type_promotion_table.png -------------------------------------------------------------------------------- /site/en/guide/images/sparse_tensor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/sparse_tensor.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/3-axis_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/3-axis_block.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/3-axis_front.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/3-axis_front.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/3-axis_numpy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/3-axis_numpy.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/3-axis_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/3-axis_stack.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/4-axis_block.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/4-axis_block.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/broadcasting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/broadcasting.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/index1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/index1.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/index2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/index2.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/matrix.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/ragged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/ragged.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-bad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-bad.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-bad2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-bad2.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-bad3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-bad3.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-bad4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-bad4.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-before.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-before.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-good1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-good1.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/reshape-good2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/reshape-good2.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/scalar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/scalar.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/shape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/shape.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/shape2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/shape2.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/sparse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/sparse.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/string-split.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/string-split.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/strings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/strings.png -------------------------------------------------------------------------------- /site/en/guide/images/tensor/vector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensor/vector.png -------------------------------------------------------------------------------- /site/en/guide/images/tensorboard_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tensorboard_graph.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/capture_profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/capture_profile.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/gpu_kernel_stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/gpu_kernel_stats.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/input_op_stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/input_op_stats.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/input_pipeline_analyzer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/input_pipeline_analyzer.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/memory_breakdown_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/memory_breakdown_table.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/memory_profile_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/memory_profile_summary.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/memory_timeline_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/memory_timeline_graph.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/memory_timeline_graph_popup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/memory_timeline_graph_popup.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/overview_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/overview_page.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/pod_viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/pod_viewer.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/python_tracer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/python_tracer.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/tf_data_all_hosts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/tf_data_all_hosts.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/tf_data_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/tf_data_graph.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/tf_data_graph_selector.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/tf_data_graph_selector.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/tf_data_summary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/tf_data_summary.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/tf_stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/tf_stats.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_profiler/trace_viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_profiler/trace_viewer.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/gather_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/gather_1.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/gather_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/gather_2.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/gather_nd_sparse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/gather_nd_sparse.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/slice_1d_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/slice_1d_1.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/slice_1d_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/slice_1d_2.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/slice_1d_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/slice_1d_3.png -------------------------------------------------------------------------------- /site/en/guide/images/tf_slicing/slice_2d_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/images/tf_slicing/slice_2d_1.png -------------------------------------------------------------------------------- /site/en/guide/keras/README.md: -------------------------------------------------------------------------------- 1 | Welcome to the warp zone! 2 | 3 | # Keras 4 | 5 | These docs are available here: https://github.com/keras-team/keras-io/tree/master/guides 6 | -------------------------------------------------------------------------------- /site/en/guide/migrate/_toc.yaml: -------------------------------------------------------------------------------- 1 | toc: 2 | - title: Migration guide 3 | path: /guide/migrate/ 4 | - heading: Migration overview 5 | - title: Migrate to TensorFlow 2 6 | path: /guide/migrate/migrate_tf2 7 | - title: TF1 vs TF2 behavior comparison 8 | path: /guide/migrate/tf1_vs_tf2 9 | - title: Convert with the upgrade script 10 | path: /guide/migrate/upgrade 11 | 12 | - heading: Migrate your models 13 | - title: TF2 model mapping 14 | path: /guide/migrate/model_mapping 15 | - title: TF Lite models in TF2 16 | path: /guide/migrate/tflite 17 | - title: Migrating checkpoints 18 | path: /guide/migrate/migrating_checkpoints 19 | - title: Canned and boosted tree estimators 20 | path: /guide/migrate/canned_estimators 21 | 22 | - heading: Migrate training and evaluation pipelines 23 | - title: Estimators 24 | path: /guide/migrate/migrating_estimator 25 | - title: Summary APIs 26 | path: https://www.tensorflow.org/tensorboard/migrate 27 | status: external 28 | - title: Estimator logging and stop hooks 29 | path: /guide/migrate/logging_stop_hook 30 | - title: tf.estimator.SessionRunHook API 31 | path: /guide/migrate/sessionrunhook_callback 32 | # - title: Migrate custom training loops 33 | # path: /guide/migrate/custom_training_loops 34 | - title: Early stopping 35 | path: /guide/migrate/early_stopping 36 | - title: Feature columns to Keras preprocessing layers 37 | path: /guide/migrate/migrating_feature_columns 38 | - title: Metrics and optimizers 39 | path: /guide/migrate/metrics_optimizers 40 | - title: Incorporate fault tolerance in training 41 | path: /guide/migrate/fault_tolerance 42 | - title: Evaluate training metrics with SidecarEvaluator 43 | path: /guide/migrate/evaluator 44 | - title: TensorBoard metric displays 45 | path: /guide/migrate/tensorboard 46 | 47 | - heading: Migrate saving and export workflows 48 | - title: Export models to SavedModel 49 | path: /guide/migrate/saved_model 50 | - title: Save checkpoints 51 | path: /guide/migrate/checkpoint_saver 52 | 53 | - heading: Migrate distributed training workflows 54 | - title: Multi-GPU training 55 | path: /guide/migrate/mirrored_strategy 56 | - title: Multi-worker training on CPU and GPU 57 | path: /guide/migrate/multi_worker_cpu_gpu_training 58 | - title: Multi-worker training on TPU 59 | path: /guide/migrate/tpu_estimator 60 | - title: TPU embedding_columns to TPUEmbedding layer 61 | path: /guide/migrate/tpu_embedding 62 | # - title: Efficient distributed input processing 63 | # path: /guide/migrate/distributed_input_processing 64 | 65 | - heading: Validate model quality and performance 66 | - title: Validate correctness and numerical equivalence 67 | path: /guide/migrate/validate_correctness 68 | - title: Debug TF2 Migrated Training Pipeline 69 | path: /guide/migrate/migration_debugging 70 | # - title: Testing speed and throughput 71 | # path: /guide/migrate/throughput_testing 72 | -------------------------------------------------------------------------------- /site/en/guide/migrate/images/tensorboard_TF1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/migrate/images/tensorboard_TF1.png -------------------------------------------------------------------------------- /site/en/guide/migrate/images/tensorboard_TF2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/guide/migrate/images/tensorboard_TF2.png -------------------------------------------------------------------------------- /site/en/hub/_book.yaml: -------------------------------------------------------------------------------- 1 | upper_tabs: 2 | # Tabs left of dropdown menu 3 | - include: /_upper_tabs_left.yaml 4 | - include: /api_docs/_upper_tabs_api.yaml 5 | # Dropdown menu 6 | - name: Resources 7 | path: /resources 8 | is_default: true 9 | menu: 10 | - include: /resources/_menu_toc.yaml 11 | lower_tabs: 12 | # Subsite tabs 13 | other: 14 | # [Guide] 15 | - name: "Guide" 16 | contents: 17 | # TF Hub Platform overview. 18 | - heading: Getting Started 19 | - title: Overview 20 | path: /hub/overview 21 | - title: Installation 22 | path: /hub/installation 23 | - title: Community and support 24 | path: /hub/community 25 | # Python library usage information 26 | - heading: Using the library 27 | - title: Overview 28 | path: /hub/lib_overview 29 | - title: SavedModels for TensorFlow 2 30 | path: /hub/tf2_saved_model 31 | - title: Caching model downloads 32 | path: /hub/caching 33 | - title: Migration to TF2 34 | path: /hub/migration_tf2 35 | - title: Model compatibility for TF1/TF2 36 | path: /hub/model_compatibility 37 | - title: "Deprecated: TF1 Hub format" 38 | path: /hub/tf1_hub_module 39 | status: deprecated 40 | # SavedModel APIs 41 | - heading: Common SavedModel APIs 42 | - title: Overview 43 | path: /hub/common_saved_model_apis/index.md 44 | - title: Reusable SavedModels (for all tasks) 45 | path: /hub/reusable_saved_models 46 | - title: Image tasks 47 | path: /hub/common_saved_model_apis/images 48 | - title: Text tasks 49 | path: /hub/common_saved_model_apis/text 50 | # Publishing models 51 | - heading: Publishing models 52 | - title: Publishing process 53 | path: /hub/publish 54 | - title: Data portability and deletion 55 | path: /hub/portability_and_deletion 56 | # Advanced developer info 57 | - heading: Advanced developer info 58 | - title: Model formats 59 | path: /hub/model_formats 60 | - title: Model hosting protocol 61 | path: /hub/hosting 62 | - title: Build from source 63 | path: /hub/build_from_source 64 | - title: Common issues 65 | path: /hub/common_issues 66 | - title: Contribute to TensorFlow Hub 67 | path: /hub/contribute 68 | # [Tutorials] 69 | - name: Tutorials 70 | path: /hub/tutorials 71 | contents: 72 | - include: /hub/tutorials/_toc.yaml 73 | # [API] 74 | - name: API 75 | skip_translation: true 76 | contents: 77 | - include: /hub/api_docs/python/hub/_toc.yaml 78 | # [Models] 79 | - name: "Models ↗" 80 | contents: 81 | - title: Models 82 | path: https://tfhub.dev 83 | status: external 84 | 85 | - include: /_upper_tabs_right.yaml 86 | -------------------------------------------------------------------------------- /site/en/hub/_redirects.yaml: -------------------------------------------------------------------------------- 1 | redirects: 2 | - from: /hub/becoming_a_publisher 3 | to: /hub/publish 4 | - from: /hub/writing_model_documentation 5 | to: /hub/writing_documentation#model 6 | - from: /hub/creating_a_collection 7 | to: /hub/writing_documentation#collection 8 | -------------------------------------------------------------------------------- /site/en/hub/caching.md: -------------------------------------------------------------------------------- 1 | 2 | # Caching model downloads from TF Hub 3 | 4 | ## Overview 5 | 6 | The `tensorflow_hub` library currently supports two modes for downloading 7 | models. By default, a model is downloaded as a compressed archive and cached on 8 | disk. Secondly, models can directly be read from remote storage into TensorFlow. 9 | Either way, the calls to `tensorflow_hub` functions in the actual Python code 10 | can and should continue to use the canonical tfhub.dev URLs of models, which are 11 | portable across systems and navigable for documentation. In the rare case that 12 | user code needs the actual filesystem location (after downloading and 13 | decompressing, or after resolving a model handle into a filesystem path), 14 | it can be obtained by the function `hub.resolve(handle)`. 15 | 16 | ### Caching of compressed downloads 17 | 18 | The `tensorflow_hub` library by default caches models on the filesystem when 19 | they have been downloaded from tfhub.dev (or other [hosting sites](hosting.md)) 20 | and decompressed. This mode is recommended for most environments, except if disk 21 | space is scarce but network bandwidth and latency are superb. 22 | 23 | The download location defaults to a local temporary directory but can be 24 | customized by setting the environment variable `TFHUB_CACHE_DIR` (recommended) 25 | or by passing the command-line flag `--tfhub_cache_dir`. The default cache 26 | location `/tmp/tfhub_modules` (or whatever `os.path.join(tempfile.gettempdir(), 27 | "tfhub_modules")` is evaluated to) should work in most cases. 28 | 29 | Users who prefer persistent caching across system reboots can instead set 30 | `TFHUB_CACHE_DIR` to a location in their home directory. For example, a user of 31 | the bash shell on a Linux system can add a line like the following to 32 | `~/.bashrc`: 33 | 34 | ```bash 35 | export TFHUB_CACHE_DIR=$HOME/.cache/tfhub_modules 36 | ``` 37 | 38 | ...restart the shell, and then this location will be used. When using a 39 | persistent location, be aware that there is no automatic cleanup. 40 | 41 | ### Reading from remote storage 42 | 43 | Users can instruct the `tensorflow_hub` library to directly read models from 44 | remote storage (GCS) instead of downloading the models locally with: 45 | 46 | ```shell 47 | os.environ["TFHUB_MODEL_LOAD_FORMAT"] = "UNCOMPRESSED" 48 | ``` 49 | 50 | or by setting the command-line flag `--tfhub_model_load_format` to 51 | `UNCOMPRESSED`. This way, no caching directory is needed, which is especially 52 | helpful in environments that provide little disk space but a fast internet 53 | connection. 54 | 55 | ### Running on TPU in Colab notebooks 56 | 57 | On [colab.research.google.com](https://colab.research.google.com), downloading 58 | compressed models will conflict with the TPU runtime since the computation 59 | workload is delegated to another machine that does not have access to the cache 60 | location by default. There are two workarounds for this situation: 61 | 62 | #### 1) Use a GCS bucket that the TPU worker can access 63 | 64 | The easiest solution is to instruct the `tensorflow_hub` library to read the 65 | models from TF Hub's GCS bucket as explained above. Users with their own GCS 66 | bucket can instead specify a directory in their bucket as the cache location 67 | with code like: 68 | 69 | ```python 70 | import os 71 | os.environ["TFHUB_CACHE_DIR"] = "gs://my-bucket/tfhub-modules-cache" 72 | ``` 73 | 74 | ...before calling the `tensorflow_hub` library. 75 | 76 | #### 2) Redirect all reads through the Colab host 77 | 78 | Another workaround is to redirect all reads (even of large variables) through 79 | the Colab host: 80 | 81 | ```python 82 | load_options = 83 | tf.saved_model.LoadOptions(experimental_io_device='/job:localhost') 84 | reloaded_model = hub.load("https://tfhub.dev/...", options=load_options) 85 | ``` 86 | **Note:** See more information regarding valid handles [here](tf2_saved_model.md#model_handles). 87 | -------------------------------------------------------------------------------- /site/en/hub/common_saved_model_apis/index.md: -------------------------------------------------------------------------------- 1 | 2 | # Common SavedModel APIs for TF Hub 3 | 4 | ## Introduction 5 | 6 | [TensorFlow Hub](https://tfhub.dev) hosts models for a variety of tasks. Models 7 | for the same task are encouraged to implement a common API so that model 8 | consumers can easily exchange them without modifying the code that uses them, 9 | even if they come from different publishers. 10 | 11 | The goal is to make exchanging different models for the same task as simple as 12 | switching a string-valued hyperparameter. With that, model consumers can easily 13 | find the best one for their problem. 14 | 15 | This directory collects specifications of common APIs for models in the 16 | [TF2 SavedModel format](../tf2_saved_model.md). (It replaces the 17 | [Common Signatures](../common_signatures/index.md) for the now-deprecated 18 | [TF1 Hub format](../tf1_hub_module.md).) 19 | 20 | ## Reusable SavedModel: the common foundation 21 | 22 | The [Reusable SavedModel API](../reusable_saved_models.md) defines general 23 | conventions how to load a SavedModel back into a Python program and reuse it as 24 | part of a bigger TensorFlow model. 25 | 26 | Basic usage: 27 | 28 | ```python 29 | obj = hub.load("path/to/model") # That's tf.saved_model.load() after download. 30 | outputs = obj(inputs, training=False) # Invokes the tf.function obj.__call__. 31 | ``` 32 | 33 | Key point: This uses the object-based interface to restored SavedModels that was 34 | added in TensorFlow 2, not the SavedModel signatures for serving. 35 | 36 | For Keras users, the `hub.KerasLayer` class relies on this API to wrap the 37 | Reusable SavedModel as a Keras Layer (shielding Keras users from its details), 38 | with inputs and outputs according to the task-specific APIs listed below. 39 | 40 | ## Task-specific APIs 41 | 42 | These refine the [Reusable SavedModel API](../reusable_saved_models.md) with 43 | conventions for particular ML tasks and types of data. 44 | 45 | * [Image tasks](images.md) 46 | * [Text tasks](text.md) 47 | -------------------------------------------------------------------------------- /site/en/hub/common_signatures/index.md: -------------------------------------------------------------------------------- 1 | 2 | # Common Signatures for TF Hub Modules 3 | 4 | ## Introduction 5 | 6 | [TensorFlow Hub](https://tfhub.dev) hosts models for a variety of tasks. Models 7 | for the same task are encouraged to implement a common API so that model 8 | consumers can easily exchange them without modifying the code that uses them, 9 | even if they come from different publishers. 10 | 11 | The goal is to make exchanging different models for the same task as simple as 12 | switching a string-valued hyperparameter. With that, model consumers can easily 13 | find the best one for their problem. 14 | 15 | This directory collects specifications of common signatures for modules in the 16 | [TF1 Hub format](../tf1_hub_module.md). 17 | 18 | Note that the TF1 Hub format has been **deprecated** in favor of the 19 | [TF2 SavedModel format](../tf2_saved_model.md) and its 20 | [Common SavedModel APIs](../common_saved_model_apis/index.md). 21 | 22 | ## Signatures 23 | 24 | * [Image Signatures](images.md) 25 | * [Text Signatures](text.md) 26 | -------------------------------------------------------------------------------- /site/en/hub/common_signatures/text.md: -------------------------------------------------------------------------------- 1 | 2 | # Common Signatures for Text 3 | 4 | This page describes common signatures that should be implemented by modules in 5 | the [TF1 Hub format](../tf1_hub_module.md) for tasks that accept text inputs. 6 | (For the [TF2 SavedModel format](../tf2_saved_model.md), see the analogous 7 | [SavedModel API](../common_saved_model_apis/text.md).) 8 | 9 | ## Text feature vector 10 | 11 | A **text feature vector** module creates a dense vector representation 12 | from text features. 13 | It accepts a batch of strings of shape `[batch_size]` and maps them to 14 | a `float32` tensor of shape `[batch_size, N]`. This is often called 15 | **text embedding** in dimension `N`. 16 | 17 | ### Basic usage 18 | 19 | ```python 20 | embed = hub.Module("path/to/module") 21 | representations = embed([ 22 | "A long sentence.", 23 | "single-word", 24 | "http://example.com"]) 25 | ``` 26 | 27 | ### Feature column usage 28 | 29 | ```python 30 | feature_columns = [ 31 | hub.text_embedding_column("comment", "path/to/module", trainable=False), 32 | ] 33 | input_fn = tf.estimator.inputs.numpy_input_fn(features, labels, shuffle=True) 34 | estimator = tf.estimator.DNNClassifier(hidden_units, feature_columns) 35 | estimator.train(input_fn, max_steps=100) 36 | ``` 37 | 38 | ## Notes 39 | 40 | Modules have been pre-trained on different domains and/or tasks, 41 | and therefore not every text feature vector module would be suitable for 42 | your problem. E.g.: some modules could have been trained on a single language. 43 | 44 | This interface does not allow fine-tuning of the text representation on TPUs, 45 | because it requires the module to instantiate both string processing and the 46 | trainable variables at the same time. 47 | -------------------------------------------------------------------------------- /site/en/hub/community.md: -------------------------------------------------------------------------------- 1 | 2 | # Community and support 3 | 4 | * The source code is available on [GitHub](https://github.com/tensorflow/hub). 5 | We use [GitHub issues](https://github.com/tensorflow/hub/issues) for 6 | tracking feature requests and bugs. -------------------------------------------------------------------------------- /site/en/hub/contribute.md: -------------------------------------------------------------------------------- 1 | 2 | # Contribute 3 | 4 | To learn more about how to publish a model or model collection on 5 | [tfhub.dev](https://tfhub.dev/), see the [becoming_a_publisher](publish.md) 6 | guide. 7 | 8 | You can find more information of how to contribute to the 9 | [TensorFlow Hub library](https://github.com/tensorflow/hub) in our 10 | [GitHub contributing guide](https://github.com/tensorflow/hub/blob/master/CONTRIBUTING.md). 11 | 12 | Content published to tfhub.dev can be automatically mirrored to other model 13 | hubs, provided it follows a specified format and is permitted by our Terms 14 | (https://tfhub.dev/terms). See [our publishing documentation](publish.md) for 15 | more details, and [our contribution documentation](contribute_a_model.md) if 16 | you'd like to opt-out of mirroring. 17 | -------------------------------------------------------------------------------- /site/en/hub/images/action_recognition.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/action_recognition.gif -------------------------------------------------------------------------------- /site/en/hub/images/bert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/bert.png -------------------------------------------------------------------------------- /site/en/hub/images/bert_preprocess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/bert_preprocess.png -------------------------------------------------------------------------------- /site/en/hub/images/bert_preprocess_wide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/bert_preprocess_wide.png -------------------------------------------------------------------------------- /site/en/hub/images/bit_blog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/bit_blog.jpg -------------------------------------------------------------------------------- /site/en/hub/images/boundless.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/boundless.png -------------------------------------------------------------------------------- /site/en/hub/images/colab_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /site/en/hub/images/food.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/food.png -------------------------------------------------------------------------------- /site/en/hub/images/gan_faces.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/gan_faces.gif -------------------------------------------------------------------------------- /site/en/hub/images/github_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /site/en/hub/images/guide_basics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/guide_basics.png -------------------------------------------------------------------------------- /site/en/hub/images/image_classification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/image_classification.png -------------------------------------------------------------------------------- /site/en/hub/images/interpolation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/interpolation.png -------------------------------------------------------------------------------- /site/en/hub/images/library_download_cache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/library_download_cache.png -------------------------------------------------------------------------------- /site/en/hub/images/object_detection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/object_detection.png -------------------------------------------------------------------------------- /site/en/hub/images/odml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/odml.png -------------------------------------------------------------------------------- /site/en/hub/images/similarity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/similarity.png -------------------------------------------------------------------------------- /site/en/hub/images/spice_blog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/spice_blog.png -------------------------------------------------------------------------------- /site/en/hub/images/spice_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/spice_color.png -------------------------------------------------------------------------------- /site/en/hub/images/stackoverflow_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /site/en/hub/images/style_transfer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/style_transfer.png -------------------------------------------------------------------------------- /site/en/hub/images/super_resolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/super_resolution.png -------------------------------------------------------------------------------- /site/en/hub/images/text_video.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/text_video.gif -------------------------------------------------------------------------------- /site/en/hub/images/yamnet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/hub/images/yamnet.png -------------------------------------------------------------------------------- /site/en/hub/installation.md: -------------------------------------------------------------------------------- 1 | 2 | # Installation 3 | 4 | ## Installing tensorflow_hub 5 | 6 | The `tensorflow_hub` library can be installed alongside TensorFlow 1 and 7 | TensorFlow 2. We recommend that new users start with TensorFlow 2 right away, 8 | and current users upgrade to it. 9 | 10 | ### Use with TensorFlow 2 11 | 12 | Use [pip](https://pip.pypa.io/) to 13 | [install TensorFlow 2](https://www.tensorflow.org/install) as usual. (See there 14 | for extra instructions about GPU support.) Then install a current version of 15 | [`tensorflow-hub`](https://pypi.org/project/tensorflow-hub/) next to it (must be 16 | 0.5.0 or newer). 17 | 18 | ```bash 19 | $ pip install "tensorflow>=2.0.0" 20 | $ pip install --upgrade tensorflow-hub 21 | ``` 22 | 23 | The TF1-style API of TensorFlow Hub works with the v1 compatibility mode of 24 | TensorFlow 2. 25 | 26 | ### Legacy use with TensorFlow 1 27 | 28 | TensorFlow 1.15 is the only version of TensorFlow 1.x still supported by the 29 | `tensorflow_hub` library (as of release 0.11.0). TensorFlow 1.15 defaults to 30 | TF1-compatible behavior but contains many TF2 features under the hood to allow 31 | some use of TensorFlow Hub's TF2-style APIs. 32 | 33 | ```bash 34 | $ pip install "tensorflow>=1.15,<2.0" 35 | $ pip install --upgrade tensorflow-hub 36 | ``` 37 | 38 | ### Use of pre-release versions 39 | 40 | The pip packages `tf-nightly` and `tf-hub-nightly` are built automatically from 41 | the source code on github, with no release testing. This lets developers try out 42 | the latest code without [building from source](build_from_source.md). 43 | 44 | ```bash 45 | $ pip install tf-nightly 46 | $ pip install --upgrade tf-hub-nightly 47 | ``` 48 | 49 | ## Next Steps 50 | 51 | - [Library overview](lib_overview.md) 52 | - Tutorials: 53 | - [Text classification](https://github.com/tensorflow/docs/blob/master/site/en/hub/tutorials/tf2_text_classification.ipynb) 54 | - [Image classification](https://github.com/tensorflow/docs/blob/master/site/en/hub/tutorials/tf2_image_retraining.ipynb) 55 | - Additional examples 56 | [on GitHub](https://github.com/tensorflow/hub/blob/master/examples/README.md) 57 | - Find models on [tfhub.dev](https://tfhub.dev). -------------------------------------------------------------------------------- /site/en/hub/lib_overview.md: -------------------------------------------------------------------------------- 1 | 2 | # TensorFlow Hub Library Overview 3 | 4 | The [`tensorflow_hub`](https://github.com/tensorflow/hub) library lets you 5 | download and reuse trained models in your TensorFlow program with a minimum 6 | amount of code. The main way to load a trained model is using the 7 | `hub.KerasLayer` API. 8 | 9 | ```python 10 | import tensorflow_hub as hub 11 | 12 | embed = hub.KerasLayer("https://tfhub.dev/google/nnlm-en-dim128/2") 13 | embeddings = embed(["A long sentence.", "single-word", "http://example.com"]) 14 | print(embeddings.shape, embeddings.dtype) 15 | ``` 16 | **Note:** This documentation uses TFhub.dev URL handles in examples. See more 17 | information regarding other valid handle types [here](tf2_saved_model.md#model_handles). 18 | 19 | ## Setting the cache location for downloads. 20 | 21 | By default, `tensorflow_hub` uses a system-wide, temporary directory to cache 22 | downloaded and uncompressed models. See [Caching](caching.md) for options to use 23 | other, possibly more persistent locations. 24 | 25 | ## API stability 26 | 27 | Although we hope to prevent breaking changes, this project is still under active 28 | development and is not yet guaranteed to have a stable API or model format. 29 | 30 | ## Fairness 31 | 32 | As in all of machine learning, [fairness](http://ml-fairness.com) is an 33 | [important](https://research.googleblog.com/2016/10/equality-of-opportunity-in-machine.html) 34 | consideration. Many pre-trained models are trained on large datasets. When 35 | reusing any model, it’s important to be mindful of what data the model was 36 | trained on (and whether there are any existing biases there), and how these 37 | might impact your use of it. 38 | 39 | ## Security 40 | 41 | Since they contain arbitrary TensorFlow graphs, models can be thought of as 42 | programs. 43 | [Using TensorFlow Securely](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) 44 | describes the security implications of referencing a model from an untrusted 45 | source. 46 | 47 | ## Next Steps 48 | 49 | - [Use the library](tf2_saved_model.md) 50 | - [Reusable SavedModels](reusable_saved_models.md) 51 | -------------------------------------------------------------------------------- /site/en/hub/model_formats.md: -------------------------------------------------------------------------------- 1 | 2 | # Model formats 3 | 4 | [tfhub.dev](https://tfhub.dev) hosts the following model 5 | formats: TF2 SavedModel, TF1 Hub format, TF.js and TFLite. This page provides an 6 | overview of each model format. 7 | 8 | Content published to tfhub.dev can be automatically mirrored to other model 9 | hubs, provided it follows a specified format and is permitted by our Terms 10 | (https://tfhub.dev/terms). See [our publishing documentation](publish.md) for 11 | more details, and [our contribution documentation](contribute_a_model.md) if 12 | you'd like to opt-out of mirroring. 13 | 14 | ## TensorFlow formats 15 | 16 | [tfhub.dev](https://tfhub.dev) hosts TensorFlow models in the TF2 SavedModel 17 | format and TF1 Hub format. We recommend using models in the standardized TF2 18 | SavedModel format instead of the deprecated TF1 Hub format when possible. 19 | 20 | ### SavedModel 21 | 22 | TF2 SavedModel is the recommended format for sharing TensorFlow models. You can 23 | learn more about the SavedModel format in the 24 | [TensorFlow SavedModel](https://www.tensorflow.org/guide/saved_model) guide. 25 | 26 | You can browse SavedModels on tfhub.dev by using the TF2 version filter on the 27 | [tfhub.dev browse page](https://tfhub.dev/s?subtype=module,placeholder) or by 28 | following 29 | [this link](https://tfhub.dev/s?subtype=module,placeholder&tf-version=tf2). 30 | 31 | You can use SavedModels from tfhub.dev without depending on the `tensorflow_hub` 32 | library, since this format is a part of core TensorFlow. 33 | 34 | Learn more about SavedModels on TF Hub: 35 | 36 | * [Using TF2 SavedModels](tf2_saved_model.md) 37 | * [Exporting a TF2 SavedModel](exporting_tf2_saved_model.md) 38 | * [TF1/TF2 compatibility of TF2 SavedModels](model_compatibility.md) 39 | 40 | ### TF1 Hub format 41 | 42 | The TF1 Hub format is a custom serialization format used in by TF Hub library. 43 | The TF1 Hub format is similar to the SavedModel format of TensorFlow 1 on a 44 | syntactic level (same file names and protocol messages) but semantically 45 | different to allow for module reuse, composition and re-training (e.g., 46 | different storage of resource initializers, different tagging conventions for 47 | metagraphs). The easiest way to tell them apart on disk is the presence or 48 | absence of the `tfhub_module.pb` file. 49 | 50 | You can browse models in the TF1 Hub format on tfhub.dev by using the TF1 51 | version filter on the 52 | [tfhub.dev browse page](https://tfhub.dev/s?subtype=module,placeholder) or by 53 | following 54 | [this link](https://tfhub.dev/s?subtype=module,placeholder&tf-version=tf1). 55 | 56 | Learn more about models in TF1 Hub format on TF Hub: 57 | 58 | * [Using TF1 Hub format models](tf1_hub_module.md) 59 | * [Exporting a model in the TF1 Hub format](exporting_hub_format.md) 60 | * [TF1/TF2 compatibility of TF1 Hub format](model_compatibility.md) 61 | 62 | ## TFLite format 63 | 64 | The TFLite format is used for on-device inference. You can learn more at the 65 | [TFLite documentation](https://www.tensorflow.org/lite). 66 | 67 | You can browse TF Lite models on tfhub.dev by using the TF Lite model format 68 | filter on the 69 | [tfhub.dev browse page](https://tfhub.dev/s?subtype=module,placeholder) or by 70 | following [this link](https://tfhub.dev/lite). 71 | 72 | ## TFJS format 73 | 74 | The TF.js format is used for in-browser ML. You can learn more at the 75 | [TF.js documentation](https://www.tensorflow.org/js). 76 | 77 | You can browse TF.js models on tfhub.dev by using the TF.js model format filter 78 | on the [tfhub.dev browse page](https://tfhub.dev/s?subtype=module,placeholder) 79 | or by following [this link](https://tfhub.dev/js). 80 | -------------------------------------------------------------------------------- /site/en/hub/overview.md: -------------------------------------------------------------------------------- 1 | 2 | # TensorFlow Hub 3 | 4 | TensorFlow Hub is an open repository and library for reusable machine learning. 5 | The [tfhub.dev](https://tfhub.dev) repository provides many pre-trained models: 6 | text embeddings, image classification models, TF.js/TFLite models and much more. 7 | The repository is open to 8 | [community contributors](https://tfhub.dev/s?subtype=publisher). 9 | 10 | The [`tensorflow_hub`](https://github.com/tensorflow/hub) library lets you 11 | download and reuse them in your TensorFlow program with a minimum amount of 12 | code. 13 | 14 | ```python 15 | import tensorflow_hub as hub 16 | 17 | model = hub.KerasLayer("https://tfhub.dev/google/nnlm-en-dim128/2") 18 | embeddings = model(["The rain in Spain.", "falls", 19 | "mainly", "In the plain!"]) 20 | 21 | print(embeddings.shape) #(4,128) 22 | ``` 23 | 24 | ## Next Steps 25 | 26 | - [Find models on tfhub.dev](https://tfhub.dev) 27 | - [Publish models on tfhub.dev](publish.md) 28 | - TensorFlow Hub library 29 | - [Install TensorFlow Hub](installation.md) 30 | - [Library overview](lib_overview.md) 31 | - [Follow tutorials](tutorials) 32 | -------------------------------------------------------------------------------- /site/en/hub/portability_and_deletion.md: -------------------------------------------------------------------------------- 1 | 2 | ## I want to see what I’ve uploaded to TensorFlow Hub. Can I get a copy of my data? 3 | 4 | Yes. If you’d like the Kaggle Team to **send you a copy** of all of the 5 | data you have uploaded, please send us an email at [support@kaggle.com](mailto:support@kaggle.com) 6 | and we’ll respond as soon as possible. 7 | 8 | ## How do I delete what I’ve uploaded to TensorFlow Hub? 9 | 10 | Similarly, if you’d like us to **delete or remove content**, please send us an 11 | email at [support@kaggle.com](mailto:support@kaggle.com) and we’ll delete 12 | all copies that we have and stop serving it on tfhub.dev. Please note: 13 | 14 | * Because TensorFlow Hub is an open-source platform, copies of your assets may 15 | still be retained by members of the public. 16 | * Deletion is permanent and cannot be undone. 17 | * Deletion can cause downstream breakages if users are not caching your model 18 | locally and/or are not properly warned prior to deletion. 19 | -------------------------------------------------------------------------------- /site/en/hub/publish.md: -------------------------------------------------------------------------------- 1 | 2 | # Publishing Process 3 | 4 | Thank you for considering to publish your models! 5 | 6 | **Please join the Early Access Model Publishing (EAP) on 7 | [Kaggle Models](https://www.kaggle.com/models):** 8 | 9 | - Email [kaggle-models@google.com](mailto:kaggle-models@google.com) and 10 | provide the following to get access to EAP: 11 | - (1) Your Kaggle username 12 | - (2) Your desired organization slug 13 | - (3) A URL to a square-shaped profile image (which is needed for the 14 | organization creation) 15 | - Follow the 16 | [documentation instructions](https://www.kaggle.com/model-publishing-instructions) 17 | to create and publish your model 18 | - Feel free to raise any questions and get support from 19 | [Kaggle Discord channel](https://discord.gg/rKEyxj9WF) 20 | -------------------------------------------------------------------------------- /site/en/install/_toc.yaml: -------------------------------------------------------------------------------- 1 | toc: 2 | - title: Install TensorFlow 3 | path: /install/ 4 | - heading: Packages 5 | - title: pip 6 | path: /install/pip 7 | - title: Docker 8 | path: /install/docker 9 | - heading: Additional setup 10 | - title: GPU device plugins 11 | path: /install/gpu_plugins 12 | - title: Problems 13 | path: /install/errors 14 | - heading: Build from source 15 | - title: Linux / macOS 16 | path: /install/source 17 | - title: Windows 18 | path: /install/source_windows 19 | - title: SIG Build 20 | path: https://github.com/tensorflow/build 21 | status: external 22 | - heading: Language bindings 23 | - title: Java 24 | path: /jvm/install 25 | status: external 26 | - title: Java (legacy) 27 | status: deprecated 28 | path: /install/lang_java_legacy 29 | - title: C 30 | path: /install/lang_c 31 | - title: Go 32 | path: https://github.com/tensorflow/build/tree/master/golang_install_guide 33 | status: external 34 | -------------------------------------------------------------------------------- /site/en/install/gpu_plugins.md: -------------------------------------------------------------------------------- 1 | # GPU device plugins 2 | 3 | Note: This page is for non-NVIDIA® GPU devices. For NVIDIA® GPU support, go to 4 | the [Install TensorFlow with pip](./pip.md) guide. 5 | 6 | TensorFlow's 7 | [pluggable device](https://github.com/tensorflow/community/blob/master/rfcs/20200624-pluggable-device-for-tensorflow.md) 8 | architecture adds new device support as separate plug-in packages that are 9 | installed alongside the official TensorFlow package. 10 | 11 | The mechanism requires no device-specific changes in the TensorFlow code. It 12 | relies on C APIs to communicate with the TensorFlow binary in a stable manner. 13 | Plug-in developers maintain separate code repositories and distribution packages 14 | for their plugins and are responsible for testing their devices. 15 | 16 | ## Use device plugins 17 | 18 | To use a particular device, like one would a native device in TensorFlow, users 19 | only have to install the device plug-in package for that device. The following 20 | code snippet shows how the plugin for a new demonstration device, *Awesome 21 | Processing Unit (APU)*, is installed and used. For simplicity, this sample APU 22 | plug-in only has one custom kernel for ReLU: 23 | 24 | ```sh 25 | # Install the APU example plug-in package 26 | $ pip install tensorflow-apu-0.0.1-cp36-cp36m-linux_x86_64.whl 27 | ... 28 | Successfully installed tensorflow-apu-0.0.1 29 | ``` 30 | 31 | With the plug-in installed, test that the device is visible and run an operation 32 | on the new APU device: 33 | 34 | ```python 35 | import tensorflow as tf # TensorFlow registers PluggableDevices here. 36 | tf.config.list_physical_devices() # APU device is visible to TensorFlow. 37 | [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU'), PhysicalDevice(name='/physical_device:APU:0', device_type='APU')] 38 | 39 | a = tf.random.normal(shape=[5], dtype=tf.float32) # Runs on CPU. 40 | b = tf.nn.relu(a) # Runs on APU. 41 | 42 | with tf.device("/APU:0"): # Users can also use 'with tf.device' syntax. 43 | c = tf.nn.relu(a) # Runs on APU. 44 | 45 | with tf.device("/CPU:0"): 46 | c = tf.nn.relu(a) # Runs on CPU. 47 | 48 | @tf.function # Defining a tf.function 49 | def run(): 50 | d = tf.random.uniform(shape=[100], dtype=tf.float32) # Runs on CPU. 51 | e = tf.nn.relu(d) # Runs on APU. 52 | 53 | run() # PluggableDevices also work with tf.function and graph mode. 54 | ``` 55 | 56 | ## Available devices 57 | 58 | Metal `PluggableDevice` for macOS GPUs: 59 | 60 | * Works with TF 2.5 or later. 61 | * [Getting started guide](https://developer.apple.com/metal/tensorflow-plugin/). 62 | * For questions and feedback, please visit the 63 | [Apple Developer Forum](https://developer.apple.com/forums/tags/tensorflow-metal). 64 | 65 | DirectML `PluggableDevice` for Windows and WSL (preview): 66 | 67 | * Works with `tensorflow-cpu` package, version 2.10 or later. 68 | * [PyPI wheel](https://pypi.org/project/tensorflow-directml-plugin/). 69 | * [GitHub repo](https://github.com/microsoft/tensorflow-directml-plugin). 70 | * For questions, feedback or to raise issues, please visit the 71 | [Issues page of `tensorflow-directml-plugin` on GitHub](https://github.com/microsoft/tensorflow-directml-plugin/issues). 72 | 73 | Intel® Extension for TensorFlow `PluggableDevice` for Linux and WSL: 74 | 75 | * Works with TF 2.10 or later. 76 | * [Getting started guide](https://intel.github.io/intel-extension-for-tensorflow/latest/get_started.html) 77 | * [PyPI wheel](https://pypi.org/project/intel-extension-for-tensorflow/). 78 | * [GitHub repo](https://github.com/intel/intel-extension-for-tensorflow). 79 | * For questions, feedback, or to raise issues, please visit the 80 | [Issues page of `intel-extension-for-tensorflow` on GitHub](https://github.com/intel/intel-extension-for-tensorflow/issues). 81 | -------------------------------------------------------------------------------- /site/en/r1/README.md: -------------------------------------------------------------------------------- 1 | # TensorFlow 1.x 2 | 3 | This archive of the TensorFlow 1.x docs is in *maintenance mode* only. 4 | 5 | For docs contributors, please update the source files in `site/en/` and read the 6 | [TensorFlow docs contributor guide](https://www.tensorflow.org/community/contribute/docs). 7 | 8 | For community translations, read the instructions in `site//README.md`. 9 | -------------------------------------------------------------------------------- /site/en/r1/tutorials/README.md: -------------------------------------------------------------------------------- 1 | # TensorFlow 1.x tutorials (archived) 2 | 3 | Note: Please use the latest tutorials at https://www.tensorflow.org/tutorials 4 | 5 | TensorFlow is an open-source machine learning library for research and 6 | production. TensorFlow offers APIs for beginners and experts to develop for 7 | desktop, mobile, web, and cloud. See the sections below to get started. 8 | 9 | ## Learn and use ML 10 | 11 | The high-level Keras API provides building blocks to create and 12 | train deep learning models. Start with these beginner-friendly 13 | notebook examples, then read the [TensorFlow Keras guide](https://www.tensorflow.org/guide/keras). 14 | 15 | * [Basic classification](./keras/basic_classification.ipynb) 16 | * [Text classification](./keras/basic_text_classification.ipynb) 17 | * [Regression](./keras/basic_regression.ipynb) 18 | * [Overfitting and underfitting](./keras/overfit_and_underfit.ipynb) 19 | * [Save and load](./keras/save_and_restore_models.ipynb) 20 | 21 | ```python 22 | import tensorflow as tf 23 | 24 | mnist = tf.keras.datasets.mnist 25 | 26 | (x_train, y_train),(x_test, y_test) = mnist.load_data() 27 | x_train, x_test = x_train / 255.0, x_test / 255.0 28 | 29 | model = tf.keras.models.Sequential([ 30 | tf.keras.layers.Flatten(input_shape=(28, 28)), 31 | tf.keras.layers.Dense(512, activation=tf.nn.relu), 32 | tf.keras.layers.Dropout(0.2), 33 | tf.keras.layers.Dense(10, activation=tf.nn.softmax) 34 | ]) 35 | 36 | model.compile(optimizer='adam', 37 | loss='sparse_categorical_crossentropy', 38 | metrics=['accuracy']) 39 | 40 | model.fit(x_train, y_train, epochs=5) 41 | model.evaluate(x_test, y_test) 42 | ``` 43 | 44 | Run this code in 45 | [Google's interactive notebook](https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/r1/tutorials/_index.ipynb). 46 | 47 | ## Research and experimentation 48 | 49 | Eager execution provides an imperative, define-by-run interface for advanced 50 | operations. Write custom layers, forward passes, and training loops with 51 | auto‑differentiation. Start with these notebooks, then read the 52 | [eager execution guide](../guide/eager.ipynb). 53 | 54 | * [Eager execution basics](./eager/eager_basics.ipynb) 55 | * [Automatic differentiation and gradient tape](./eager/automatic_differentiation.ipynb) 56 | * [Custom training: basics](./eager/custom_training.ipynb) 57 | * [Custom layers](./eager/custom_layers.ipynb) 58 | * [Custom training: walkthrough](./eager/custom_training_walkthrough.ipynb) 59 | 60 | ## ML at production scale 61 | 62 | Estimators can train large models on multiple machines in a production 63 | environment. TensorFlow provides a collection of pre-made Estimators to 64 | implement common ML algorithms. See the 65 | [Estimators guide](../guide/estimators.md). 66 | 67 | * [Build a linear model with Estimators](./estimators/linear.ipynb) 68 | * [Boosted trees](./estimators/boosted_trees.ipynb) 69 | * [Gradient Boosted Trees: Model understanding](./estimators/boosted_trees_model_understanding.ipynb) 70 | * [Build a Convolutional Neural Network using Estimators](./estimators/cnn.ipynb) 71 | * [Wide and deep learning with Estimators](https://github.com/tensorflow/models/tree/r1.15/official/r1/wide_deep) 72 | -------------------------------------------------------------------------------- /site/en/r1/tutorials/eager/README.md: -------------------------------------------------------------------------------- 1 | # Research and experimentation 2 | 3 | Eager execution provides an imperative, define-by-run interface for advanced 4 | operations. Write custom layers, forward passes, and training loops with 5 | auto differentiation. Start with these notebooks, then read the 6 | [eager execution guide](../../guide/eager). 7 | 8 | 1. [Eager execution](eager_basics.ipynb) 9 | 2. [Automatic differentiation and gradient tape](automatic_differentiation.ipynb) 10 | 3. [Custom training: basics](custom_training.ipynb) 11 | 4. [Custom layers](custom_layers.ipynb) 12 | 5. [Custom training: walkthrough](custom_training_walkthrough.ipynb) 13 | 14 | -------------------------------------------------------------------------------- /site/en/r1/tutorials/images/images/before_fine_tuning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/r1/tutorials/images/images/before_fine_tuning.png -------------------------------------------------------------------------------- /site/en/r1/tutorials/images/images/fine_tuning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/r1/tutorials/images/images/fine_tuning.png -------------------------------------------------------------------------------- /site/en/r1/tutorials/keras/README.md: -------------------------------------------------------------------------------- 1 | # Learn and use machine learning 2 | 3 | This notebook collection is inspired by the book 4 | *[Deep Learning with Python](https://books.google.com/books?id=Yo3CAQAACAAJ)*. 5 | These tutorials use `tf.keras`, TensorFlow's high-level Python API for building 6 | and training deep learning models. To learn more about using Keras with 7 | TensorFlow, see the [TensorFlow Keras Guide](https://www.tensorflow.org/guide/keras). 8 | 9 | Publisher's note: *Deep Learning with Python* introduces the field of deep 10 | learning using the Python language and the powerful Keras library. Written by 11 | Keras creator and Google AI researcher François Chollet, this book builds your 12 | understanding through intuitive explanations and practical examples. 13 | 14 | To learn about machine learning fundamentals and concepts, consider taking the 15 | [Machine Learning Crash Course](https://developers.google.com/machine-learning/crash-course/). 16 | 17 | 1. [Basic classification](./basic_classification.ipynb) 18 | 2. [Text classification](./basic_text_classification.ipynb) 19 | 3. [Regression](./basic_regression.ipynb) 20 | 4. [Overfitting and underfitting](./overfit_and_underfit.ipynb) 21 | 5. [Save and restore models](./save_and_restore_models.ipynb) 22 | -------------------------------------------------------------------------------- /site/en/r1/tutorials/sequences/images/text_generation_sampling.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/r1/tutorials/sequences/images/text_generation_sampling.png -------------------------------------------------------------------------------- /site/en/r1/tutorials/sequences/images/text_generation_training.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/r1/tutorials/sequences/images/text_generation_training.png -------------------------------------------------------------------------------- /site/en/tutorials/customization/images/full_network_penguin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/customization/images/full_network_penguin.png -------------------------------------------------------------------------------- /site/en/tutorials/customization/images/penguins_ds_species.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/customization/images/penguins_ds_species.png -------------------------------------------------------------------------------- /site/en/tutorials/distribute/images/tensorboard_distributed_training_with_keras.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/distribute/images/tensorboard_distributed_training_with_keras.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/Green_Sea_Turtle_grazing_seagrass.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/Green_Sea_Turtle_grazing_seagrass.jpg -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/adversarial_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/adversarial_example.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/cvae_latent_space.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/cvae_latent_space.jpg -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/cycle_loss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/cycle_loss.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/cyclegan_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/cyclegan_model.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/dis.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/dis.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/dogception.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/dogception.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/gan1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/gan1.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/gan2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/gan2.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/gan_diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/gan_diagram.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/gen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/gen.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/horse2zebra_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/horse2zebra_1.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/horse2zebra_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/horse2zebra_2.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/image_denoise_fmnist_results.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/image_denoise_fmnist_results.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/intro_autoencoder_result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/intro_autoencoder_result.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/kadinsky-turtle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/kadinsky-turtle.png -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/kadinsky.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/kadinsky.jpg -------------------------------------------------------------------------------- /site/en/tutorials/generative/images/stylized-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/generative/images/stylized-image.png -------------------------------------------------------------------------------- /site/en/tutorials/images/images/before_fine_tuning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/images/images/before_fine_tuning.png -------------------------------------------------------------------------------- /site/en/tutorials/images/images/fine_tuning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/images/images/fine_tuning.png -------------------------------------------------------------------------------- /site/en/tutorials/images/images/tensorboard_transfer_learning_with_hub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/images/images/tensorboard_transfer_learning_with_hub.png -------------------------------------------------------------------------------- /site/en/tutorials/interpretability/images/IG_fireboat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/interpretability/images/IG_fireboat.png -------------------------------------------------------------------------------- /site/en/tutorials/load_data/images/csv/Titanic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/load_data/images/csv/Titanic.jpg -------------------------------------------------------------------------------- /site/en/tutorials/load_data/images/csv/fonts.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/load_data/images/csv/fonts.jpg -------------------------------------------------------------------------------- /site/en/tutorials/load_data/images/csv/traffic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/load_data/images/csv/traffic.jpg -------------------------------------------------------------------------------- /site/en/tutorials/quickstart/images/beginner/run_cell_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/quickstart/images/beginner/run_cell_icon.png -------------------------------------------------------------------------------- /site/en/tutorials/reinforcement_learning/images/cartpole-v0.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/reinforcement_learning/images/cartpole-v0.gif -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/baseline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/baseline.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/conv_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/conv_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/last_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/last_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/lstm_1_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/lstm_1_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/lstm_many_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/lstm_many_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/multistep_autoregressive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/multistep_autoregressive.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/multistep_conv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/multistep_conv.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/multistep_dense.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/multistep_dense.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/multistep_last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/multistep_last.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/multistep_lstm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/multistep_lstm.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/multistep_repeat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/multistep_repeat.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/narrow_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/narrow_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/raw_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/raw_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/raw_window_1h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/raw_window_1h.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/raw_window_24h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/raw_window_24h.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/residual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/residual.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/split_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/split_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/wide_conv_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/wide_conv_window.png -------------------------------------------------------------------------------- /site/en/tutorials/structured_data/images/wide_window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/structured_data/images/wide_window.png -------------------------------------------------------------------------------- /site/en/tutorials/tensorflow_text/README.md: -------------------------------------------------------------------------------- 1 | Welcome to the warp zone! 2 | 3 | # TensorFlow Text: Text processing in Tensorflow 4 | 5 | These docs are available here: https://github.com/tensorflow/text/tree/master/examples 6 | -------------------------------------------------------------------------------- /site/en/tutorials/understanding/images/sngp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tensorflow/docs/a85e05593b485171c388df1a45b6da668edc39e7/site/en/tutorials/understanding/images/sngp.png -------------------------------------------------------------------------------- /tools/linkcheckerrc: -------------------------------------------------------------------------------- 1 | # linkchecker config for tensorflow.org 2 | # Usage (include trailing slash): 3 | # $ linkchecker -f tools/linkcheckerrc https://www.tensorflow.org/{subsite}/ 4 | # Docs: 5 | # - https://wummel.github.io/linkchecker/man5/linkcheckerrc.5.html 6 | # - https://github.com/wummel/linkchecker/blob/master/config/linkcheckerrc 7 | 8 | [checking] 9 | #pause=1 10 | 11 | [filtering] 12 | 13 | # Check external URLs 14 | checkextern=1 15 | 16 | ignore = 17 | .*?(fonts|gstatic|medium).* 18 | http://developers.google.com/ReferenceObject 19 | -------------------------------------------------------------------------------- /tools/release_tools/push_version_to_github.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Run this from your github clone. 3 | # It assumes you have tensorflow_docs as the "upstream" remote. 4 | 5 | OLD_BRANCH=$1 6 | NEW_BRANCH=$2 7 | 8 | if [ -n "$OLD_BRANCH" ]; then 9 | echo "OLD_BRANCH=$OLD_BRANCH" 10 | else 11 | echo '$OLD_BRANCH is unset' && exit; 12 | fi 13 | 14 | if [ -n "$NEW_BRANCH" ]; then 15 | echo "NEW_BRANCH=$NEW_BRANCH" 16 | else 17 | echo '$NEW_BRANCH is unset' && exit 18 | fi 19 | 20 | # Print commands while running, and fail if a command fails 21 | set -e 22 | set -x 23 | 24 | # Merge the previous releases's docs into the current. 25 | git checkout master 26 | git pull upstream master 27 | 28 | git fetch upstream 29 | git branch -D $NEW_BRANCH || echo "failed -> branch doesn't exist -> that\'s ok" 30 | # Checkout the upstream branch, if it doesn't exist create it from master 31 | git checkout --track upstream/"$NEW_BRANCH" || (git checkout -b "$NEW_BRANCH") 32 | # Merge the previous version. If that gives a merge-conflict, auto-resolve and commit. 33 | git merge upstream/$OLD_BRANCH --message "merge $OLD_BRANCH" || (grep -l "<<<<<<<" -r | xargs git checkout --ours && git commit -am "merge $OLD_BRANCH") 34 | 35 | # Overwrite the ditectory with the contents from tensorflow/en/versions 36 | rm -rf site/en/api_docs/python 37 | python ../tensorflow/tensorflow/tools/docs/generate2.py --output_dir=site/en/api_docs/python --code_url_prefix="https://github.com/tensorflow/tensorflow/blob/${NEW_BRANCH}/tensorflow" 38 | 39 | # Commit and push to your github. 40 | git add site/en/api_docs/ 41 | git commit -am "Update docs to $NEW_BRANCH" 42 | git push -f origin $NEW_BRANCH 43 | -------------------------------------------------------------------------------- /tools/release_tools/update_versions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Update tensorflow version in docs. Run this from the repo-root.""" 16 | import argparse 17 | import re 18 | 19 | try: 20 | import pathlib2 as pathlib 21 | except ImportError: 22 | import pathlib 23 | 24 | 25 | EXTS = [".ipynb",".md",".yaml",".html"] 26 | EXPAND_TABLES = [ 27 | "source_windows.md", 28 | "source.md",] 29 | 30 | class Version(object): 31 | def __init__(self, in_string): 32 | self.major, self.minor, self.patch = in_string.split(".") 33 | assert self.major.isdigit() 34 | assert self.minor.isdigit() 35 | assert self.patch.isdigit() 36 | 37 | def full(self): 38 | return ".".join([self.major, self.minor, self.patch]) 39 | 40 | def short(self): 41 | return ".".join([self.major, self.minor]) 42 | 43 | 44 | parser = argparse.ArgumentParser() 45 | parser.add_argument("--old_version", type=Version, required=True, 46 | help="The old version to replace") 47 | parser.add_argument("--new_version", type=Version, required=True, 48 | help="The new version to replace it with") 49 | 50 | if __name__=="__main__": 51 | args = parser.parse_args() 52 | 53 | for ext in EXTS: 54 | for file_path in pathlib.Path(".").rglob("*"+ext): 55 | content = file_path.read_text() 56 | if file_path.name in EXPAND_TABLES: 57 | content = re.sub("(.*?){}(.*?)".format(re.escape(args.old_version.short())), 58 | r"\g<1>{}\g<2>\n\g<0>".format(args.new_version.short()), content) 59 | file_path.write_text(content) 60 | continue 61 | 62 | content = file_path.read_text() 63 | 64 | content = content.replace(args.old_version.full(), args.new_version.full()) 65 | content = content.replace("github.com/tensorflow/tensorflow/blob/r"+args.old_version.short(), 66 | "github.com/tensorflow/tensorflow/blob/r"+args.old_version.short()) 67 | file_path.write_text(content) 68 | -------------------------------------------------------------------------------- /tools/spelltest/tmpl/html.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'full.tpl' -%} 2 | 3 | {# Do not print input/code cells #} 4 | {% block input_group -%} 5 | {% endblock input_group %} 6 | -------------------------------------------------------------------------------- /tools/spelltest/tmpl/md.tpl: -------------------------------------------------------------------------------- 1 | {%- extends 'markdown.tpl' -%} 2 | 3 | {# Do not print input/code cells #} 4 | {% block input_group -%} 5 | {% endblock input_group %} 6 | -------------------------------------------------------------------------------- /tools/spelltest/wordlist.txt: -------------------------------------------------------------------------------- 1 | ansatz 2 | APIs 3 | autoencoder 4 | backend 5 | backpropagation 6 | bazel 7 | bfloat 8 | bytecode 9 | CIFAR 10 | Cirq 11 | Colab 12 | Colaboratory 13 | convolutional 14 | CPUs 15 | CSV 16 | CUDA 17 | datapoints 18 | dataset 19 | datasets 20 | differentiator 21 | differentiators 22 | dtype 23 | eigensolver 24 | eigenstate 25 | eigenstates 26 | excitations 27 | GHZ 28 | GPU 29 | GPUs 30 | ImageNet 31 | initializer 32 | JSON 33 | Keras 34 | learnable 35 | LSTM 36 | manylinux 37 | MERA 38 | MNIST 39 | NaNs 40 | NISQ 41 | NumPy 42 | observables 43 | optimizer 44 | perceptron 45 | prepend 46 | preprocess 47 | pseudocode 48 | PyPI 49 | QCNN 50 | QNN 51 | QNNs 52 | qubit 53 | qubits 54 | quickstart 55 | ResNet 56 | RNN 57 | runnable 58 | runtime 59 | SavedModel 60 | sigmoid 61 | softmax 62 | subsampling 63 | TensorBoard 64 | TensorFlow 65 | TFQ 66 | TPU 67 | TPUs 68 | translationally 69 | VAE 70 | variational 71 | VGG 72 | VQE 73 | XLA 74 | -------------------------------------------------------------------------------- /tools/templates/build_docs.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | r"""Example api reference docs generation script. 16 | 17 | This script generates API reference docs for the reference doc generator. 18 | 19 | $> pip install -U git+https://github.com/tensorflow/docs 20 | $> python build_docs.py 21 | """ 22 | 23 | import os 24 | 25 | from absl import app 26 | from absl import flags 27 | 28 | import tensorflow_docs.api_generator 29 | from tensorflow_docs.api_generator import generate_lib 30 | from tensorflow_docs.api_generator import public_api 31 | 32 | PROJECT_SHORT_NAME = 'tfdocs' 33 | PROJECT_FULL_NAME = 'TensorFlow Docs' 34 | 35 | _OUTPUT_DIR = flags.DEFINE_string( 36 | 'output_dir', 37 | default='/tmp/generated_docs', 38 | help='Where to write the resulting docs to.') 39 | 40 | _URL_PREFIX = flags.DEFINE_string( 41 | 'code_url_prefix', 'https://github.com/tensorflow/docs/tree/master/tools/tensorflow_docs', 42 | 'The url prefix for links to code.') 43 | 44 | _SEARCH_HINTS = flags.DEFINE_bool( 45 | 'search_hints', True, 46 | 'Include metadata search hints in the generated files') 47 | 48 | _SITE_PATH = flags.DEFINE_string('site_path', '/api_docs/python', 49 | 'Path prefix in the _toc.yaml') 50 | 51 | 52 | def gen_api_docs(): 53 | """Generates api docs for the tensorflow docs package.""" 54 | 55 | # The below `del`'s are to avoid the api_gen_test to not document these. 56 | # Please remove these lines from your build_docs.py files when you create 57 | # them. 58 | try: 59 | del tensorflow_docs.google 60 | except AttributeError: 61 | pass 62 | 63 | try: 64 | del tensorflow_docs.api_generator.report.schema 65 | except AttributeError: 66 | pass 67 | 68 | doc_generator = generate_lib.DocGenerator( 69 | root_title=PROJECT_FULL_NAME, 70 | # Replace `tensorflow_docs.api_generator` with your module, here. 71 | py_modules=[(PROJECT_SHORT_NAME, tensorflow_docs.api_generator)], 72 | # Replace `tensorflow_docs.api_generator` with your module, here. 73 | base_dir=os.path.dirname(tensorflow_docs.api_generator.__file__), 74 | code_url_prefix=_URL_PREFIX.value, 75 | search_hints=_SEARCH_HINTS.value, 76 | site_path=_SITE_PATH.value, 77 | # This callback ensures that docs are only generated for objects that 78 | # are explicitly imported in your __init__.py files. There are other 79 | # options but this is a good starting point. 80 | callbacks=[public_api.explicit_package_contents_filter], 81 | ) 82 | 83 | doc_generator.build(_OUTPUT_DIR.value) 84 | 85 | print('Output docs to: ', _OUTPUT_DIR.value) 86 | 87 | 88 | def main(_): 89 | gen_api_docs() 90 | 91 | 92 | if __name__ == '__main__': 93 | app.run(main) 94 | -------------------------------------------------------------------------------- /tools/templates/subsite/README.md: -------------------------------------------------------------------------------- 1 | # Subsite projects 2 | 3 | Subsite projects are sections of the 4 | [tensorflow.org](https://www.tensorflow.org) website that *do not* live in the 5 | [tensorflow/docs](https://github.com/tensorflow/docs) repo. Instead, the project 6 | docs live with the code in the project repo. Some example subsites: 7 | 8 | * [TensorFlow Probability](https://www.tensorflow.org/probability/) 9 | [[tensorflow/probability](https://github.com/tensorflow/probability)] 10 | * [TensorFlow Serving](https://www.tensorflow.org/serving/) 11 | [[tensorflow/serving](https://github.com/tensorflow/serving)] 12 | 13 | Documentation changes are submitted to the project repo and *not* the 14 | tensorflow/docs repo. Guides can be Markdown files or Colab/Jupyter notebooks. 15 | 16 | ## Set up the base template for the subsite project 17 | 18 | 1. Copy the `tools/templates/subsite/g3doc` directory from the docs repo to the 19 | project repo: 20 | 21 | ``` 22 | $ cp -r tensorflow/docs/tools/templates/subsite/g3doc tensorflow/myproject/ 23 | ``` 24 | 25 | In GitHub, you may rename the project's `/g3doc` directory to `/docs`. 26 | 27 | 2. In the project's `g3doc/` directory, replace `PROJECT_NAME` in each template 28 | file with the *short name* of the project. This is used for the project URL, 29 | for example, `https://www.tensorflow.org/myproject`: 30 | 31 | ``` 32 | $ find tensorflow/myproject/g3doc/ -type f | xargs sed -i 's/PROJECT_NAME/myproject/g' 33 | ``` 34 | 35 | ## Update the configuration files 36 | 37 | 1. The `_book.yaml` file configures the lower tabs and left navigation for 38 | files. Each page must have an entry in `_book.yaml` to be navigable on 39 | [tensorflow.org](https://www.tensorflow.org). 40 | 2. The TensorFlow docs team must set up a project file. 41 | 42 | Changes to `.yaml` files must be approved by the TensorFlow docs team. 43 | 44 | 45 | 46 | ## Set up the API generator for reference docs 47 | 48 | To build reference docs for the project, write a `build_docs.py` script using the 49 | [api_generator](https://github.com/tensorflow/docs/tree/master/tools/tensorflow_docs/api_generator) 50 | API. The best way to do this is to look at examples from other subsite projects. 51 | 52 | If the project does not have an API reference, remove this navigation section 53 | from the `_book.yaml` file. 54 | 55 | ## Create a link to your project docs 56 | 57 | To make it easier for contributors to find your doc set, add a project entry to 58 | [tensorflow/docs/site/en](https://github.com/tensorflow/docs/blob/master/g3doc/en/) 59 | and include a `README.md` file with a link. For example, 60 | [site/en/probability/](https://github.com/tensorflow/docs/blob/master/g3doc/en/probability/). 61 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/_book.yaml: -------------------------------------------------------------------------------- 1 | upper_tabs: 2 | # Tabs left of dropdown menu 3 | - include: /_upper_tabs_left.yaml 4 | - include: /api_docs/_upper_tabs_api.yaml 5 | # Dropdown menu 6 | - name: Resources 7 | path: /resources 8 | is_default: true 9 | menu: 10 | - include: /resources/_menu_toc.yaml 11 | lower_tabs: 12 | # Subsite tabs 13 | other: 14 | - name: Tutorials 15 | contents: 16 | - title: Tutorials overview 17 | path: /{PROJECT_NAME}/tutorials/ 18 | - title: Foo tutorial 19 | path: /{PROJECT_NAME}/tutorials/foo_tutorial 20 | # - title: Notebook tutorial 21 | # path: /{PROJECT_NAME}/tutorials/notebook 22 | - name: Guide 23 | contents: 24 | - title: Guide overview 25 | path: /{PROJECT_NAME}/overview 26 | - title: Bar guide 27 | path: /{PROJECT_NAME}/bar_guide 28 | - name: Examples 29 | contents: 30 | - title: Examples overview 31 | path: /{PROJECT_NAME}/examples/ 32 | - title: Baz example 33 | path: /{PROJECT_NAME}/examples/baz_example 34 | - name: API 35 | skip_translation: true 36 | contents: 37 | - title: All Symbols 38 | path: /{PROJECT_NAME}/api_docs/python/{SHORT_NAME}/all_symbols 39 | - include: /{PROJECT_NAME}/api_docs/python/{SHORT_NAME}/_toc.yaml 40 | 41 | - include: /_upper_tabs_right.yaml 42 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/_index.yaml: -------------------------------------------------------------------------------- 1 | book_path: /PROJECT_NAME/_book.yaml 2 | project_path: /PROJECT_NAME/_project.yaml 3 | description: > 4 | Page description used for search and social. 5 | landing_page: 6 | custom_css_path: /site-assets/css/style.css 7 | rows: 8 | - heading: PROJECT_NAME does something great. 9 | items: 10 | - classname: devsite-landing-row-50 11 | description: > 12 | This is a description of PROJECT_NAME. Lorem ipsum dolor sit amet, 13 | consectetur adipiscing elit, sed do eiusmod tempor incididunt ut 14 | labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud 15 | exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 16 | 17 | code_block: | 18 |
19 |         import tensorflow as tf
20 |         import PROJECT_NAME
21 | 
22 |         # This is a short code snippet that shows off your project.
23 |         # Launch a Colab notebook to run this example.
24 |         print("Hello, PROJECT_NAME")
25 |         
26 | {% dynamic if request.tld != 'cn' %} 27 | Run in a Notebook 28 | {% dynamic endif %} 29 | 30 | - classname: devsite-landing-row-cards 31 | items: 32 | - heading: "Introducing PROJECT_NAME" 33 | image_path: /resources/images/tf-logo-card-16x9.png 34 | path: https://blog.tensorflow.org 35 | buttons: 36 | - label: "Read on TensorFlow blog" 37 | path: https://blog.tensorflow.org 38 | - heading: "PROJECT_NAME video" 39 | youtube_id: 3d34Hkf7KXA 40 | buttons: 41 | - label: Watch the video 42 | path: https://www.youtube.com/watch?v=3d34Hkf7KXA 43 | - heading: "PROJECT_NAME on GitHub" 44 | image_path: /resources/images/github-card-16x9.png 45 | path: https://github.com/tensorflow/PROJECT_NAME 46 | buttons: 47 | - label: "View on GitHub" 48 | path: https://github.com/tensorflow/PROJECT_NAME 49 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/api_docs/README.md: -------------------------------------------------------------------------------- 1 | # API reference 2 | 3 | Create a `build_docs.py` script using the `api_generator` API: 4 | https://github.com/tensorflow/docs/tree/master/tools/tensorflow_docs/api_generator 5 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/api_docs/python/_toc.yaml: -------------------------------------------------------------------------------- 1 | # This file will be automatically generated when the API generator is configured 2 | toc: 3 | - title: PROJECT_NAME 4 | section: 5 | - title: Overview 6 | path: /PROJECT_NAME/api_docs/python/ 7 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/api_docs/python/index.md: -------------------------------------------------------------------------------- 1 | # API reference 2 | 3 | This section will be generated when the 4 | [api_generator](https://github.com/tensorflow/docs/tree/master/tools/tensorflow_docs/api_generator) 5 | is configured. 6 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/bar_guide.md: -------------------------------------------------------------------------------- 1 | # Bar guide 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/examples/baz_example.md: -------------------------------------------------------------------------------- 1 | # Baz example 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/examples/index.md: -------------------------------------------------------------------------------- 1 | # PROJECT_NAME examples 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/overview.md: -------------------------------------------------------------------------------- 1 | # PROJECT_NAME overview 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/tutorials/foo_tutorial.md: -------------------------------------------------------------------------------- 1 | # Foo tutorial 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/tutorials/index.md: -------------------------------------------------------------------------------- 1 | # PROJECT_NAME tutorials 2 | 3 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. 4 | -------------------------------------------------------------------------------- /tools/templates/subsite/g3doc/tutorials/notebook.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "id": "Tce3stUlHN0L" 7 | }, 8 | "source": [ 9 | "##### Copyright 2018 The TensorFlow Authors.\n" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": { 16 | "cellView": "form", 17 | "id": "tuOe1ymfHZPu" 18 | }, 19 | "outputs": [], 20 | "source": [ 21 | "#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n", 22 | "# you may not use this file except in compliance with the License.\n", 23 | "# You may obtain a copy of the License at\n", 24 | "#\n", 25 | "# https://www.apache.org/licenses/LICENSE-2.0\n", 26 | "#\n", 27 | "# Unless required by applicable law or agreed to in writing, software\n", 28 | "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", 29 | "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", 30 | "# See the License for the specific language governing permissions and\n", 31 | "# limitations under the License." 32 | ] 33 | }, 34 | { 35 | "cell_type": "markdown", 36 | "metadata": { 37 | "id": "s7Bo2MipUnXX" 38 | }, 39 | "source": [ 40 | "# Sample tutorial or guide" 41 | ] 42 | }, 43 | { 44 | "cell_type": "markdown", 45 | "metadata": { 46 | "id": "Birwb-khUOIq" 47 | }, 48 | "source": [ 49 | "\n", 50 | " \n", 53 | " \n", 56 | " \n", 59 | " \n", 62 | "
\n", 51 | " View on TensorFlow.org\n", 52 | " \n", 54 | " Run in Google Colab\n", 55 | " \n", 57 | " View source on GitHub\n", 58 | " \n", 60 | " Download notebook\n", 61 | "
" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": { 68 | "id": "xHxb-dlhMIzW" 69 | }, 70 | "source": [ 71 | "[Colab notebooks](https://colab.research.google.com/notebooks/welcome.ipynb) are a first-class documentation format on [tensorflow.org](https://www.tensorflow.org). When published, these notebooks are rendered as static HTML on the site, with a link to the executable notebook on Colab.\n", 72 | "\n", 73 | "See the [notebook template](https://github.com/tensorflow/docs/blob/master/tools/templates/notebook.ipynb) for setup and style notes." 74 | ] 75 | } 76 | ], 77 | "metadata": { 78 | "colab": { 79 | "collapsed_sections": [ 80 | "Tce3stUlHN0L" 81 | ], 82 | "name": "notebook.ipynb", 83 | "toc_visible": true 84 | }, 85 | "kernelspec": { 86 | "display_name": "Python 3", 87 | "name": "python3" 88 | } 89 | }, 90 | "nbformat": 4, 91 | "nbformat_minor": 0 92 | } 93 | -------------------------------------------------------------------------------- /tools/templates/tflite_model_page_template.md: -------------------------------------------------------------------------------- 1 | # Title (ML Task) 2 | 3 | Short description of ML Task. Link off to relevant content on the TF docs for 4 | background info. 5 | 6 | ## Get started 7 | 8 | Image of model output (preferably GIFs) 9 | 10 | 11 | 12 | If you are new to TensorFlow Lite and are working with Android or iOS, we 13 | recommend exploring the following example applications that can help you get 14 | started. 15 | 16 | Download 17 | Android model 18 | Download 19 | iOS model 20 | 21 | If you are using a platform other than Android/iOS, or if you are already 22 | familiar with the 23 | [TensorFlow Lite APIs](https://www.tensorflow.org/api_docs/python/tf/lite), 24 | download the starter model and supporting files (if applicable). 25 | 26 | Download 27 | starter model 28 | 29 | ## Model description 30 | 31 | In this section, include content about: 32 | 33 | ### How it works 34 | 35 | * How does the model work? Provide usage instructions with examples as appropriate. 36 | 37 | 38 | ### Inputs 39 | 40 | * Which format does the model expect inputs in? 41 | * How can the user convert inputs of a certain type into a compatible format? 42 | 43 | ### Outputs 44 | 45 | * How does the user interpret the model results? 46 | 47 | ### Limitations 48 | 49 | * What can the user *not* do with the model? 50 | 51 | ## Model customization 52 | 53 | * How can the user customize this model to work with their datasets? 54 | 55 | ## Performance benchmarks 56 | 57 | ## Further reading and resources 58 | 59 | * Academic paper (if applicable) 60 | * Use cases 61 | * Other resources 62 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """tensorflow_docs is a package for generating python api-reference docs.""" 16 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Tools for building tensorflow api reference docs.""" 16 | 17 | from tensorflow_docs.api_generator import doc_controls 18 | from tensorflow_docs.api_generator import doc_generator_visitor 19 | from tensorflow_docs.api_generator import generate_lib 20 | from tensorflow_docs.api_generator import parser 21 | from tensorflow_docs.api_generator import toc_processing 22 | from tensorflow_docs.api_generator import public_api 23 | from tensorflow_docs.api_generator import traverse 24 | from tensorflow_docs.api_generator import utils 25 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/compat_test/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """This is a test module. 16 | 17 | @compatibility(TF2) 18 | test 19 | @end_compatibility 20 | 21 | Hello 22 | """ 23 | 24 | from tensorflow_docs.api_generator.compat_test import estimator 25 | 26 | 27 | def a_function(x, y): 28 | """This is a function. 29 | 30 | @compatibility(TF2) 31 | test 32 | @end_compatibility 33 | 34 | @compatibility(numpy) 35 | test 36 | @end_compatibility 37 | 38 | It does things. 39 | 40 | Args: 41 | x: x 42 | y: y 43 | 44 | Returns: 45 | None 46 | """ 47 | del x 48 | del y 49 | return None 50 | 51 | 52 | class AClass: 53 | """This is a class. 54 | 55 | @compatibility(TF2) 56 | test 57 | @end_compatibility 58 | 59 | It does things too. 60 | 61 | Attributes: 62 | x: x 63 | y: x 64 | """ 65 | 66 | def __init__(self, x, y): 67 | self.x = x 68 | self.y = y 69 | 70 | def a_method(self, x, y): 71 | """Methods can have compatibility notes too. 72 | 73 | @compatibility(TF2) 74 | test 75 | @end_compatibility 76 | 77 | It does things too. 78 | 79 | Args: 80 | x: x 81 | y: y 82 | 83 | Returns: 84 | None 85 | """ 86 | del x 87 | del y 88 | return None 89 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/compat_test/estimator.py: -------------------------------------------------------------------------------- 1 | # Copyright 2017 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """This is a test module. 16 | 17 | @compatibility(TF2) 18 | test 19 | @end_compatibility 20 | 21 | Hello 22 | """ 23 | 24 | 25 | def a_function(x, y): 26 | """This is a function. 27 | 28 | @compatibility(TF2) 29 | test 30 | @end_compatibility 31 | 32 | @compatibility(numpy) 33 | test 34 | @end_compatibility 35 | 36 | It does things. 37 | 38 | Args: 39 | x: x 40 | y: y 41 | 42 | Returns: 43 | None 44 | """ 45 | del x 46 | del y 47 | return None 48 | 49 | 50 | class AClass: 51 | """This is a class. 52 | 53 | @compatibility(TF2) 54 | test 55 | @end_compatibility 56 | 57 | It does things too. 58 | 59 | Attributes: 60 | x: x 61 | y: x 62 | """ 63 | 64 | def __init__(self, x, y): 65 | self.x = x 66 | self.y = y 67 | 68 | def a_method(self, x, y): 69 | """Methods can have compatibility notes too. 70 | 71 | @compatibility(TF2) 72 | test 73 | @end_compatibility 74 | 75 | It does things too. 76 | 77 | Args: 78 | x: x 79 | y: y 80 | 81 | Returns: 82 | None 83 | """ 84 | del x 85 | del y 86 | return None 87 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/config.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """The `ParserConfig` contains the information extracted by walking the API.""" 16 | 17 | class ParserConfig(object): 18 | """Stores all indexes required to parse the docs.""" 19 | 20 | def __init__( 21 | self, 22 | *, 23 | reference_resolver, 24 | duplicates, 25 | duplicate_of, 26 | tree, 27 | index, 28 | reverse_index, 29 | path_tree, 30 | api_tree, 31 | base_dir, 32 | code_url_prefix, 33 | self_link_base 34 | ): 35 | """Object with the common config for docs_for_object() calls. 36 | 37 | Args: 38 | reference_resolver: An instance of ReferenceResolver. 39 | duplicates: A `dict` mapping fully qualified names to a set of all aliases 40 | of this name. This is used to automatically generate a list of all 41 | aliases for each name. 42 | duplicate_of: A map from duplicate names to preferred names of API 43 | symbols. 44 | tree: A `dict` mapping a fully qualified name to the names of all its 45 | members. Used to populate the members section of a class or module page. 46 | index: A `dict` mapping full names to objects. 47 | reverse_index: A `dict` mapping object ids to full names. 48 | path_tree: A PathTree datastructure to manage all the API paths. 49 | api_tree: A PathTree datastructure to manage all the API objects. 50 | base_dir: A base path that is stripped from file locations written to the 51 | docs. 52 | code_url_prefix: A Url to pre-pend to the links to file locations. 53 | self_link_base: A Url to pre-pend to self-links to the generated docs 54 | pages. 55 | """ 56 | self.reference_resolver = reference_resolver 57 | self.duplicates = duplicates 58 | self.duplicate_of = duplicate_of 59 | self.tree = tree 60 | self.reverse_index = reverse_index 61 | self.index = index 62 | self.path_tree = path_tree 63 | self.api_tree = api_tree 64 | self.base_dir = base_dir 65 | self.code_url_prefix = code_url_prefix 66 | self.self_link_base = self_link_base 67 | 68 | def py_name_to_object(self, full_name): 69 | """Return the Python object for a Python symbol name.""" 70 | return self.index[full_name] 71 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Generate javadoc-doclava reference docs for tensorflow.org.""" 16 | 17 | import os 18 | import pathlib 19 | import subprocess 20 | from typing import Iterable, Mapping, Optional, Union 21 | 22 | from tensorflow_docs.api_generator import toc_processing 23 | 24 | import yaml 25 | 26 | 27 | class Formatter(yaml.dumper.Dumper): 28 | pass 29 | 30 | 31 | def _dict_representer(dumper, data): 32 | """Force yaml to output dictionaries in order, not alphabetically.""" 33 | return dumper.represent_dict(data.items()) 34 | 35 | 36 | Formatter.add_representer(dict, _dict_representer) 37 | 38 | # __file__ is the path to this file 39 | GEN_JAVA_DIR = pathlib.Path(__file__).resolve().parent 40 | 41 | TEMPLATES = GEN_JAVA_DIR / 'templates' 42 | DOCLAVA_FOR_TF = GEN_JAVA_DIR / 'run-javadoc-for-tf.sh' 43 | 44 | 45 | def gen_java_docs( 46 | package: Union[str, Iterable[str]], 47 | source_path: pathlib.Path, 48 | output_dir: pathlib.Path, 49 | site_path: pathlib.Path, 50 | script_path: pathlib.Path = DOCLAVA_FOR_TF, 51 | section_labels: Optional[Mapping[str, str]] = None, 52 | federated_docs: Optional[Mapping[str, pathlib.Path]] = None, 53 | ) -> None: 54 | """Generate tensorflow.org java-docs for `package`.""" 55 | fed_paths = list(federated_docs.values()) if federated_docs else [] 56 | for path in [source_path, output_dir, script_path, TEMPLATES] + fed_paths: 57 | assert path.is_absolute(), 'All paths used in doc-gen must be absolute' 58 | 59 | if federated_docs: 60 | os.environ['FEDERATED_DOCS'] = ' '.join( 61 | [f'{url},{file}' for url, file in federated_docs.items()]) 62 | 63 | if isinstance(package, str): 64 | os.environ['PACKAGE'] = package 65 | root_pkgs = [package] 66 | else: 67 | os.environ['PACKAGE'] = ' '.join(package) 68 | root_pkgs = package 69 | 70 | os.environ['SOURCE_PATH'] = str(source_path) 71 | os.environ['OUTPUT_DIR'] = str(output_dir) 72 | os.environ['SITE_PATH'] = str(pathlib.Path('/') / site_path) 73 | os.environ['TEMPLATES'] = str(TEMPLATES) 74 | subprocess.check_call(['bash', script_path]) 75 | 76 | yaml_path = pathlib.Path(output_dir) / '_toc.yaml' 77 | yaml_content = yaml_path.read_text() 78 | yaml_data = yaml.safe_load(yaml_content) 79 | if section_labels: 80 | yaml_data = toc_processing.add_package_headings(yaml_data, root_pkgs, 81 | section_labels) 82 | yaml_content = yaml.dump(yaml_data, Dumper=Formatter) 83 | yaml_path.write_text(yaml_content) 84 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/run-javadoc-for-tf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | # https://android.googlesource.com/platform/external/doclava/ 5 | # There's a debian package: 6 | # https://packages.debian.org/unstable/doclava-aosp 7 | # Install with: 8 | # 9 | # $ sudo apt install doclava-aosp #v 6.0.1+r55-1+build1 10 | # 11 | # https://unix.stackexchange.com/questions/594841/how-do-i-assign-a-value-to-a-bash-variable-iff-that-variable-is-null-unassigned 12 | DOCLAVA_JAR=${DOCLAVA_JAR:-'/usr/share/java/doclava.jar'} 13 | 14 | # Install java clear silver templates with: 15 | # 16 | # $ sudo apt install libjsilver-aosp-java #v 6.0.1+r55-1+build1 17 | JSILVER_JAR=${JSILVER_JAR:-'/usr/share/java/jsilver.jar'} 18 | 19 | 20 | ######### DELETE OUTPUT_DIR ################# 21 | 22 | # Empty the output directory in case a class has been deleted 23 | rm -rf "${OUTPUT_DIR:?}"/* 24 | ############ RUN DOCLAVA ################### 25 | 26 | # $FEDERATED_DOCS is a space-separated string of url,file pairs. 27 | read -a api_pairs <<< "${FEDERATED_DOCS}" 28 | FEDERATED_PARAMS="" 29 | for i in "${!api_pairs[@]}"; do 30 | api_pair_str="${api_pairs[$i]}" # "url,api.txt" 31 | read -a api_pair <<< "${api_pair_str//,/ }" 32 | # Using the index as the API "name", build the federation params. Note that 33 | # using 0 as an API name will evaluate to false and cause rendering bugs, 34 | # so we preface with "api_". 35 | FEDERATED_PARAMS+=" -federate api_${i} ${api_pair[0]}" 36 | FEDERATED_PARAMS+=" -federationapi api_${i} ${api_pair[1]}" 37 | done 38 | 39 | # To install javadoc, for example, use 40 | # 41 | # sudo apt install openjdk-11-jdk 42 | # 43 | # doclava doesn't work with openjdk-13 44 | # ``` 45 | # javadoc: error - Class com.google.doclava.Doclava is not a valid doclet. 46 | # Note: As of JDK 13, the com.sun.javadoc API is no longer supported. 47 | # ``` 48 | # It's used here: https://android.googlesource.com/platform/external/doclava/+/refs/heads/master/src/com/google/doclava/Doclava.java 49 | 50 | # Each package in $PACKAGE needs to prefaced with -subpackages, so do that. 51 | SUBPACKAGES="" 52 | read -r -a packages <<< "${PACKAGE}" 53 | for pkg in "${packages[@]}"; do 54 | SUBPACKAGES+=" -subpackages ${pkg}" 55 | done 56 | ( # Capture the return code. it may be non-zero for minor errors. 57 | javadoc \ 58 | -sourcepath "${SOURCE_PATH}" \ 59 | -docletpath "${DOCLAVA_JAR}:${JSILVER_JAR}" \ 60 | -doclet com.google.doclava.Doclava \ 61 | -d "${OUTPUT_DIR}" \ 62 | -toroot "${SITE_PATH}"/ \ 63 | -yaml _toc.yaml \ 64 | -templatedir "${TEMPLATES}" \ 65 | -public \ 66 | -devsite \ 67 | ${FEDERATED_PARAMS} \ 68 | ${SUBPACKAGES} 69 | ) 70 | 71 | 72 | mv "${OUTPUT_DIR}"/reference/* "${OUTPUT_DIR}" 73 | 74 | ################################################################### 75 | ################### START OF POST-PROCESSING ###################### 76 | ################################################################### 77 | rm "${OUTPUT_DIR}/navtree_data.js" || true 78 | rm "${OUTPUT_DIR}/hierarchy.html" || true 79 | 80 | find ${OUTPUT_DIR} -name "*.html" | xargs sed --in-place "s|${SITE_PATH}/reference|${SITE_PATH}|g" 81 | find ${OUTPUT_DIR} -name "*.yaml" | xargs sed --in-place "s|${SITE_PATH}/reference|${SITE_PATH}|g" 82 | find ${OUTPUT_DIR} -name "*.html" | xargs sed --in-place "s|a href=\"reference/org/tensorflow|a href=\"${SITE_PATH}/org/tensorflow|g" 83 | find ${OUTPUT_DIR} -name "*.html" | xargs sed --in-place "s|a href=\"reference/com/google|a href=\"${SITE_PATH}/com/google|g" 84 | 85 | JAVA_LANG=https://docs.oracle.com/javase/8/docs/api 86 | find ${OUTPUT_DIR} -name "*.html" | xargs sed --in-place "s|a href=\"reference/java/lang|a href=\"${JAVA_LANG}/java/lang|g" 87 | 88 | find ${OUTPUT_DIR} -name "*.html" | xargs sed --in-place 's|
|
|g'
89 | 
90 | rm ${OUTPUT_DIR}/timestamp.js || true
91 | rm ${OUTPUT_DIR}/lists.js || true
92 | rm ${OUTPUT_DIR}/index.html || true
93 | 
94 | cp ${TEMPLATES}/screen.css ${OUTPUT_DIR}/
95 | 
96 | 
97 | 


--------------------------------------------------------------------------------
/tools/tensorflow_docs/api_generator/gen_java/templates/classes.cs:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 
 5 | 
 6 | 
 7 | 
8 | 9 |
10 | 11 | 12 | 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
 
24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/head_tag.cs: -------------------------------------------------------------------------------- 1 | 2 | <?cs if:page.title ?><?cs var:page.title ?><?cs /if ?> 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/header.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/navtree_data.cs: -------------------------------------------------------------------------------- 1 | var NAVTREE_DATA = 2 | 3 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/package-descr.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 |
11 |
12 | 13 | 14 |
15 |
16 | 17 |
18 | package 19 |

20 |
21 | Classes | Description 22 |
23 |
24 | 25 |
26 | 27 |
28 |
29 |

30 |
31 | 32 | 33 |
34 |
35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/package-list.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/package.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
10 | 11 |
12 |
13 | 14 | 15 |
16 |
17 | 18 |
19 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | 28 |
29 | 30 |
31 | 32 | 33 | 34 | 35 |

36 |
37 | 38 |
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 |
51 | 52 | 53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/packages.cs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 |

9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/screen.css: -------------------------------------------------------------------------------- 1 | /** Heading for "Parameters", "See Also", etc., in details sections */ 2 | body.docs h4.jd-details-title { 3 | font-size: 1.15em; 4 | margin: 1.5em 0 0.6em -0.5em; 5 | padding: 0.2em 8em 0.4em 2.5em; 6 | text-indent: -2em; 7 | background-color: #E9E9E9; /** #DEEAFA */ 8 | } 9 | 10 | #jd-header { 11 | margin-bottom: 1em; 12 | } 13 | 14 | /* Hide empty first cell of constructors */ 15 | #pubctors td.jd-typecol { 16 | display: none; 17 | } 18 | 19 | p { 20 | margin-bottom: 0.7em; 21 | } 22 | 23 | body.docs table th { 24 | border: 1px solid #ddd; 25 | } 26 | 27 | .main tr th { 28 | color: #222; 29 | background-color: #fff; 30 | } 31 | 32 | body.docs h2 { 33 | margin-left: -0.3em; 34 | } 35 | 36 | td.jd-typecol { 37 | min-width: 100px; 38 | } 39 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/gen_java/templates/yaml_navtree.cs: -------------------------------------------------------------------------------- 1 | 20 | - title: "" 21 | path: 23 | section: 27 | - title: "" 28 | path: 40 | toc: 44 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/get_source.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Simple get_source.""" 16 | import ast 17 | import inspect 18 | import textwrap 19 | 20 | from typing import Any, Optional, Sequence, Tuple 21 | 22 | 23 | def get_ast(py_object) -> Optional[ast.AST]: 24 | if isinstance(py_object, str): 25 | source = textwrap.dedent(py_object) 26 | else: 27 | source = get_source(py_object) 28 | if source is None: 29 | return None 30 | 31 | try: 32 | return ast.parse(source) 33 | except Exception: # pylint: disable=broad-except 34 | return None 35 | 36 | 37 | def get_source(py_object: Any) -> Optional[str]: 38 | if py_object is not None: 39 | try: 40 | return textwrap.dedent(inspect.getsource(py_object)) 41 | except Exception: # pylint: disable=broad-except 42 | # A wide-variety of errors can be thrown here. 43 | pass 44 | return None 45 | 46 | 47 | def get_source_lines( 48 | py_object: Any) -> Tuple[Optional[Sequence[str]], Optional[int]]: 49 | if py_object is not None: 50 | try: 51 | return inspect.getsourcelines(py_object) 52 | except Exception: # pylint: disable=broad-except 53 | # A wide-variety of errors can be thrown here. 54 | pass 55 | return None, None 56 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/obj_type.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Turn Python docstrings into Markdown for TensorFlow documentation.""" 16 | 17 | 18 | import enum 19 | import inspect 20 | 21 | from typing import Any 22 | 23 | 24 | class ObjType(enum.Enum): 25 | """Enum to standardize object type checks.""" 26 | TYPE_ALIAS = 'type_alias' 27 | MODULE = 'module' 28 | CLASS = 'class' 29 | CALLABLE = 'callable' 30 | # properties or any `descriptor` 31 | PROPERTY = 'property' 32 | OTHER = 'other' 33 | 34 | @classmethod 35 | def get(cls, py_obj: Any) -> 'ObjType': 36 | """Get the `ObjType` for the `py_object`.""" 37 | if (getattr(py_obj, '__args__', None) and 38 | getattr(py_obj, '__origin__', None)): 39 | return cls.TYPE_ALIAS 40 | elif inspect.ismodule(py_obj): 41 | return cls.MODULE 42 | elif inspect.isclass(py_obj): 43 | return cls.CLASS 44 | elif callable(py_obj): 45 | return cls.CALLABLE 46 | elif hasattr(py_obj, '__get__'): 47 | # This handles any descriptor not only properties. 48 | # https://docs.python.org/3/howto/descriptor.html 49 | return cls.PROPERTY 50 | else: 51 | return cls.OTHER 52 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | 16 | from tensorflow_docs.api_generator.pretty_docs.base_page import PageBuilder 17 | from tensorflow_docs.api_generator.pretty_docs.base_page import PageInfo 18 | from tensorflow_docs.api_generator.pretty_docs.base_page import TemplatePageBuilder 19 | 20 | from tensorflow_docs.api_generator.pretty_docs.class_page import ClassPageBuilder 21 | from tensorflow_docs.api_generator.pretty_docs.class_page import ClassPageInfo 22 | 23 | from tensorflow_docs.api_generator.pretty_docs.function_page import FunctionPageBuilder 24 | from tensorflow_docs.api_generator.pretty_docs.function_page import FunctionPageInfo 25 | 26 | from tensorflow_docs.api_generator.pretty_docs.module_page import ModulePageBuilder 27 | from tensorflow_docs.api_generator.pretty_docs.module_page import ModulePageInfo 28 | 29 | from tensorflow_docs.api_generator.pretty_docs.type_alias_page import TypeAliasPageBuilder 30 | from tensorflow_docs.api_generator.pretty_docs.type_alias_page import TypeAliasPageInfo 31 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/docs_for_object.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Create a `pretty_docs.base_page.PageInfo` from a python object.""" 16 | from typing import Any, Dict, Optional, Type 17 | 18 | from tensorflow_docs.api_generator import config 19 | from tensorflow_docs.api_generator import doc_controls 20 | from tensorflow_docs.api_generator import doc_generator_visitor 21 | from tensorflow_docs.api_generator import obj_type as obj_type_lib 22 | from tensorflow_docs.api_generator.pretty_docs import base_page 23 | from tensorflow_docs.api_generator.pretty_docs import class_page 24 | from tensorflow_docs.api_generator.pretty_docs import function_page 25 | from tensorflow_docs.api_generator.pretty_docs import module_page 26 | from tensorflow_docs.api_generator.pretty_docs import type_alias_page 27 | 28 | _DEFAULT_PAGE_BUILDER_CLASSES = { 29 | obj_type_lib.ObjType.CLASS: class_page.ClassPageInfo, 30 | obj_type_lib.ObjType.CALLABLE: function_page.FunctionPageInfo, 31 | obj_type_lib.ObjType.MODULE: module_page.ModulePageInfo, 32 | obj_type_lib.ObjType.TYPE_ALIAS: type_alias_page.TypeAliasPageInfo, 33 | } 34 | 35 | PageBuilderDict = Dict[obj_type_lib.ObjType, Type[base_page.PageInfo]] 36 | 37 | 38 | def docs_for_object( 39 | *, 40 | api_node: doc_generator_visitor.ApiTreeNode, 41 | parser_config: config.ParserConfig, 42 | extra_docs: Optional[Dict[int, str]] = None, 43 | search_hints: bool = True, 44 | page_builder_classes: Optional[PageBuilderDict] = None, 45 | ) -> base_page.PageInfo: 46 | """Return a PageInfo object describing a given object from the TF API. 47 | 48 | This function resolves `tf.symbol` references in the docstrings into links 49 | to the appropriate location. 50 | 51 | Args: 52 | api_node: The ApiTreeNode for the object. 53 | parser_config: A `config.ParserConfig` object. 54 | extra_docs: Extra docs for symbols like public constants(list, tuple, etc) 55 | that need to be added to the markdown pages created. 56 | search_hints: If true include metadata search hints, else include a 57 | "robots: noindex". 58 | page_builder_classes: An optional dict of `{ObjectType:Type[PageInfo]}` for 59 | overriding the default page builder classes. 60 | 61 | Returns: 62 | Either a subclass of `pretty_docs.base_page.PageInfo` depending on the type 63 | of the python object being documented. 64 | 65 | Raises: 66 | RuntimeError: If an object is encountered for which we don't know how 67 | to make docs. 68 | """ 69 | if page_builder_classes is None: 70 | page_builder_classes = _DEFAULT_PAGE_BUILDER_CLASSES 71 | 72 | page_info_class = doc_controls.get_custom_page_builder_cls(api_node.py_object) 73 | if page_info_class is None: 74 | obj_type = obj_type_lib.ObjType.get(api_node.py_object) 75 | page_info_class = page_builder_classes[obj_type] 76 | 77 | page_info = page_info_class( 78 | api_node=api_node, 79 | search_hints=search_hints, 80 | extra_docs=extra_docs, 81 | parser_config=parser_config) 82 | 83 | page_info.docs_for_object() 84 | 85 | return page_info 86 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/function_page.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | import textwrap 16 | from typing import Any, Optional 17 | 18 | from tensorflow_docs.api_generator import doc_controls 19 | from tensorflow_docs.api_generator import parser 20 | from tensorflow_docs.api_generator import signature as signature_lib 21 | from tensorflow_docs.api_generator.pretty_docs import base_page 22 | 23 | 24 | class FunctionPageBuilder(base_page.TemplatePageBuilder): 25 | """Builds a markdown page from a `FunctionPageInfo` object.""" 26 | TEMPLATE = 'templates/function.jinja' 27 | 28 | def format_docstring_part(self, part): 29 | ttt = '' 30 | return base_page.format_docstring(part, table_title_template=ttt) 31 | 32 | def build_signature(self): 33 | return base_page.build_signature( 34 | name=self.page_info.full_name, 35 | signature=self.page_info.signature, 36 | decorators=self.page_info.decorators) 37 | 38 | 39 | class FunctionPageInfo(base_page.PageInfo): 40 | """Collects docs For a function Page. 41 | 42 | Attributes: 43 | full_name: The full, main name, of the object being documented. 44 | short_name: The last part of the full name. 45 | py_object: The object being documented. 46 | defined_in: A _FileLocation describing where the object was defined. 47 | aliases: A list of full-name for all aliases for this object. 48 | doc: A list of objects representing the docstring. These can all be 49 | converted to markdown using str(). 50 | signature: the parsed signature (see: generate_signature) 51 | decorators: A list of decorator names. 52 | """ 53 | DEFAULT_BUILDER_CLASS = FunctionPageBuilder 54 | 55 | def __init__(self, *, api_node, **kwargs): 56 | """Initialize a FunctionPageInfo. 57 | 58 | Args: 59 | api_node: the api tree node. 60 | **kwargs: Extra arguments. 61 | """ 62 | super().__init__(api_node, **kwargs) 63 | 64 | self._signature = None 65 | self._decorators = [] 66 | 67 | @property 68 | def signature(self): 69 | return self._signature 70 | 71 | def collect_docs(self): 72 | """Collect all information necessary to genertate the function page. 73 | 74 | Mainly this is details about the function signature. 75 | """ 76 | assert self.signature is None 77 | self._signature = signature_lib.generate_signature( 78 | self.py_object, 79 | self.parser_config, 80 | func_type=signature_lib.FuncType.FUNCTION, 81 | ) 82 | self._decorators = signature_lib.extract_decorators(self.py_object) 83 | 84 | @property 85 | def decorators(self): 86 | return list(self._decorators) 87 | 88 | def add_decorator(self, dec): 89 | self._decorators.append(dec) 90 | 91 | @property 92 | def header(self) -> Optional[str]: 93 | header = doc_controls.get_header(self.py_object) 94 | if header is not None: 95 | header = textwrap.dedent(header) 96 | return header 97 | 98 | def get_metadata_html(self): 99 | return parser.Metadata(self.full_name).build_html() 100 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/templates/class.jinja: -------------------------------------------------------------------------------- 1 | {% extends "templates/page.jinja" %} 2 | 3 | {#----------------------------------------------------------------------------#} 4 | 5 | {% block metadata %} 6 | {{ builder.top_source_link() }} 7 | 8 | {{ page_info.doc.brief -}} 9 | 10 | {% if page_info.inheritable_header %} 11 | 12 | 13 | {{ page_info.inheritable_header -}} 14 | {% endif %} 15 | 16 | {{ builder.build_bases() }} 17 | {{ builder.build_collapsable_aliases() -}} 18 | {{ builder.build_constructor() -}} 19 | {% endblock metadata %} 20 | 21 | {#----------------------------------------------------------------------------#} 22 | 23 | {% block body %} 24 | {{- builder.top_compat() -}} 25 | 26 | 27 | {{ builder.build_class_docstring() -}} 28 | {{ builder.build_attr_block() }} 29 | {{- self.child_classes() -}} 30 | {{- self.methods() -}} 31 | 32 | {{- self.other_members() -}} 33 | 34 | {{- builder.bottom_compat() -}} 35 | {% endblock body %} 36 | 37 | {#----------------------------------------------------------------------------#} 38 | 39 | {% block child_classes %} 40 | {%- if page_info.classes %} 41 | ## Child Classes 42 | {% for child_class in page_info.classes %} 43 | [`class {{child_class.short_name}}`]({{child_class.url}}) 44 | 45 | {% endfor %} 46 | {% endif -%} 47 | {% endblock child_classes%} 48 | 49 | {#----------------------------------------------------------------------------#} 50 | 51 | {% block methods %} 52 | {%- if builder.methods.info_dict -%} 53 | ## Methods 54 | 55 | {% for name, method in builder.methods.info_dict.items() %} 56 | {{- builder.build_method_section(method) -}} 57 | {% endfor %} 58 | 59 | 60 | {% endif -%} 61 | {% endblock methods%} 62 | 63 | {#----------------------------------------------------------------------------#} 64 | 65 | {% block other_members %} 66 | {%- if page_info.other_members -%} 67 | {{ builder.build_other_member_section() }} 68 | {% endif %} 69 | {% endblock other_members%} 70 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/templates/function.jinja: -------------------------------------------------------------------------------- 1 | {% extends "templates/page.jinja" %} 2 | 3 | {#----------------------------------------------------------------------------#} 4 | 5 | {% block metadata %} 6 | {{ builder.top_source_link() }} 7 | 8 | {{ page_info.doc.brief }} 9 | 10 | {% if page_info.header %} 11 | 12 | 13 | {{ page_info.header -}} 14 | {% endif %} 15 | 16 | {{ builder.build_collapsable_aliases() -}} 17 | {% endblock metadata %} 18 | 19 | {#----------------------------------------------------------------------------#} 20 | 21 | {% block body %} 22 | {% if page_info.signature %} 23 | {{ builder.build_signature() }} 24 | {% endif %} 25 | {{ super() -}} 26 | {% endblock %} 27 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/templates/module.jinja: -------------------------------------------------------------------------------- 1 | {% extends "templates/page.jinja" %} 2 | 3 | {#----------------------------------------------------------------------------#} 4 | 5 | {% block header %} 6 | {{ builder.get_devsite_headers() }} 7 | # Module: {{page_info.full_name}} 8 | 9 | 10 | {% endblock header%} 11 | 12 | {#----------------------------------------------------------------------------#} 13 | 14 | {% block body %} 15 | {{ builder.top_compat() -}} 16 | 17 | {% for part in page_info.doc.docstring_parts %} 18 | {{- builder.format_docstring_part(part) -}} 19 | {% endfor %} 20 | {{ builder.bottom_compat() }} 21 | 22 | {{ self.modules() }} 23 | {{- self.classes() }} 24 | {{- self.functions() }} 25 | {{- self.type_aliases() }} 26 | {{- self.other_members() -}} 27 | {% endblock body %} 28 | 29 | {#----------------------------------------------------------------------------#} 30 | 31 | {% block modules %} 32 | {%- if page_info.modules %} 33 | ## Modules 34 | 35 | {% for module in page_info.modules %} 36 | {%if module.doc.brief%} 37 | [`{{module.short_name}}`]({{module.url}}) module: {{module.doc.brief}} 38 | {%else%} 39 | [`{{module.short_name}}`]({{module.url}}) module 40 | {%endif%} 41 | 42 | {% endfor %} 43 | {% endif -%} 44 | {% endblock modules %} 45 | 46 | {#----------------------------------------------------------------------------#} 47 | 48 | {% block classes %} 49 | {%- if page_info.classes %} 50 | ## Classes 51 | 52 | {% for cls in page_info.classes %} 53 | {%if cls.doc.brief%} 54 | [`class {{cls.short_name}}`]({{cls.url}}): {{cls.doc.brief}} 55 | {%else%} 56 | [`class {{cls.short_name}}`]({{cls.url}}) 57 | {%endif%} 58 | 59 | {% endfor %} 60 | {% endif -%} 61 | {% endblock classes%} 62 | 63 | {#----------------------------------------------------------------------------#} 64 | 65 | {% block functions %} 66 | {%- if page_info.functions -%} 67 | ## Functions 68 | 69 | {% for fun in page_info.functions %} 70 | {%if fun.doc.brief%} 71 | [`{{fun.short_name}}(...)`]({{fun.url}}): {{fun.doc.brief}} 72 | {%else%} 73 | [`{{fun.short_name}}(...)`]({{fun.url}}) 74 | {%endif%} 75 | 76 | {% endfor %} 77 | {% endif -%} 78 | {% endblock functions%} 79 | 80 | {#----------------------------------------------------------------------------#} 81 | 82 | {% block type_aliases %} 83 | {%- if page_info.type_alias -%} 84 | ## Type Aliases 85 | 86 | {% for alias in page_info.type_alias %} 87 | [`{{alias.short_name}}`]({{alias.url}}) 88 | 89 | {% endfor %} 90 | {% endif -%} 91 | {% endblock type_aliases%} 92 | 93 | {#----------------------------------------------------------------------------#} 94 | 95 | {% block other_members %} 96 | {%- if page_info.other_members -%} 97 | {{ builder.build_other_member_section() }} 98 | {% endif %} 99 | {% endblock other_members%} 100 | 101 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/templates/page.jinja: -------------------------------------------------------------------------------- 1 | {%- extends 'templates/root.jinja' -%} 2 | 3 | {#----------------------------------------------------------------------------#} 4 | 5 | {% block content %} 6 | {{- self.header() -}} 7 | {{- self.metadata() -}} 8 | {{- self.body() -}} 9 | {% endblock content %}} 10 | 11 | {#----------------------------------------------------------------------------#} 12 | 13 | {% block header %} 14 | {{ builder.get_devsite_headers() }} 15 | # {{page_info.full_name}} 16 | 17 | 18 | {% endblock header%} 19 | 20 | {#----------------------------------------------------------------------------#} 21 | 22 | {% block metadata %} 23 | {{ builder.top_source_link() }} 24 | 25 | {{ page_info.doc.brief }} 26 | 27 | {{ builder.build_collapsable_aliases() -}} 28 | {% endblock metadata %} 29 | 30 | {#----------------------------------------------------------------------------#} 31 | 32 | {% block body %} 33 | 34 | {{ builder.top_compat() -}} 35 | 36 | {% for part in page_info.doc.docstring_parts %} 37 | {{- builder.format_docstring_part(part) -}} 38 | {% endfor %} 39 | {{ builder.bottom_compat() -}} 40 | {% endblock body %} 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/templates/root.jinja: -------------------------------------------------------------------------------- 1 | {{- self.content() -}} 2 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/pretty_docs/templates/type_alias.jinja: -------------------------------------------------------------------------------- 1 | {% extends "templates/page.jinja" %} 2 | 3 | 4 | {% block metadata %} 5 | This symbol is a **type alias**. 6 | 7 | {{ page_info.doc.brief }} 8 | 9 | {% endblock metadata %} 10 | 11 | {#----------------------------------------------------------------------------#} 12 | 13 | {% block body %} 14 | {% if page_info.signature %} 15 | #### Source: 16 | 17 | {{ builder.build_signature() }} 18 | {% endif %} 19 | {{ super() -}} 20 | {% endblock %} 21 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/report/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Tools to generate the API report.""" 16 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/report/schema/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Public API for api report proto.""" 16 | 17 | import sys 18 | 19 | from google import protobuf 20 | 21 | _version_parts = protobuf.__version__.split('.') 22 | _version = (int(_version_parts[0]), int(_version_parts[1])) 23 | 24 | if _version >= (3, 20): 25 | from tensorflow_docs.api_generator.report.schema import api_report_generated_pb2 as api_report_pb2 # pylint: disable=g-import-not-at-top 26 | else: 27 | from tensorflow_docs.api_generator.report.schema import api_report_generated_319_pb2 as api_report_pb2 # pylint: disable=g-import-not-at-top 28 | 29 | sys.modules['tensorflow_docs.api_generator.report.schema.api_report_pb2'] = ( 30 | api_report_pb2 31 | ) 32 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/traverse_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Tests for Python module traversal.""" 16 | from absl.testing import absltest 17 | 18 | 19 | from tensorflow_docs.api_generator import traverse 20 | 21 | 22 | class TestVisitor(object): 23 | 24 | def __init__(self): 25 | self.call_log = [] 26 | 27 | def __call__(self, path, parent, children): 28 | self.call_log += [(path, parent, children)] 29 | return children 30 | 31 | 32 | class TraverseTest(absltest.TestCase): 33 | 34 | def test_cycle(self): 35 | 36 | class Cyclist(object): 37 | pass 38 | Cyclist.cycle = Cyclist 39 | 40 | visitor = TestVisitor() 41 | traverse.traverse(Cyclist, [], visitor, root_name='root_name') 42 | # We simply want to make sure we terminate. 43 | 44 | def test_class(self): 45 | visitor = TestVisitor() 46 | traverse.traverse(TestVisitor, [], visitor, root_name='root_name') 47 | self.assertEqual(TestVisitor, 48 | visitor.call_log[0][1]) 49 | # There are a bunch of other members, but make sure that the ones we know 50 | # about are there. 51 | self.assertIn('__init__', [name for name, _ in visitor.call_log[0][2]]) 52 | self.assertIn('__call__', [name for name, _ in visitor.call_log[0][2]]) 53 | 54 | # There are more classes descended into, at least __class__ and 55 | # __class__.__base__, neither of which are interesting to us, and which may 56 | # change as part of Python version etc., so we don't test for them. 57 | 58 | def test_non_class(self): 59 | integer = 5 60 | visitor = TestVisitor() 61 | traverse.traverse(integer, [], visitor, root_name='root_name') 62 | self.assertEqual([], visitor.call_log) 63 | 64 | 65 | if __name__ == '__main__': 66 | absltest.main() 67 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/api_generator/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Utility functions.""" 16 | 17 | import importlib 18 | import logging 19 | import pkgutil 20 | 21 | 22 | def _onerror(name): 23 | logging.exception('Failed to load package: %r', name) 24 | logging.error('Continuing') 25 | 26 | 27 | def recursive_import(root, strict=False): 28 | """Recursively imports all the modules under a root package. 29 | 30 | Args: 31 | root: A python package. 32 | strict: Bool, if `True` raise exceptions, else just log them. 33 | 34 | Returns: 35 | A list of all imported modules. 36 | """ 37 | 38 | modules = [] 39 | 40 | kwargs = {} 41 | # If strict=False, ignore errors during `pkgutil.walk_packages`. 42 | if not strict: 43 | kwargs = {'onerror': _onerror} 44 | 45 | for _, name, _ in pkgutil.walk_packages( 46 | root.__path__, prefix=root.__name__ + '.', **kwargs): 47 | try: 48 | modules.append(importlib.import_module(name)) 49 | # And ignore the same set of errors if import_module fails, these are not 50 | # triggered by walk_packages. 51 | except Exception: # pylint: disable=broad-except 52 | if strict: 53 | raise 54 | else: 55 | _onerror(name) 56 | 57 | return modules 58 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/modeling/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | import tensorflow.compat.v2 as tf 16 | 17 | 18 | class EpochDots(tf.keras.callbacks.Callback): 19 | """A simple callback that prints a "." every epoch, with occasional reports. 20 | 21 | Args: 22 | report_every: How many epochs between full reports 23 | dot_every: How many epochs between dots. 24 | """ 25 | 26 | def __init__(self, report_every=100, dot_every=1): 27 | self.report_every = report_every 28 | self.dot_every = dot_every 29 | 30 | def on_epoch_end(self, epoch, logs): 31 | if epoch % self.report_every == 0: 32 | print() 33 | print('Epoch: {:d}, '.format(epoch), end='') 34 | for name, value in sorted(logs.items()): 35 | print('{}:{:0.4f}'.format(name, value), end=', ') 36 | print() 37 | 38 | if epoch % self.dot_every == 0: 39 | print('.', end='', flush=True) 40 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/plots/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Visualization tools for tensorflow_docs. 16 | 17 | Use this module for plotting and visualization code that is too long to inline 18 | into a notebook. 19 | """ 20 | import matplotlib.pyplot as plt 21 | import numpy as np 22 | 23 | prop_cycle = plt.rcParams['axes.prop_cycle'] 24 | COLOR_CYCLE = prop_cycle.by_key()['color'] 25 | 26 | 27 | def _smooth(values, std): 28 | """Smooths a list of values by convolving with a Gaussian distribution. 29 | 30 | Assumes equal spacing. 31 | 32 | Args: 33 | values: A 1D array of values to smooth. 34 | std: The standard deviation of the Gaussian distribution. The units are 35 | array elements. 36 | 37 | Returns: 38 | The smoothed array. 39 | """ 40 | width = std * 4 41 | x = np.linspace(-width, width, min(2 * width + 1, len(values))) 42 | kernel = np.exp(-(x / 5)**2) 43 | 44 | values = np.array(values) 45 | weights = np.ones_like(values) 46 | 47 | smoothed_values = np.convolve(values, kernel, mode='same') 48 | smoothed_weights = np.convolve(weights, kernel, mode='same') 49 | 50 | return smoothed_values / smoothed_weights 51 | 52 | 53 | class HistoryPlotter(object): 54 | """A class for plotting a named set of Keras-histories. 55 | 56 | The class maintains colors for each key from plot to plot. 57 | """ 58 | 59 | def __init__(self, metric=None, smoothing_std=None): 60 | self.color_table = {} 61 | self.metric = metric 62 | self.smoothing_std = smoothing_std 63 | 64 | def plot(self, histories, metric=None, smoothing_std=None): 65 | """Plots a {name: history} dictionary of Keras histories. 66 | 67 | Colors are assigned to the name-key, and maintained from call to call. 68 | Training metrics are shown as a solid line, validation metrics dashed. 69 | 70 | Args: 71 | histories: {name: history} a dictionary of Keras histories. 72 | metric: which metric to plot from all the histories. 73 | smoothing_std: the standard deviation of the smoothing kernel applied 74 | before plotting. The units are in array-indices. 75 | """ 76 | if metric is None: 77 | metric = self.metric 78 | if smoothing_std is None: 79 | smoothing_std = self.smoothing_std 80 | 81 | for name, history in histories.items(): 82 | # Remember name->color associations. 83 | if name in self.color_table: 84 | color = self.color_table[name] 85 | else: 86 | color = COLOR_CYCLE[len(self.color_table) % len(COLOR_CYCLE)] 87 | self.color_table[name] = color 88 | 89 | train_value = history.history[metric] 90 | val_value = history.history['val_' + metric] 91 | if smoothing_std is not None: 92 | train_value = _smooth(train_value, std=smoothing_std) 93 | val_value = _smooth(val_value, std=smoothing_std) 94 | 95 | plt.plot( 96 | history.epoch, 97 | train_value, 98 | color=color, 99 | label=name.title() + ' Train') 100 | plt.plot( 101 | history.epoch, 102 | val_value, 103 | '--', 104 | label=name.title() + ' Val', 105 | color=color) 106 | 107 | plt.xlabel('Epochs') 108 | plt.ylabel(metric.replace('_', ' ').title()) 109 | plt.legend() 110 | 111 | plt.xlim( 112 | [0, max([history.epoch[-1] for name, history in histories.items()])]) 113 | plt.grid(True) 114 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/.pre-commit-hooks.yaml: -------------------------------------------------------------------------------- 1 | # Example using the https://pre-commit.com/ framework. 2 | # See: https://github.com/tensorflow/docs/blob/master/tools/tensorflow_docs/tools/README.md#pre-commit 3 | - id: nbformat 4 | name: nbformat 5 | description: "Run 'nbformat' on a Jupyter Notebook" 6 | entry: python -m tensorflow_docs.tools.nbfmt 7 | language: python 8 | language_version: python3 9 | require_serial: true 10 | types: [jupyter] 11 | additional_dependencies: [] 12 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nbcp/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nbcp/__main__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2022 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Utility for copying cells between notebooks.""" 15 | import pathlib 16 | import sys 17 | import textwrap 18 | 19 | from absl import app 20 | import nbformat 21 | 22 | from tensorflow_docs.tools.nbfmt import __main__ as nbfmt 23 | from tensorflow_docs.tools.nbfmt import notebook_utils 24 | 25 | 26 | def process_stats(stats: notebook_utils.CellCopyStats) -> bool: 27 | """Displays summary stats to the user. Returns True if any warnings.""" 28 | print( 29 | textwrap.dedent(f""" 30 | Notebook copy complete. 31 | - Total code cells processed: {stats.processed_cells} 32 | - Cells updated: {stats.updated_cells} 33 | """)) 34 | 35 | has_warnings = any(( 36 | stats.unmatched_target_cells, 37 | stats.unmatched_source_cells, 38 | stats.out_of_order_target_cells, 39 | )) 40 | if has_warnings: 41 | print('Warnings:') 42 | 43 | if stats.unmatched_target_cells: 44 | notebook_utils.warn( 45 | '- Cells in source notebook that are not in the destination: ' 46 | f'{" ".join(stats.unmatched_target_cells)}') 47 | 48 | if stats.unmatched_source_cells: 49 | notebook_utils.warn( 50 | '- Cells in destination notebook that are not in the source: ' 51 | f'{" ".join(stats.unmatched_source_cells)}') 52 | 53 | if stats.out_of_order_target_cells: 54 | notebook_utils.warn( 55 | '- Cells found earlier in destination notebook than source: ' 56 | f'{" ".join(stats.out_of_order_target_cells)}') 57 | 58 | print() 59 | 60 | return has_warnings 61 | 62 | 63 | def main(args: list[str]) -> int: 64 | if len(args) != 3: 65 | notebook_utils.warn('nbcp requires 2 notebooks as arguments:') 66 | notebook_utils.warn(' $ ...nbcp src_notebook.ipynb dest_notebook.ipynb' 67 | ' [--nbfmt --args --supported]') 68 | sys.exit(1) 69 | 70 | src = pathlib.Path(args[1]) 71 | dest = pathlib.Path(args[2]) 72 | 73 | # Open files and copy cells. 74 | with src.open('rt') as src_fh, dest.open('rt') as dest_fh: 75 | dest_nb = nbformat.read(dest_fh, nbformat.NO_CONVERT) 76 | stats = notebook_utils.copy_code_cells( 77 | nbformat.read(src_fh, nbformat.NO_CONVERT), dest_nb) 78 | 79 | # Write over destination file. 80 | with dest.open('wt') as dest_fh: 81 | nbformat.write(dest_nb, dest_fh) 82 | 83 | warnings = process_stats(stats) 84 | 85 | # Format the notebook. 86 | nbfmt.main(['', str(dest)]) 87 | 88 | return int(warnings) 89 | 90 | 91 | if __name__ == '__main__': 92 | app.run(main) 93 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nbfmt/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nbfmt/nbfmtmain_test.py: -------------------------------------------------------------------------------- 1 | # Copyright 2024 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Unit tests for nbfmt.""" 15 | import pathlib 16 | import unittest 17 | from nbformat import notebooknode 18 | from tensorflow_docs.tools.nbfmt import __main__ as nbfmt 19 | 20 | 21 | class NotebookFormatTest(unittest.TestCase): 22 | 23 | def test_metadata_cleansing(self): 24 | subject_notebook = notebooknode.NotebookNode({ 25 | "cells": [], 26 | "metadata": { 27 | "unknown": ["delete", "me"], 28 | "accelerator": "GPU", 29 | "colab": { 30 | "name": "/this/is/clobbered.ipynb", 31 | "collapsed_sections": [], 32 | "deleteme": "pls", 33 | }, 34 | "kernelspec": { 35 | "display_name": "Python 2 foreverrrr", 36 | "name": "python2", 37 | "deleteme": "deldeldel", 38 | }, 39 | "google": { 40 | "keywords": ["one", "two"], 41 | "image_path": "/foo/img.png", 42 | "more_stuff": "delete me", 43 | }, 44 | }, 45 | }) 46 | 47 | expected_notebook = notebooknode.NotebookNode({ 48 | "cells": [], 49 | "metadata": { 50 | "accelerator": "GPU", 51 | "colab": { 52 | "name": "test.ipynb", 53 | "collapsed_sections": [], 54 | "toc_visible": True, 55 | }, 56 | "kernelspec": { 57 | "display_name": "Python 3", 58 | "name": "python3", 59 | }, 60 | "google": { 61 | "keywords": ["one", "two"], 62 | "image_path": "/foo/img.png", 63 | }, 64 | }, 65 | "nbformat": 4, 66 | "nbformat_minor": 0, 67 | }) 68 | 69 | nbfmt.clean_root(subject_notebook, pathlib.Path("/path/test.ipynb")) 70 | self.assertEqual(subject_notebook, expected_notebook) 71 | 72 | 73 | if __name__ == "__main__": 74 | unittest.main() 75 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nblint/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nblint/fix.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | r"""Utlities for fixing lints. 16 | 17 | Convenience functions for writing general fix functions for style lints. Opening 18 | and closing files, modifying contents, all should happen in the fix function 19 | callback. 20 | 21 | Fix functions are run as `fn(lint_args, *fix_args)` and executed once for each 22 | unique fn-args pair. Callbacks passed the same arg are deduplicated. But it's 23 | not the end of the world if the same function/args are run multiple times since 24 | the file changes should be the same. 25 | """ 26 | import re 27 | from typing import Any, Dict, Pattern 28 | 29 | 30 | def regex_replace_all(args: Dict[str, Any], pattern: Pattern[str], 31 | repl: str) -> None: 32 | """Replace regex matched content in a file. 33 | 34 | Args: 35 | args: Dict of args passed to the lint function. 36 | pattern: Regex pattern containing two groups to match. 37 | repl: Replacement text to insert between the two matched groups. 38 | """ 39 | fp = args["path"] 40 | contents = fp.read_text(encoding="utf-8") 41 | contents_new = re.sub( 42 | pattern, rf"{repl}", contents, flags=re.MULTILINE | re.DOTALL) 43 | if contents_new != contents: 44 | fp.write_text(contents_new, encoding="utf-8") 45 | 46 | 47 | def regex_between_groups_replace_all(args: Dict[str, Any], 48 | pattern: Pattern[str], repl: str) -> None: 49 | """Replace content between two matched groups in a file. 50 | 51 | Regex pattern must contain two groups: r'(foo).*(bar)' 52 | and the replacement text is inserted between these matches. 53 | 54 | Args: 55 | args: Dict of args passed to the lint function. 56 | pattern: Regex pattern containing two groups to match. 57 | repl: Replacement text to insert between the two matched groups. 58 | """ 59 | regex_replace_all(args, pattern, rf"\g<1>{repl}\g<2>") 60 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nblint/style/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/tools/nblint/style/google.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | r"""Lint assertions that adhere to the Google dev docs style guide. 16 | 17 | This style module is a non-exhaustive implementation of style rules found in the 18 | Google developer documentation style guide: https://developers.google.com/style 19 | 20 | When adding lints, please link to the URL of the relevant style rule. 21 | """ 22 | import re 23 | 24 | from tensorflow_docs.tools.nblint.decorator import fail 25 | from tensorflow_docs.tools.nblint.decorator import lint 26 | from tensorflow_docs.tools.nblint.decorator import Options 27 | 28 | 29 | def search_wordlist(wordlist, src_str): 30 | """Search for wordlist entries in text and return set of found items. 31 | 32 | Args: 33 | wordlist: Dict of word entries and recommendations to search in string. 34 | src_str: String to search for word entries. 35 | 36 | Returns: 37 | A dict that is a subset of entries from `wordlist` found in `src_str`. 38 | """ 39 | found_words = {} 40 | for word in wordlist: 41 | # Word-boundary and ignore between path separator '/'. 42 | if re.search(rf"[^/]\b{word}\b[^/]", src_str, re.IGNORECASE): 43 | alt_word = wordlist[word] 44 | if not alt_word: 45 | alt_word = "n/a" 46 | found_words[word] = alt_word 47 | return found_words 48 | 49 | 50 | # Non-exhaustive list: {word: alt-word} (Use False if alt not provided.) 51 | _INCLUSIVE_WORDLIST = { 52 | "blacklist": "blocked", 53 | "whitelist": "allowed", 54 | "master": "primary", 55 | "slave": "replica", 56 | "native": "built-in" 57 | } 58 | 59 | 60 | @lint( 61 | message="Use inclusive language: https://developers.google.com/style/inclusive-documentation", 62 | cond=Options.Cond.ALL) 63 | def inclusive_language(args): 64 | """Test for words found in inclusive wordlist and recommend alternatives.""" 65 | found_words = search_wordlist(_INCLUSIVE_WORDLIST, args["cell_source"]) 66 | if found_words: 67 | words = ", ".join([f"{word} => {alt}" for word, alt in found_words.items()]) 68 | fail( 69 | f"Use inclusive language where possible and accurate. Found: {words} in" 70 | f" {args['cell_source']}" 71 | ) 72 | else: 73 | return True 74 | 75 | 76 | # Non-exhaustive list: {word: alt-word} (Use False if alt not provided.) 77 | _SECOND_PERSON_WORDLIST = {"we": "you", "we're": "you are"} 78 | 79 | 80 | @lint( 81 | message="Prefer second person instead of first person: https://developers.google.com/style/person", 82 | cond=Options.Cond.ALL) 83 | def second_person(args): 84 | """Test for first person usage in doc and recommend second person.""" 85 | found_words = search_wordlist(_SECOND_PERSON_WORDLIST, args["cell_source"]) 86 | if found_words: 87 | words = ", ".join([f"{word} => {alt}" for word, alt in found_words.items()]) 88 | fail( 89 | f"Prefer second person instead of first person. Found: {words} in" 90 | f" {args['cell_source']}" 91 | ) 92 | else: 93 | return True 94 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/vis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Visualization tools for tensorflow_docs. 16 | 17 | Use this module for plotting and visualization code that is too long to inline 18 | into a notebook. 19 | """ 20 | 21 | -------------------------------------------------------------------------------- /tools/tensorflow_docs/vis/embed.py: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Simple functions for embedding data in a notebook file.""" 16 | 17 | import base64 18 | import mimetypes 19 | import os 20 | import pathlib 21 | import textwrap 22 | 23 | import IPython.display 24 | 25 | 26 | def embed_data(mime: str, data: bytes) -> IPython.display.HTML: 27 | """Embeds data as an html tag with a data-url.""" 28 | b64 = base64.b64encode(data).decode() 29 | if mime.startswith('image'): 30 | tag = f'' 31 | elif mime.startswith('video'): 32 | tag = textwrap.dedent(f""" 33 | 37 | """) 38 | else: 39 | raise ValueError('Images and Video only.') 40 | return IPython.display.HTML(tag) 41 | 42 | 43 | def embed_file(path: os.PathLike) -> IPython.display.HTML: 44 | """Embeds a file in the notebook as an html tag with a data-url.""" 45 | path = pathlib.Path(path) 46 | mime, unused_encoding = mimetypes.guess_type(str(path)) 47 | data = path.read_bytes() 48 | 49 | return embed_data(mime, data) 50 | --------------------------------------------------------------------------------