Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

python - load GTZAN dataset in pytohn using tensorflow,keras

hi im using keras in python and im new in machine learning i want to load the data , i have a folder that in this folder i have sub-folders and in the sub folders i have spectograma of audio files example:

(i have 10 sub folders each sub folders is genre and inside the sub folders i have 100 audio files spectograma (jpg) that connect to the genre)

data->

   pop-> 1.jpg
         2.jpg
         ....
   
  hip hop-> 1.jpg
         2.jpg
         ....
   
  blues-> 1.jpg
         2.jpg
         ....

how can i load the data and split ?

(try, (x_train,y_train) , (x_test,y_test) = ????)

question from:https://stackoverflow.com/questions/65641504/load-gtzan-dataset-in-pytohn-using-tensorflow-keras

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From tensorflow guide tensorflow.org/tutorials/load_data/images:

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
  data_dir,
  validation_split=0.2,
  subset="training",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

Get validation

val_ds = tf.keras.preprocessing.image_dataset_from_directory(
  data_dir,
  validation_split=0.2,
  subset="validation",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

To get label

train_ds.class_names

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...