Parameter optimizing method of neural network and computing apparatus
A parameter optimizing method of a neural network and a computing apparatus are provided. A shared filter is obtained, and the shared filter includes multiple shared weights. Those shared weights are assigned to multiple sub-filters. Each sub-filter corresponds to one of multiple channels. Each sub-filter includes multiple sub-weights. The size of each sub-filter is smaller than or equal to the size of the shared filter. The sub-weights of each sub-filter are generated according to the assigned shared weight. The sub-filters of those channels are used to be computed with one or more pieces of input data respectively. Thereby, checkerboard artifacts may be reduced or avoided.
1 . A parameter optimizing method of a neural network, comprising:
obtaining a shared filter, wherein the shared filter comprises a plurality of shared weights;
assigning the shared weights to a plurality of sub-filters, wherein each of the sub-filters corresponds to one of a plurality of channels, each of the sub-filters comprises a plurality of sub-weights, and a size of each of the sub-filters is smaller than or equal to a size of the shared filter;
generating the sub-weights of each of the sub-filters according to assigned shared weights; and
performing a computation with at least one input data by using the sub-filters of the channels respectively.
2 . The parameter optimizing method of a neural network according to claim 1 , wherein assigning the shared weights to the sub-filters comprises:
defining a plurality of areas of the shared filter according to the size of each of the sub-filters, wherein a number of the sub-weights in each of the sub-filters is the same as a number of the areas, a plurality of shared weights located in one area have the same value, and the shared weights in each of the areas have different values;
mapping the sub-filters to the shared filter to generate a mapping result, wherein the mapping result comprises the area of the shared filter to which each of the sub-weights of each of the sub-filters corresponds; and
assigning the shared weights according to the mapping result, wherein each selected sub-weight of a corresponding selected area of each of the sub-filters corresponds to at least one of the shared weights in the area mapped.
3 . The parameter optimizing method of a neural network according to claim 2 , wherein generating the sub-weights of each of the sub-filters according to the assigned shared weights comprises:
for each of the sub-filters, obtaining the sub-weights by adding up the corresponding shared weights in the area of the shared filter to which each selected sub-weight in each selected area is mapped.
4 . The parameter optimizing method of a neural network according to claim 2 , wherein the sub-filters comprise a first sub-filter and a second sub-filter, and mapping the sub-filters to the shared filter comprises:
setting at least one of the shared weights of the shared filter mapped to a selected area of the first sub-filter to be different from at least one of the shared weights of the shared filter mapped to a selected area of the second sub-filter.
5 . The parameter optimizing method of a neural network according to claim 1 , wherein the computation is a first convolution operation, the at least one input data comprises a plurality of pieces of first input data corresponding to the channels, and performing the computation with the at least one input data by using the sub-filters of the channels respectively comprises:
performing the first convolution operation on one of the sub-filters and one piece of the first input data respectively according to the corresponding channel to generate a plurality of pieces of first output data corresponding to the channels; and
performing a first format conversion on the first output data to generate second output data of a single channel.
6 . The parameter optimizing method of a neural network according to claim 5 , wherein the number of the channels is N, and performing the first format conversion on the first output data comprises:
assigning first elements at the same position in the pieces of first output data to N adjacent elements in the second output data.
7 . The parameter optimizing method of a neural network according to claim 5 , wherein before performing the first convolution operation on one of the sub-filters and one piece of the first input data respectively according to the corresponding channel, the parameter optimizing method further comprises:
performing a second format conversion on a first image to generate the first input data corresponding to the channels.
8 . The parameter optimizing method of a neural network according to claim 5 , wherein before performing the first convolution operation on one of the sub-filters and one piece of the first input data respectively according to the corresponding channel, the parameter optimizing method further comprises:
performing a first encoding on a second image to generate the first input data corresponding to the channels, wherein the first encoding comprises an average pooling or a second format conversion for conversion from a single channel to multiple channels.
9 . The parameter optimizing method of a neural network according to claim 5 , wherein before performing the first convolution operation on one of the sub-filters and one piece of the first input data respectively according to the corresponding channel, the parameter optimizing method further comprises:
performing at least a second convolution operation on a third image to generate the first input data corresponding to the channels.
10 . The parameter optimizing method of a neural network according to claim 1 , wherein the computation is a first convolution operation, the at least one input data comprises second input data of a single channel, and performing the computation with the at least one input data by using the sub-filters of the channels respectively comprises:
performing the first convolution operation on the sub-filters and the second input data respectively to generate a plurality of pieces of third output data corresponding to the channels; and
performing a first format conversion on the third output data to generate fourth output data of a single channel.
11 . The parameter optimizing method of a neural network according to claim 1 , wherein after performing the computation with the at least one input data by using the sub-filters of the channels respectively, the parameter optimizing method further comprises:
generating output data, wherein the input data has a first resolution, the output data has a second resolution, and the second resolution is higher than the first resolution, and the size of the shared filter is the same as a size of the output data.
12 . A computing apparatus, comprising:
a storage configured to store a program code; and
a processor coupled to the storage and configured to load and execute the program code to:
obtain a shared filter, wherein the shared filter comprises a plurality of shared weights;
assign the shared weights to a plurality of sub-filters, wherein each of the sub-filters corresponds to one of a plurality of channels, each of the sub-filters comprises a plurality of sub-weights, and a size of each of the sub-filters is smaller than or equal to a size of the shared filter;
generate the sub-weights of each of the sub-filters according to the assigned shared weights; and
perform a computation with at least one input data by using the sub-filters of the channels respectively.
13 . The computing apparatus according to claim 12 , wherein the processor is further configured to:
define a plurality of areas of the shared filter according to the size of each of the sub-filters, wherein a number of the sub-weights in each of the sub-filters is the same as a number of the areas, a plurality of shared weights located in one area have the same value, and the shared weights in each of the areas have different values;
map the sub-filters to the shared filter to generate a mapping result, wherein the mapping result comprises the area of the shared filter to which each of the sub-weights of each of the sub-filters corresponds; and
assign the shared weights according to the mapping result, wherein each selected sub-weight of a corresponding selected area of each of the sub-filters corresponds to at least one of the shared weights in the area mapped.
14 . The computing apparatus according to claim 13 , wherein the processor is further configured to:
for each of the sub-filters, obtain the sub-weights by adding up the corresponding shared weights in the area of the shared filter to which each selected sub-weight in each selected area is mapped.
15 . The computing apparatus according to claim 13 , wherein the sub-filters comprise a first sub-filter and a second sub-filter, and the processor is further configured to:
set at least one of the shared weights of the shared filter mapped to a selected area of the first sub-filter to be different from at least one of the shared weights of the shared filter mapped to a selected area of the second sub-filter.
16 . The computing apparatus according to claim 12 , wherein the computation is a first convolution operation, the at least one input data comprises a plurality of pieces of first input data corresponding to the channels, and the processor is further configured to:
perform the first convolution operation on one of the sub-filters and one piece of the first input data respectively according to the corresponding channel to generate a plurality of pieces of first output data corresponding to the channels; and
perform a first format conversion on the first output data to generate second output data of a single channel.
17 . The computing apparatus according to claim 16 , wherein the number of the channels is N, and the processor is further configured to:
assign first elements at the same position in the pieces of first output data to N adjacent elements in the second output data.
18 . The computing apparatus according to claim 16 , wherein the processor is further configured to:
perform a second format conversion on a first image to generate the first input data corresponding to the channels.
19 . The computing apparatus according to claim 16 , wherein the processor is further configured to:
perform a first encoding on a second image to generate the first input data corresponding to the channels, wherein the first encoding comprises an average pooling or a second format conversion for conversion from a single channel to multiple channels.
20 . The computing apparatus according to claim 16 , wherein the processor is further configured to:
perform at least a second convolution operation on a third image to generate the first input data corresponding to the channels.
21 . The computing apparatus according to claim 12 , wherein the computation is a first convolution operation, the at least one input data comprises second input data of a single channel, and the processor is further configured to:
perform the first convolution operation on the sub-filters and the second input data respectively to generate a plurality of pieces of third output data corresponding to the channels; and
perform a first format conversion on the third output data to generate fourth output data of a single channel.
22 . The computing apparatus according to claim 12 , wherein the processor is further configured to:
generate output data, wherein the input data has a first resolution, the output data has a second resolution, and the second resolution is higher than the first resolution, and the size of the shared filter is the same as a size of the output data.