Training deep neural network (DNN) models, which has become an important task in today's software development, is often costly in terms of computational resources and time. With the inspiration of software reuse, building DNN models through reusing existing ones has gained increasing attention recently. Prior approaches to DNN model reuse have two main limitations: 1) reusing the entire model, while only a small part of the model's functionalities (labels) are required, would cause much overhead (e.g., computational and time costs for inference), and 2) model reuse would inherit the defects and weaknesses of the reused model, and hence put the new system under threats of security attack. To solve the above problem, we propose SeaM, a tool that re-engineers a trained DNN model to improve its reusability. Specifically, given a target problem and a trained model, SeaM utilizes a gradient-based search method to search for the model's weights that are relevant to the target problem. The re-engineered model that only retains the relevant weights is then reused to solve the target problem. Evaluation results on widely-used models show that the re-engineered models produced by SeaM only contain 10.11% weights of the original models, resulting 42.41% reduction in terms of inference time. For the target problem, the re-engineered models even outperform the original models in classification accuracy by 5.85%. Moreover, reusing the re-engineered models inherits an average of 57% fewer defects than reusing the entire model. We believe our approach to reducing reuse overhead and defect inheritance is one important step forward for practical model reuse.
翻译:训练深度神经网络(DNN)模型已成为当今软件开发中的重要任务,但往往需要高昂的计算资源和时间成本。受软件重用理念的启发,通过重用现有模型来构建DNN模型近年来受到越来越多的关注。现有DNN模型重用方法存在两个主要局限性:1)当仅需模型部分功能(标签)时,重用整个模型会造成大量开销(例如推理的计算和时间成本);2)模型重用会继承原始模型的缺陷与弱点,使新系统面临安全攻击威胁。为解决上述问题,我们提出SeaM工具,该工具通过重构已训练DNN模型来提升其可重用性。具体而言,针对目标问题与已训练模型,SeaM采用基于梯度的搜索方法,查找与目标问题相关的模型权重。仅保留相关权重的重构模型随后被重用于解决目标问题。在广泛使用的模型上的评估结果表明,SeaM生成的重构模型仅保留原始模型10.11%的权重,推理时间减少42.41%。在目标问题上,重构模型的分类准确率甚至比原始模型高出5.85%。此外,重用重构模型平均比重用完整模型少继承57%的缺陷。我们相信,这种降低重用开销与缺陷继承的方法,是推动模型实用化重用迈出的重要一步。