python – How can I apply a 2D TensorFlow convolution (`tf.nn.conv2d ()`) to a single 2D image (without a batch)?

I would like to use the function tf.nn.conv2d () on a unique example, but the TensorFlow documentation seems to mention only the application of this transformation to a lot images.

The documentation mentions that the image of entry must be of form [batch, in_height, in_width, in_channels] and the core must be of shape [filter_height, filter_width, in_channels, out_channels]. However, what is the easiest way to perform a 2D convolution with an input form? [in_height, in_width, in_channels]?

Here is an example of the current approach, where img has the shape (height, width, channels):

img = tf.random_uniform ((10,10,3)) # a single image
img = tf.nn.conv2d ([img], core)[0] # create a batch of 1, then index the single example

I reshape the entry as follows:

[in_height, in_width, in_channels]->[1, in_height, in_width, in_channels]->[in_height, in_width, in_channels]

This sounds like an unnecessary and expensive operation when I am only interested in the transformation of an example.

Is there a simple / standard way to do it that does not require remodeling?