Method and system for implementing a variable accuracy neural network
Disclosed is an electronic apparatus. The electronic apparatus includes a memory storing at least one instruction, and a processor coupled to the memory and configured to control the electronic apparatus, the processor configured to identify one of a plurality of exit points included in a neural network based on at least one constraint in at least one of processing or the electronic apparatus, process the input data via the neural network and obtain processing results output from the identified exit point as output data.
1 . A method for controlling an electronic apparatus, the method comprising:
receiving input data;
identifying one of a plurality of exit points included in a neural network based on a time taken to reach each exit point to provide a processing result and based on a memory capacity of the electronic apparatus, the neural network providing progressive hierarchical inference by having at least a coarse-grained domain and a fine-grained domain, and coarse-grained results output from exit points in the coarse-grained domain are further processed in the fine-grained domain to obtain fine-grained results;
processing the input data via the neural network;
obtaining processing results output from the identified exit point as output data; and
using knowledge distillation, jointly training a plurality of classifiers corresponding to the plurality of exit points.
2 . The method as claimed in claim 1 , wherein the plurality of exit points are equidistantly spaced in the neural network.
3 . The method as claimed in claim 1 , wherein the identifying comprises identifying one of the plurality of exit points based on accuracy.
4 . The method as claimed in claim 1 , wherein:
the neural network includes the coarse-grained domain corresponding to a starting part of the neural network and the fine-grained domain corresponding to a deeper part of the neural network following the starting part;
classifiers in the coarse-grained domain generate coarser predictions then classifiers in the fine-grained domain; and
a plurality of exit points are positioned in the coarse-grained domain or the fine-grained domain.
5 . The method as claimed in claim 1 , wherein the obtaining comprises, based on a confidence of the processing result being greater than or equal to a predetermined confidence level, obtaining the processing result as the output data.
6 . The method as claimed in claim 5 , further comprising:
based on the confidence of the processing result being less than the predetermined confidence level, further processing the input data through a neural network after the identified exit point.
7 . The method as claimed in claim 1 , further comprising:
receiving a command to select a low-latency mode,
wherein the identifying comprises identifying one of the plurality of exit points based on time constraints corresponding to the low-latency mode.
8 . The method as claimed in claim 1 , further comprising:
receiving a command to select a confidence-based mode,
wherein the identifying comprises identifying one of the plurality of exit points based on the confidence level corresponding to the confidence-based mode.
9 . The method as claimed in claim 8 , further comprising:
receiving an additional processing command for the processing result;
additionally processing the input data through a neural network after the identified exit point; and
obtaining the additionally-processed data from the neural network as the output data.
10 . The method as claimed in claim 1 , further comprising:
calibrating the neural network based on at least one of a processing capacity of the electronic apparatus, the memory capacity of the electronic apparatus, or a power capacity of the electronic apparatus.
11 . The method as claimed in claim 10 , wherein the calibrating comprises reducing a number of classes used for processing the input data and outputting the processing result.
12 . The method as claimed in claim 10 wherein the calibrating comprises partitioning the neural network into a first portion configured to be executed by the electronic apparatus and a second portion configured to be executed by a remote server, and
wherein the obtaining comprises processing the input data through the first portion.
13 . The method as claimed in claim 12 , wherein based on a confidence of the processing result through the first portion being greater than or equal to the predetermined confidence level, the processing result through the first portion is obtained as the output data.
14 . The method as claimed in claim 13 , further comprising:
based on the confidence of the processing result through the first portion being less than the predetermined confidence level, transmitting the processing result through the first portion to the remote server; and
receiving, from the remote server, a result obtained by additionally processing, through the second portion, the processing result through the first portion.
15 . An electronic apparatus comprising:
a memory storing at least one instruction; and
a processor coupled to the memory and configured to control the electronic apparatus,
wherein the processor is configured to:
identify one of a plurality of exit points included in a neural network based on a time taken to reach each exit point to provide a processing result and based on a memory capacity of the electronic apparatus, the neural network providing progressive hierarchical inference by having at least a coarse-grained domain and a fine-grained domain, and coarse-grained results output from exit points in the coarse-grained domain are further processed in the fine-grained domain to obtain fine-grained results;
process the input data via the neural network;
obtain processing results output from the identified exit point as output data; and
jointly train, using knowledge distillation, a plurality of classifiers corresponding to the plurality of exit points.
16 . The electronic apparatus as claimed in claim 15 , wherein the processor, based on a confidence of the processing result being greater than or equal to a predetermined confidence level, is configured to obtain the processing result as the output data.
17 . The electronic apparatus as claimed in claim 16 , wherein the processor, based on the confidence of the processing result being less than the predetermined confidence level, is configured to further process the input data through a neural network after the identified exit point.