Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Help with finding correct topic in Python learning

I am starting at zero with Python. I need to know which topics in Python do I need to study to understand below two statements. The confusing part is more than one variable on the left side of assignment.

(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, y_train = load_image_dataset(...)

that's called unpacking (or iterable unpacking)

long story short - on the right side there is some data structure and values are assign to variables on the left side
in your first example mnist.load_data() shuld return tuple/list of 2 tuples/list with 2 elements each, e.g. ((1, 3), (5, 2)) (just arbitrary numbers for example) and then x_train = 1, y_train=3, x_test=5, y_test=2

check this SO question and accepted answer

there is also extended unpacking

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Python - Most effective way to correct keyboard-user-input. ppel123 8 281 Apr-08-2020, 07:41 AM
Last Post: ppel123
  subscribing to kafka topic/key georgelza 10 467 Jan-03-2020, 04:58 AM
Last Post: georgelza
  numpynot associted with correct python version ErnestTBass 17 1,599 Jan-16-2019, 02:47 PM
Last Post: ErnestTBass
  Topic Modelling - Document Labels Nicson 0 480 Nov-20-2018, 04:56 PM
Last Post: Nicson
  finding 2 max values in an array in python Akankshha 11 1,961 Oct-18-2018, 09:16 AM
Last Post: perfringo
  Need help to correct my python function for fetching full data! PrateekG 2 941 May-27-2018, 06:39 AM
Last Post: PrateekG
  Projected Surface in 2D [Difficult topic] Hans_K 6 1,117 Aug-02-2017, 09:16 AM
Last Post: Hans_K
  Trouble finding Python code Larz60+ 5 1,768 Jun-02-2017, 01:30 PM
Last Post: sparkz_alot

Forum Jump:

Users browsing this thread: 1 Guest(s)