when it is utilized for its purpose (for example, the test data may include an image that is to be compressed). Overfitting is for example beneficial when there is a sudden domain shift in the data, and especially if the domain shift happens continuously and gradually. A data domain shift means that the data domain or context or type changes, for example a camera may start to capture data from a different-looking scene, where the difference may be in the lighting, in the type or amount of objects, in the type or amount of motion, in the type or amount of texture, etc. A neural network which is trained on a different data domain than the one on which it is run may perform sub-optimally. The present embodiments relate to neural image (or video) compression. This may include using neural networks for compressing and/or de-compressing images (or other data), with high compression gain and a high reconstruction quality. The compression gain can be measured by the number of bits of the encoded or compressed representation. The reconstruction quality can be measured by a certain metric which compares the original image and the de-compressed or reconstructed image. The various embodiments provide a set of techniques for optimizing image compression auto-encoders on the specific input data (“overfitting”), and in a way which improves the encoding speed and the reconstruction quality, or alternatively improves the encoding speed and the compression gain. In the various embodiments of the solution, an auto-encoder is used as an example. The auto-encoder is optimized (i.e., overfitted) to a specific input data on which it is used. This optimization may be performed at network utilization time, not at training time. According to a first embodiment of the present solution, the encoding is sped up via sequential neural encoder network overfitting. According to a second embodiment, the decoding quality is improved via neural decoder network overfitting. In general, the neural decoder network should not be optimized for a certain input data because sending the data to the decoder for performing the optimization may require too many bits. However, in the second embodiment, a strategy allowing trade-offs between bitrates and decoding quality is introduced.