I am trying to use SVM classifier for classification of some images. I am extracting features of the images using a pre-trained inception V3 model. I want to save the extracted features to a csv or excel file and then assign labels to them so that they can be used with SVM classifier. The features are currently in numpy array. I want to dump this numpy array to a excel or csv file. When using the numpy "savetxt" function, it gives error
expecting 1D or 2D array instead the array is %d dimensions
which means it can't dump the feature array to a csv file due to its high dimensions. Can someone, please, tell me a way to dump this high dimensional array to an excel or csv file?
from keras.applications.inception_v3 import InceptionV3
from keras.applications.inception_v3 import preprocess_input
from keras.applications.inception_v3 import decode_predictions
import os
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True
import scipy.io
from keras.preprocessing import image
import numpy as np
import pandas as pd
model = InceptionV3(weights='imagenet', include_top=False)
model.summary()
#for file in os.listdir('D:/MS/Literature for thesis/Mediaeval 2018/multimedia task/tools/twitter_downloader/evidence_0/'):
img_path='900095331450273792.png'
img = image.load_img(img_path, target_size=(229, 229))
img_data = image.img_to_array(img)
img_data = np.expand_dims(img_data, axis=0)
img_data = preprocess_input(img_data)
inception_feature = model.predict(img_data)
df = pd.DataFrame (inception_feature)
filepath = 'my_excel_file.xlsx'
df.to_excel(filepath, index=False)