MulaiMulai sekarang secara gratis

One dimensional convolutions

A convolution of an one-dimensional array with a kernel comprises of taking the kernel, sliding it along the array, multiplying it with the items in the array that overlap with the kernel in that location and summing this product.

Latihan ini adalah bagian dari kursus

Image Modeling with Keras

Lihat Kursus

Petunjuk latihan

Multiply each window in the input array with the kernel and sum the multiplied result and allocate the result into the correct entry in the output array (conv).

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

array = np.array([1, 0, 1, 0, 1, 0, 1, 0, 1, 0])
kernel = np.array([1, -1, 0])
conv = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

# Output array
for ii in range(8):
    conv[ii] = (____ * array[____:____+____]).sum()

# Print conv
print(conv)
Edit dan Jalankan Kode