简体   繁体   English

使用 tensorflow,keras 在 python 中加载 GTZAN 数据集

[英]load GTZAN dataset in python 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:嗨,我在 python 中使用 keras 并且我是机器学习的新手,我想加载数据,我有一个文件夹,在这个文件夹中我有子文件夹,在子文件夹中我有音频文件的谱图示例:

(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) (我有 10 个子文件夹,每个子文件夹都是流派,在子文件夹中我有 100 个连接到流派的音频文件 spectograma(jpg))

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) =????) (尝试,(x_train,y_train),(x_test,y_test)=????)

From tensorflow guide tensorflow.org/tutorials/load_data/images :从 tensorflow 指南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获取 label

train_ds.class_names

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM