Skip to content

Instantly share code, notes, and snippets.

View Dexter1618's full-sized avatar
💭
Hamiltonians with 無為

Debayan Das Dexter1618

💭
Hamiltonians with 無為
View GitHub Profile
@Dexter1618
Dexter1618 / tensorflow_show_graph.py
Created September 26, 2019 12:05
Plot Tensorflow Graphs in Jupyter Notebook
'''
Source:https://nbviewer.jupyter.org/github/tensorflow/examples/blob/master/community/en/r1/deepdream.ipynb#Loading-and-displaying-the-model-graph
'''
from IPython.display import Image, display, HTML
def strip_consts(graph_def, max_const_size = 32):
"""Strip large constant values from graph_def."""
strip_def = tf.GraphDef()
@Dexter1618
Dexter1618 / read_large_json_files.py
Last active August 6, 2021 08:55
This python function can read a large JSON export from MongoDB as a generator
def read_large_json_file(json_document:str, lines = -1):
'''
This function accepts the path to a large JSON file exported from MongoDB
and reads each JSON document one by one as a generator. Use this function in a loop as:
`for document in read_large_json_file("[path to json export].json)`. The parameter `lines`
limit how many files in the export file it will read and is put there as a safe measure in case you have a very large
file.
'''
import json