LSTM(长短期记忆网络)是一种常用的循环神经网络模型,具有较好的时间序列预测和序列分类能力。在光谱分类任务中,可以使用LSTM模型来识别不同类别的光谱信号。
以下是一个使用LSTM模型进行光谱分类的代码示例:
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import LSTM, Dense
# 设置超参数
batch_size = 32
num_classes = 10
epochs = 100
# 加载训练数据和测试数据
(x_train, y_t