.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/visualkeras/plot_dl_nlp_vector_index_db.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite or Binder. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_visualkeras_plot_dl_nlp_vector_index_db.py: visualkeras: Vector Index DB ========================================== .. currentmodule:: scikitplot.visualkeras An example showing the :py:func:`~scikitplot.visualkeras` function used by a :py:class:`~tensorflow.keras.Model` model. .. GENERATED FROM PYTHON SOURCE LINES 10-15 .. code-block:: Python # Authors: The scikit-plots developers # SPDX-License-Identifier: BSD-3-Clause .. GENERATED FROM PYTHON SOURCE LINES 16-34 .. code-block:: Python # visualkeras Need aggdraw tensorflow # !pip install scikitplot[core, cpu] # or # !pip install aggdraw # !pip install tensorflow # python -c "import tensorflow as tf, google.protobuf as pb; print('tf', tf.__version__); print('protobuf', pb.__version__)" # python -m pip check # If Needed # pip install -U "protobuf<6" # pip install protobuf==5.29.4 import tensorflow as tf # Clear any session to reset the state of TensorFlow/Keras tf.keras.backend.clear_session() from scikitplot import visualkeras .. GENERATED FROM PYTHON SOURCE LINES 35-49 .. code-block:: Python import sys # TODO: change this import to wherever your modified AnnoyIndex lives # e.g. scikitplot.cexternals._annoy or similar import scikitplot.cexternals._annoy as annoy # from scikitplot import annoy sys.modules["annoy"] = annoy # now `import annoy` will resolve to your module import annoy print(annoy.__doc__) .. rst-class:: sphx-glr-script-out .. code-block:: none High-level Python interface for the C++ ANNoy backend. Spotify ANNoy [1]_ (Approximate Nearest Neighbors Oh Yeah). Exports: * Annoy → low-level C-extension type (stable) `c-api powered new features `_ * AnnoyIndex → alias of Annoy (legacy AnnoyIndex name) .. seealso:: * :ref:`ANNoy ` * :ref:`cexternals/ANNoy ` * https://github.com/spotify/annoy * https://pypi.org/project/annoy References ---------- .. [1] `Spotify AB. (2013). "Approximate Nearest Neighbors Oh Yeah" Github. https://github.com/spotify/annoy `_ Examples -------- >>> import random; random.seed(0) >>> # from annoy import Annoy, AnnoyIndex >>> from scikitplot.cexternals._annoy import Annoy, AnnoyIndex >>> from scikitplot.annoy import Annoy, AnnoyIndex, Index >>> f = 40 # vector dimensionality >>> t = AnnoyIndex(f, "angular") # Length of item vector and metric >>> t.add_item(0, [1] * f) >>> t.build(10) # Build 10 trees >>> t.get_nns_by_item(0, 1) # Find nearest neighbor .. GENERATED FROM PYTHON SOURCE LINES 50-58 .. tags:: model-type: classification model-workflow: model building plot-type: visualkeras domain: neural network level: beginner purpose: showcase .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.370 seconds) .. _sphx_glr_download_auto_examples_visualkeras_plot_dl_nlp_vector_index_db.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/scikit-plots/scikit-plots/main?urlpath=lab/tree/notebooks/auto_examples/visualkeras/plot_dl_nlp_vector_index_db.ipynb :alt: Launch binder :width: 150 px .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../lite/lab/index.html?path=auto_examples/visualkeras/plot_dl_nlp_vector_index_db.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_dl_nlp_vector_index_db.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_dl_nlp_vector_index_db.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_dl_nlp_vector_index_db.zip ` .. include:: plot_dl_nlp_vector_index_db.recommendations .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_