-7

What does this line mean in python 3.x?

a:[1,3]

Source : https://www.youtube.com/watch?v=yX8KuPZCAMo

Time: 17:40

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
shiteme
  • 5
  • 3

4 Answers4

3

This is the syntax of a dictionary in Python, a data structure which maps an index to another object.

a = tf.placeholder(tf.float32)
{a: [1,3]}

In this case, a is a Tensor from Tensorflow and [1,3] are the values it will assume when the graph is executed.

IMO, you should invest your time into acquiring a better understanding of elementary data structures and syntax from Python before diving into Tensorflow.

Matheus Portela
  • 2,420
  • 1
  • 21
  • 32
0

In the video, a and b are tensorflow.python.framework.ops.Tensor Objects. At time 17:40, the instructor uses a and b as keys and their respective values [1,3] and [2, 4]. At 17:45, in the pop_up, you can see the variable name, feed_dict. He is just creating a dictionary.

Kris
  • 39
  • 5
0

You didn't give us the whole context of the code.

{a:[1,3]}

defines a dictionary with key a and value [1,3].

John Gordon
  • 29,573
  • 7
  • 33
  • 58
  • Is it a dictionary or a List? coz dictionary is created like this a={"a_key":2,"akey1":4} – shiteme Jan 25 '18 at 17:14
  • Dict keys don't have to be strings; they can be any immutable value. In this case, the key is a variable `a` which was previously defined. And the value can be anything, in this case it's a list. – John Gordon Jan 25 '18 at 17:19
-1

OP takes a part of a Dictionary out of context which can be seen at timepoint 17:47min.

a is declared as a = tf... etc and thus has content and context.

[1,3] are list items.

then a:[1,3] in dict:

a = keyname. [1,3] = values

try this:

a = 'alot of words for a keyname'
b = 17.47

my_dict = {a:["sing along song", "the voice of"], b:(12, 'candidates', None, "wins")}

print my_dict.keys()
ZF007
  • 3,708
  • 8
  • 29
  • 48
  • Is it a dictionary or a List? coz dictionary is created like this a={"a_key":2,"akey1":4} – shiteme Jan 25 '18 at 17:17
  • its dict with declared values. `a` is here a variable name that is brought in as you can see at 17:47 in the video. – ZF007 Jan 25 '18 at 17:18