Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help #12

Open
aldiak opened this issue Aug 17, 2020 · 0 comments
Open

Need help #12

aldiak opened this issue Aug 17, 2020 · 0 comments

Comments

@aldiak
Copy link

aldiak commented Aug 17, 2020

how to modify the following code for Indian Pines? because Pavia University dataset has 9 class and Indian Pines 16.

w=2
num_PC=1
israndom=True
randtime = 1

OASpectral_IP = np.zeros((9+2,randtime))
s1s2=1
OASpectral_Pavia1 = 'spec1'
time_step = 3

for r in range(0,randtime):

#################Pavia#################
dataID=2
data = HyperspectralSamples(dataID=dataID, timestep=time_step, w=w, num_PC=num_PC, israndom=israndom, s1s2=s1s2)
X = data[0]
X_train = data[1]
X_test = data[2]
XP = data[3]
XP_train = data[4]
XP_test = data[5]
Y = data[6]-1
Y_train = data[7]-1
Y_test = data[8]-1

batch_size = 128

nb_classes = Y_train.max()+1
nb_epoch = 50
nb_features = X.shape[-1]

img_rows, img_cols = XP.shape[1],XP.shape[1]
# convert class vectors to binary class matrices
y_train = np_utils.to_categorical(Y_train, nb_classes)
y_test = np_utils.to_categorical(Y_test, nb_classes)

model = LSTM_RS(time_step=time_step,nb_features=nb_features)
tic1 = time.clock()
histloss=model.fit([X_train], [y_train], nb_epoch=nb_epoch, batch_size=batch_size, verbose=1, shuffle=True)
losses = histloss.history
toc1 = time.clock()

tic2 = time.clock()

PredictLabel = model.predict([X_test],verbose=1).argmax(axis=-1)
toc2 = time.clock()

OA,Kappa,ProducerA = CalAccuracy(PredictLabel,Y_test[:,0])    
OASpectral_IP[0:9,r] = ProducerA
OASpectral_IP[-2,r] = OA
OASpectral_IP[-1,r] = Kappa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant