我有2个数据集,分别是FPDataset和SIDataset。然后是 FPDatset 和 SIDataset 然后每个数据集将被分成两组。 FPDataset:FPWalking 和 FPStanding SIDataset:SIWalking 和 SIStanding
我的数据集的插图如下:
FPWalking = np.array([
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[5.29, -1.22, 8.282, 8.22],
[-1.92, 9.781, 3.28, 1.93],
[0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0],
[0.27, 6.12, 8.12, 2.34],
[6.93, 2.83, 0.72, 7.22]
])
FPStanding = np.array([
[6.93, 2.83, 0.72, 7.22],
[0.27, 6.12, 8.12, 2.34],
[5.29, -1.22, 8.282, 8.22],
[-1.92, 9.781, 3.28, 1.93],
])
SIWalking = np.array([
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[9.0, 92.0, 0.0, 0.0, 0.0, 1.0, 21.0, 71.0, 0.0, 12.0, 65.0, 45.0],
[9.0, 92.0, 0.0, 0.0, 0.0, 1.0, 21.0, 71.0, 0.0, 12.0, 65.0, 45.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[0.0, 0.0, 45.0, 0.0, 0.0, 22.0, 45.0, 23.0, 0.0, 77.0, 89.0, 0.0],
[0.0, 0.0, 45.0, 0.0, 0.0, 22.0, 45.0, 23.0, 0.0, 77.0, 89.0, 0.0],
])
SIStanding= np.array([
[0.0, 0.0, 0.0, 0.0, 73.0, 12.0, 66.0, 78.0, 0.0, 12.0, 87.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 73.0, 12.0, 66.0, 78.0, 0.0, 12.0, 87.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 73.0, 12.0, 66.0, 78.0, 0.0, 12.0, 87.0, 0.0],
[0.0, 0.0, 0.0, 0.0, 73.0, 12.0, 66.0, 78.0, 0.0, 12.0, 87.0, 0.0],
我想使用 SIDataset(SIWalking 和 SIStanding)预测 FPDataset(FPWalking 和 FPStanding)。 现在我已经制作了一个模型,然后只需连接数据集如下:
SIDataset = np.concatenate((SIDatasetWalking,SIDatasetStanding), axis=0)
FPDataset = np.concatenate((FPDatasetWalking,FPDatasetStanding), axis=0)
在我连接数据集之后,我训练了一个模型,使用 resnet 来解决我的问题。但我的模型只适用于步行数据。
我的架构代码:
def identity_block(input_tensor, filters):
x = layers.Conv1D(filters, kernel_size=5, padding='same')(input_tensor)
x = layers.Activation('relu')(x)
x = layers.Conv1D(filters, kernel_size=5, padding='same')(x)
x = layers.Activation('relu')(x)
x = layers.Conv1D(filters, kernel_size=5, padding='same')(x)
x = layers.add([x, input_tensor])
x = layers.Activation('relu')(x)
return x
def dens_block(input_tensor, filters):
x = layers.Conv1D(filters, kernel_size=5, padding='same')(input_tensor)
x = layers.Activation('relu')(x)
x = layers.Conv1D(filters, kernel_size=5, padding='same')(x)
x = layers.Activation('relu')(x)
x = layers.Conv1D(filters, kernel_size=5, padding='same')(x)
shortcut = layers.Conv1D(filters, kernel_size=5, padding='same')(input_tensor)
x = layers.add([x, shortcut])
x = layers.Activation('relu')(x)
return x
def ResNet50Regression():
input_shape = (89, 1) # Change the number of input features (channels) accordingly
width = 32
Res_input = layers.Input(shape=input_shape)
x = dens_block(Res_input, width)
x = identity_block(x, width)
x = identity_block(x, width)
x = dens_block(x, width*2)
x = identity_block(x, width*2)
x = identity_block(x, width*2)
x = dens_block(x, width*4)
x = identity_block(x, width*4)
x = identity_block(x, width*4)
x = layers.GlobalAveragePooling1D()(x)
x = layers.Dense(6, activation='linear')(x)
model = models.Model(inputs=Res_input, outputs=x)
return model
训练结果预测:
下面是步行预测结果
如何让我的模型可以预测站立和步行数据?因为现在该模型仅适用于步行数据
我的完整代码在这里:https://colab.research.google.com/drive/1ajARJWJrYY3Qa7XKldJirX6QHutQzkzc?usp=sharing