A semiconductor device and electronic device with reduced power consumption are provided. The semiconductor device includes an encoder, a decoder, and a source driver circuit. An output terminal of the encoder is electrically connected to an input terminal of the source driver circuit, and an output terminal of the source driver circuit is electrically connected to an input terminal of the decoder. The encoder converts input image data into feature-extracted image data, and the decoder restores the feature-extracted image data to the original image data. In addition, provision of a circuit that performs convolution processing using a weight filter for the encoder enables calculation using a convolutional neural network.