{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1444","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1444/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1444/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1444/events","html_url":"https://github.com/tensorflow/tensorflow/issues/1444","id":139714351,"number":1444,"title":"SummaryWriter writes constants with the graph definition","user":{"login":"vgatto","id":32080,"avatar_url":"https://avatars.githubusercontent.com/u/32080?v=3","gravatar_id":"","url":"https://api.github.com/users/vgatto","html_url":"https://github.com/vgatto","followers_url":"https://api.github.com/users/vgatto/followers","following_url":"https://api.github.com/users/vgatto/following{/other_user}","gists_url":"https://api.github.com/users/vgatto/gists{/gist_id}","starred_url":"https://api.github.com/users/vgatto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vgatto/subscriptions","organizations_url":"https://api.github.com/users/vgatto/orgs","repos_url":"https://api.github.com/users/vgatto/repos","events_url":"https://api.github.com/users/vgatto/events{/privacy}","received_events_url":"https://api.github.com/users/vgatto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-09T22:03:49Z","updated_at":"2016-03-10T01:18:51Z","closed_at":null,"body":"It looks like SummaryWriter includes the values of constants when writing the graph definition. I'm currently loading word embeddings using python and using the numpy array to initialize a variable. This results in the ~300M of embeddings to be dumped to disk during summarization.  I understand why a constant would be part of the model graph if the goal was to save and restore the graph, but I don't believe this is the goal of the SummaryWriter. Is it possible to strip these out to save disk space?\r\n\r\nHere's a trivial example. If the declaration of `random_b` is removed, the resulting summary is ~4.6K, but with it, it's about 7.6M.\r\n\r\n```\r\nimport numpy as np\r\nimport os\r\nimport tensorflow as tf\r\n\r\nsession = tf.Session()\r\n\r\nlogdir = \"/tmp/tflogs\"\r\n\r\nrandom_a = tf.Variable(tf.random_normal([1000000]))\r\nrandom_b = tf.Variable(np.random.rand(1000000))\r\ntf.histogram_summary(\"random_var\", random_a)\r\nos.makedirs(logdir)\r\nwriter = tf.train.SummaryWriter(logdir, session.graph_def)\r\ninit = tf.initialize_all_variables()\r\nmerged_summary_op = tf.merge_all_summaries()\r\nsession.run(init)\r\n\r\nsummary = session.run(merged_summary_op)\r\nwriter.add_summary(summary, 0)\r\n```"},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/194602742","html_url":"https://github.com/tensorflow/tensorflow/issues/1444#issuecomment-194602742","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/1444","id":194602742,"user":{"login":"girving","id":70511,"avatar_url":"https://avatars.githubusercontent.com/u/70511?v=3","gravatar_id":"","url":"https://api.github.com/users/girving","html_url":"https://github.com/girving","followers_url":"https://api.github.com/users/girving/followers","following_url":"https://api.github.com/users/girving/following{/other_user}","gists_url":"https://api.github.com/users/girving/gists{/gist_id}","starred_url":"https://api.github.com/users/girving/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/girving/subscriptions","organizations_url":"https://api.github.com/users/girving/orgs","repos_url":"https://api.github.com/users/girving/repos","events_url":"https://api.github.com/users/girving/events{/privacy}","received_events_url":"https://api.github.com/users/girving/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T01:18:51Z","updated_at":"2016-03-10T01:18:51Z","body":"Constants are part of the `GraphDef`, so unfortunately this is intended behavior.  To keep them out of the `GraphDef`, change from\r\n\r\n    random_a = tf.Variable(tf.random_normal([1000000]))\r\n\r\nto\r\n\r\n    random_a = tf.Variable(shape=[1000000])\r\n    random_a.assign(np.random.randn(*random_a.shape)).eval()\r\n\r\nUg, actually that'll implicitly create a constant too.  @petewarden: What's the right solution here?"}}