Methods and apparatuses for compressing parameters of neural networks
An encoder for encoding weight parameters of a neural network is configured to obtain a plurality of weight parameters of the neural network, to encode the weight parameters of the neural network using a context-dependent arithmetic coding, to select a context for an encoding of a weight parameter, or for an encoding of a syntax element of a number representation of the weight parameter, in dependence on one or more previously encoded weight parameters and/or in dependence on one or more previously encoded syntax elements of a number representation of one or more weight parameters, and to encode the weight parameter, or a syntax element of the weight parameter, using the selected context. Corresponding decoder, quantizer, methods and computer programs are also described.
1 . A decoder for decoding weight parameters of a neural network, the decoder comprising:
a communication interface;
a memory storing instructions; and
a processor which is coupled to the communication interface and the memory, to execute the instructions stored in the memory to implement operations comprising:
acquiring a plurality of bits representing weight parameters of the neural network;
decoding the weight parameters of the neural network using a context-dependent arithmetic coding;
selecting a context for a decoding of a weight parameter, or for a decoding of a syntax element of a number representation of the weight parameter, in dependence on one or more previously decoded weight parameters and/or in dependence on one or more previously decoded syntax elements of a number representation of one or more weight parameters;
decoding the weight parameter, or a syntax element of the weight parameter, using the selected context; and
selecting different contexts in dependence on whether the previously decoded weight parameter is smaller than zero, equal to zero or larger than zero.
2 . The decoder of claim 1 , wherein the operations further comprise:
determine a plurality of status identifiers representing statuses of a plurality of weight parameters at a plurality of positions relative to a position of a currently decoded weight parameter in the form of a numeric value, and combining the status identifiers, in order to acquire a context index value representing a context of the currently decoded weight parameter.
3 . The decoder of claim 1 , wherein the operations further comprise:
selecting a context for the decoding of a zero flag of the weight parameter in dependence on how many zero-valued weight parameters and/or unavailable weight parameters in a row are adjacent to a currently decoded weight parameter.
4 . The decoder of claim 3 ,
wherein the plurality of weight parameters is arranged in a matrix, and the weight parameters are denoted as I x−1,y , I x−,y and I x−3,y and correspond to positions (x−1,y), (x−2,y) and (x−3,y) in the matrix, respectively, and are represented by status identifiers s x−1,y , s x−2,y , s x−3,y .
5 . The decoder of claim 2 ,
wherein the plurality of weight parameters is arranged in a matrix, and a status identifier s x,y for a position (x,y) in the matrix is equal to a first value, if the position (x,y) is not available or the weight parameter at the position (x,y) is equal to zero, the status identifier s x,y for the position (x,y) is equal a second value, if the weight parameter at the position (x,y) is smaller than zero, and the status identifier s x,y for the position (x,y) is equal to a third value, if the weight parameter at the position (x,y) is larger than 0.
6 . The decoder of claim 2 ,
wherein the plurality of weight parameters is arranged in a matrix, and a status identifier s x,y for a position (x,y) in the matrix is equal to a first value, if the position (x,y) is not available or the weight parameter at the position (x,y) is equal to zero, and the status identifier s x,y for the position (x,y) is equal to a second value, if the position (x,y) is available and the weight parameter at the position (x,y) is not equal to zero.
7 . The decoder of claim 1 , wherein the operations further comprise:
selecting a context for the decoding of a zero flag of the weight parameter in dependence on a distance of a closest non-zero weight parameter present in a predetermined direction, when seen from a currently decoded weight parameter.
8 . The decoder of claim 1 , wherein the operations further comprise:
selecting a context for the decoding of a zero flag of the weight parameter considering only a single one previously decoded weight parameter, which is adjacent to a currently decoded weight parameter.
9 . The decoder of claim 8 , wherein the operations further comprise:
determining a status identifier for the single one previously decoded weight parameter, wherein the status identifier for the single one previously decoded weight parameter equals to a first value, if the single one previously decoded weight parameter is not available or the weight parameter at the position (x,y) is equal to zero, equals to a second value, if the single one previously decoded weight parameter is smaller than zero, and equals to a third value, if the single one previously decoded weight parameter is larger than 0; and
wherein the context in dependence on the status identifier.
10 . The decoder of claim 1 , wherein the operations further comprise:
selecting a context associated with a zero value of the previously decoded weight parameter in case the previously decoded weight parameter is not available.
11 . The decoder of claim 1 ,
wherein the weight parameters are organized in rows and columns of a matrix,
wherein an order in which the weight parameters are decoded is along a first row of the matrix, then along a subsequent second row of the matrix, or
wherein an order in which the weight parameters are decoded is along a first column of the matrix, then along a subsequent second column of the matrix.
12 . A method for decoding weight parameters of a neural network, the method comprising:
acquiring a plurality of bits representing weight parameters of the neural network;
decoding the weight parameters of the neural network using a context-dependent arithmetic coding;
selecting a context for a decoding of a weight parameter, or for a decoding of a syntax element of a number representation of the weight parameter, in dependence on one or more previously decoded weight parameters and/or in dependence on one or more previously decoded syntax elements of a number representation of one or more weight parameters;
wherein the weight parameter, or a syntax element of the weight parameter, is decoded using the selected context; and
selecting different contexts in dependence on whether the previously decoded weight parameter is smaller than zero, equal to zero or larger than zero.
13 . A non-transitory computer readable medium storing a computer program indicating instructions that, when executed by at least one processor of a computing device, cause the computing device to perform a method for decoding weight parameters of a neural network, wherein the method comprises operations comprising:
acquiring a plurality of bits representing weight parameters of the neural network;
decoding the weight parameters of the neural network using a context-dependent arithmetic coding;
selecting a context for a decoding of a weight parameter, or for a decoding of a syntax element of a number representation of the weight parameter, in dependence on one or more previously decoded weight parameters and/or in dependence on one or more previously decoded syntax elements of a number representation of one or more weight parameters;
wherein the weight parameter, or a syntax element of the weight parameter, is decoded using the selected context; and
selecting different contexts in dependence on whether the previously decoded weight parameter is smaller than zero, equal to zero or larger than zero.
14 . An encoder for encoding weight parameters of a neural network, the encoder comprising:
a communication interface;
a memory storing instructions; and
a processor which is coupled to the communication interface and the memory, to execute the instructions stored in the memory to implement operations comprising:
obtaining a plurality of weight parameters of the neural network;
encoding the weight parameters of the neural network using a context-dependent arithmetic coding;
selecting a context for an encoding of a weight parameter, or for an encoding of a syntax element of a number representation of the weight parameter, in dependence on one or more previously encoded weight parameters and/or in dependence on one or more previously encoded syntax elements of a number representation of one or more weight parameters;
encoding the weight parameter, or a syntax element of the weight parameter, using the selected context; and
selecting different contexts in dependence on whether the previously encoded weight parameter is smaller than zero, equal to zero or larger than zero.
15 . A non-transitory computer-readable medium for storing data associated with a data stream, wherein the data stream comprises weight parameters of the neural network decodable using a decoder according to claim 1 .
16 . A non-transitory computer-readable medium for storing data associated with a data stream, wherein the data stream comprises weight parameters of the neural network encoded thereinto using an encoder according to claim 14 .