<p dir="auto">After installing docker, I attempted to run tensorflow in Jupyter. My run command was<br>
<code class="notranslate">LewIss-MacBook-Pro:MyTensorFlow</code> lewleib$  docker run -it -p 8888:8888 -p 6006:6006 -v ~/Users/lewleib/MyTensorFlow:/notebooks tensorflow/tensorflow`</p>
<p dir="auto">In the Jupyter notebook I ran</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import tensorflow as tf     
hello = tf.constant('Hello, TensorFlow!')     
sess = tf.Session()     
print(sess.run(hello) "><pre class="notranslate"><code class="notranslate">import tensorflow as tf     
hello = tf.constant('Hello, TensorFlow!')     
sess = tf.Session()     
print(sess.run(hello) 
</code></pre></div>
<p dir="auto">This resulted in<br>
<code class="notranslate">ModuleNotFoundError: No module named 'tensorflow'</code></p>
<p dir="auto">I have tried starting in different directories and added prefix gcr.io with the same results. Thanks<br>
-- | --</p>
<p dir="auto">Code :</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import tensorflow as tf
def Conv3D(x, filter_shape, stride = 1, padding = 'VALID', dilation_rate = (1,1,1)):
      W = tf.get_variable(name = 'weights', shape = filter_shape, initializer = tf.contrib.layers.xavier_initializer())
      b = tf.get_variable(name = 'bias', shape = filter_shape[4], initializer = tf.constant_initializer(0.1))
      conv_out = tf.nn.convolution(x, W, b, padding = padding, strides = [1,1,1], dilation_rate = dilation_rate)
     ret_val = tf.nn.bias_add(conv_out,b)
     return ret_val

def MaxPool3D(x, dilation_rate = (1,1,1)):
      ret_val = tf.nn.pool(x, window_shape = [2,2,2], pooling_type = 'MAX', padding = 'VALID', dilation_rate = dilation_rate, strides = [1,1,1])
      return ret_val


layer = {}
dilation = 1
inputs = tf.placeholder(tf.float32, (None, 80, 80, 80, 1))
layer[1] = Conv3D(inputs, [3,3,3,1,128], dilation_rate = (dilation, dilation, dilation))
layer[2] = Conv3D(layer[1], [3,3,3,128,64], dilation_rate = (dilation, dilation, dilation))
layer[3] = MaxPool3D(layer[2], dilation_rate = (dilation, dilation, dilation))
dilation = 2*dilation
layer[4] = Conv3D(layer[3], [3,3,3,64,128], dilation_rate = (dilation, dilation, dilation))
layer[5] = MaxPool3D(layer[4], dilation_rate = (dilation, dilation, dilation))
dilation = 2*dilation
layer[6] = Conv3D(layer[5], [3,3,3,128, 256], dilation_rate = (dilation, dilation, dilation))
layer[7] = MaxPool3D(layer[6], dilation_rate = (dilation, dilation, dilation))
dilation = 2*dilation
layer[8] = Conv3D(layer[7], [3,3,3,256,64], dilation_rate = (dilation, dilation, dilation))

inputs_np = np.random.randn(1,80,80,80,1)
sess = tf.Session()
logits1 = sess.run(layer[8], feed_dict = {inputs : inputs_np})
logits1_duplicate = sess.run(layer[8], feed_dict = {inputs : inputs_np})

sum_diff = np.sum(logits1 - logits1_duplicate)
print(' sum diff : ', sum_diff)
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span>
<span class="pl-k">def</span> <span class="pl-v">Conv3D</span>(<span class="pl-s1">x</span>, <span class="pl-s1">filter_shape</span>, <span class="pl-s1">stride</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>, <span class="pl-s1">padding</span> <span class="pl-c1">=</span> <span class="pl-s">'VALID'</span>, <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>)):
      <span class="pl-v">W</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">get_variable</span>(<span class="pl-s1">name</span> <span class="pl-c1">=</span> <span class="pl-s">'weights'</span>, <span class="pl-s1">shape</span> <span class="pl-c1">=</span> <span class="pl-s1">filter_shape</span>, <span class="pl-s1">initializer</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">contrib</span>.<span class="pl-s1">layers</span>.<span class="pl-en">xavier_initializer</span>())
      <span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">get_variable</span>(<span class="pl-s1">name</span> <span class="pl-c1">=</span> <span class="pl-s">'bias'</span>, <span class="pl-s1">shape</span> <span class="pl-c1">=</span> <span class="pl-s1">filter_shape</span>[<span class="pl-c1">4</span>], <span class="pl-s1">initializer</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">constant_initializer</span>(<span class="pl-c1">0.1</span>))
      <span class="pl-s1">conv_out</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">nn</span>.<span class="pl-en">convolution</span>(<span class="pl-s1">x</span>, <span class="pl-v">W</span>, <span class="pl-s1">b</span>, <span class="pl-s1">padding</span> <span class="pl-c1">=</span> <span class="pl-s1">padding</span>, <span class="pl-s1">strides</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> <span class="pl-s1">dilation_rate</span>)
     <span class="pl-s1">ret_val</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">nn</span>.<span class="pl-en">bias_add</span>(<span class="pl-s1">conv_out</span>,<span class="pl-s1">b</span>)
     <span class="pl-k">return</span> <span class="pl-s1">ret_val</span>

<span class="pl-k">def</span> <span class="pl-v">MaxPool3D</span>(<span class="pl-s1">x</span>, <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>)):
      <span class="pl-s1">ret_val</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-s1">nn</span>.<span class="pl-en">pool</span>(<span class="pl-s1">x</span>, <span class="pl-s1">window_shape</span> <span class="pl-c1">=</span> [<span class="pl-c1">2</span>,<span class="pl-c1">2</span>,<span class="pl-c1">2</span>], <span class="pl-s1">pooling_type</span> <span class="pl-c1">=</span> <span class="pl-s">'MAX'</span>, <span class="pl-s1">padding</span> <span class="pl-c1">=</span> <span class="pl-s">'VALID'</span>, <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> <span class="pl-s1">dilation_rate</span>, <span class="pl-s1">strides</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>])
      <span class="pl-k">return</span> <span class="pl-s1">ret_val</span>


<span class="pl-s1">layer</span> <span class="pl-c1">=</span> {}
<span class="pl-s1">dilation</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>
<span class="pl-s1">inputs</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">placeholder</span>(<span class="pl-s1">tf</span>.<span class="pl-s1">float32</span>, (<span class="pl-c1">None</span>, <span class="pl-c1">80</span>, <span class="pl-c1">80</span>, <span class="pl-c1">80</span>, <span class="pl-c1">1</span>))
<span class="pl-s1">layer</span>[<span class="pl-c1">1</span>] <span class="pl-c1">=</span> <span class="pl-v">Conv3D</span>(<span class="pl-s1">inputs</span>, [<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">1</span>,<span class="pl-c1">128</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">layer</span>[<span class="pl-c1">2</span>] <span class="pl-c1">=</span> <span class="pl-v">Conv3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">1</span>], [<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">128</span>,<span class="pl-c1">64</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">layer</span>[<span class="pl-c1">3</span>] <span class="pl-c1">=</span> <span class="pl-v">MaxPool3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">2</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">dilation</span> <span class="pl-c1">=</span> <span class="pl-c1">2</span><span class="pl-c1">*</span><span class="pl-s1">dilation</span>
<span class="pl-s1">layer</span>[<span class="pl-c1">4</span>] <span class="pl-c1">=</span> <span class="pl-v">Conv3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">3</span>], [<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">64</span>,<span class="pl-c1">128</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">layer</span>[<span class="pl-c1">5</span>] <span class="pl-c1">=</span> <span class="pl-v">MaxPool3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">4</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">dilation</span> <span class="pl-c1">=</span> <span class="pl-c1">2</span><span class="pl-c1">*</span><span class="pl-s1">dilation</span>
<span class="pl-s1">layer</span>[<span class="pl-c1">6</span>] <span class="pl-c1">=</span> <span class="pl-v">Conv3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">5</span>], [<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">128</span>, <span class="pl-c1">256</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">layer</span>[<span class="pl-c1">7</span>] <span class="pl-c1">=</span> <span class="pl-v">MaxPool3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">6</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))
<span class="pl-s1">dilation</span> <span class="pl-c1">=</span> <span class="pl-c1">2</span><span class="pl-c1">*</span><span class="pl-s1">dilation</span>
<span class="pl-s1">layer</span>[<span class="pl-c1">8</span>] <span class="pl-c1">=</span> <span class="pl-v">Conv3D</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">7</span>], [<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">3</span>,<span class="pl-c1">256</span>,<span class="pl-c1">64</span>], <span class="pl-s1">dilation_rate</span> <span class="pl-c1">=</span> (<span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>, <span class="pl-s1">dilation</span>))

<span class="pl-s1">inputs_np</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-c1">1</span>,<span class="pl-c1">80</span>,<span class="pl-c1">80</span>,<span class="pl-c1">80</span>,<span class="pl-c1">1</span>)
<span class="pl-s1">sess</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">Session</span>()
<span class="pl-s1">logits1</span> <span class="pl-c1">=</span> <span class="pl-s1">sess</span>.<span class="pl-en">run</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">8</span>], <span class="pl-s1">feed_dict</span> <span class="pl-c1">=</span> {<span class="pl-s1">inputs</span> : <span class="pl-s1">inputs_np</span>})
<span class="pl-s1">logits1_duplicate</span> <span class="pl-c1">=</span> <span class="pl-s1">sess</span>.<span class="pl-en">run</span>(<span class="pl-s1">layer</span>[<span class="pl-c1">8</span>], <span class="pl-s1">feed_dict</span> <span class="pl-c1">=</span> {<span class="pl-s1">inputs</span> : <span class="pl-s1">inputs_np</span>})

<span class="pl-s1">sum_diff</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">sum</span>(<span class="pl-s1">logits1</span> <span class="pl-c1">-</span> <span class="pl-s1">logits1_duplicate</span>)
<span class="pl-en">print</span>(<span class="pl-s">' sum diff : '</span>, <span class="pl-s1">sum_diff</span>)</pre></div>
<p dir="auto">When I run this code, I get a non zero sum_diff. Why is the network's output not consistent with multiple runs ? I will appreciate some help</p>