Python use of a:[1,3]?

204
January 25, 2018, at 10:43 PM

What does this line mean in python 3.x?

a:[1,3]

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

Time: 17:40

Answer 1

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.

Answer 2

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.

Answer 3

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

{a:[1,3]}

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

Answer 4

OP takes a part of a Dictionary out of context and spam's it as question for a starter question.

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()
READ ALSO
Numpy random choice to produce a 2D-array with all unique values

Numpy random choice to produce a 2D-array with all unique values

so I am wondering if there's a more efficient solution in generating a 2-D array using nprandom

232
Move chunks of list to new lines

Move chunks of list to new lines

I have created a script where I generate chunks of 2 elements within a List:

190
How to avoid orphan records in Django many-to-many relationships?

How to avoid orphan records in Django many-to-many relationships?

How do you ensure that you don't leave any orphan records when deleting records from Django tables that have a many-to-many relationship?

194
Resample pandas dataframe and apply mode

Resample pandas dataframe and apply mode

I would like to calculate mode for each group of resampled rows in pandas dataframeI try it like so:

446