-2

The full problem: Generate a NumPy array of 10,000 random numbers (called x) and create a Variable storing the equation y=5x^2−3x+15

import numpy as np 
data = np.random.randint(1000, size=10000)
x = tf.constant(data, name='x')
y = tf.Variable(5 * (x**2) - (3 * x) + 15)

model = tf.global_variables_initializer()

with tf.Session() as session:
    session.run(model)
    print(session.run(y))

The output is [4528679 4547733 119675 ... 2215797 1247 1703543]. What is the reason for not including the full 10,000 random numbers within the array? And what does the '...' signify?

wim
  • 338,267
  • 99
  • 616
  • 750

1 Answers1

2

That's just numpy summarising your array, so you don't get 1000 numbers printed to the terminal. You can control the threshold where this kicks in by using the threshold argument to np.set_printoptions:

threshold : int, optional
    Total number of array elements which trigger summarization
    rather than full repr (default 1000).

Demo:

>>> import numpy as np
>>> a = np.arange(100)
>>> np.set_printoptions(threshold=5)
>>> print(a)
[ 0  1  2 ... 97 98 99]
>>> np.set_printoptions(threshold=500)
>>> print(a)
[ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
 96 97 98 99]
wim
  • 338,267
  • 99
  • 616
  • 750