tensorflow - 如何获取tensorflow文档的pdf格式?

标签 tensorflow pdf documentation

我想要 pdf 版本的 TensorFlow 文档,因为 pdf 更方便阅读和注释。

similar question这已经过时了。

这是source file TF 文档。我还没有找到 pdf 生成脚本。我们可能会尝试将 md/ipynb/html 转换为 pdf,这有点麻烦。

有没有更直接、方便的方法呢?谢谢!

最佳答案

我写了一个可以生成pdf的脚本,但仍然存在一些问题,例如TOC。

结果 pdf 在这里:https://github.com/hxsnow10/tensorflow_doc_pdf

HTML 生成

# change a diractoy of md and ipynb to html

import os
import pdfkit
import markdown


in_dir = 'site/en/tutorials'   # this will be relative_path"
out_dir = os.path.join("html", in_dir)
out_html_path = os.path.join(out_dir, "index.html")
out_images_path = os.path.join(out_dir, "inages")

cmd = "rm -rf {} ; mkdir -p {}".format(out_dir, out_images_path)
os.system(cmd)

cmd = "echo '' >  {}".format(out_html_path)
os.system(cmd)

files_txt = []
for root, subFolders, files in os.walk(in_dir):
    # copy image to prevent relative path miss
    if 'images' in subFolders:
        path = os.path.join(root, 'images')
        m_files1 = os.listdir(out_images_path)
        m_files2 = os.listdir(path)
        if set(m_files1) & set(m_files2):
            print 'BADLLY IMGES', m_files1, m_files2
        # better to recursive merge
        cmd = "cp -rf {}/* {}".format(path, out_images_path)
        os.system(cmd)

    nb_file_paths = [os.path.join(root,filename) for filename in files if filename.endswith('.ipynb')]
    md_file_paths = [os.path.join(root,filename) for filename in files if filename.endswith('.md')]

    print "md_files = " , md_file_paths
    for file_path in md_file_paths:
        out_path = file_path[:-3]+'.html'
        markdown.markdownFromFile(
            input=file_path,
            output=out_path,
            encoding='utf8'
        )
        cmd = "cat {} >> {}".format(out_path, out_html_path)
        os.system(cmd)

    print "nb_files = " , nb_file_paths
    if nb_file_paths:
        ss = ''
        for f in nb_file_paths:
            ss = ss + ' "' + f + '"'

        cmd = 'jupyter nbconvert ' + ss + ' --to html --stdout >> {}'.format(out_html_path)
        os.system(cmd)

它可以生成带有图像的html: enter image description here

PDF生成

如果有时间我可能会尝试更多。

链接

关于tensorflow - 如何获取tensorflow文档的pdf格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71931340/

相关文章:

java - 使用 Java 的 Pdf 页数

java - 当我以 pdf 形式向占位符插入值时,如何设置 iText 的编码?

node.js - 在哪里可以找到 npm 包的文档?

ruby - 为什么 Ruby 文档中的方法前面有井号?

python - 如何在tensorflow 2中获得损失梯度wrt内层输出?

python - 在构建和训练 3D Keras U-NET 时出现 ValueError

javascript - jQuery 在选项卡中打开 PDF - 正在打开其他选项卡

python - 如何将Tensorflow张量尺寸(形状)作为int值?

python - Tensorflow:如何将张量提供给经过训练的神经网络?

javascript - 苹果用什么程序来创建模块化的javascript文件