hiroshi (1) [Avatar] Offline
[ 21 KB ]
When using docker to run sample codes, I found that it is hard to use plt.show() because it requires a X11 environment.
I'v had struggled while I found outputting plot as png image is very easy.

  import numpy as np
+ import matplotlib as mpl
+ mpl.use('Agg')
  import matplotlib.pyplot as plt
- plt.show()
+ plt.savefig('plot.png')

Now you can do like this with docker for mac.
docker run -it --rm -v$PWD:/notebooks b.gcr.io/tensorflow/tensorflow python regression.py && open plot.png 

I attached a resulted plot.png of listing 3.2.

How about adding this information in the book?

reference: http://stackoverflow.com/a/4935945/338986