0
0
Prompt Engineering / GenAIml~10 mins

Why AI image generation creates visual content in Prompt Engineering / GenAI - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library used for AI image generation.

Prompt Engineering / GenAI
import [1]
Drag options to blanks, or click blank then click option'
Atorch
Bnumpy
Ctensorflow
Dmatplotlib
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing numpy or matplotlib which are not primarily for AI model building.
2fill in blank
medium

Complete the code to define a simple neural network layer for image generation.

Prompt Engineering / GenAI
layer = torch.nn.Linear([1], 256)
Drag options to blanks, or click blank then click option'
A512
B128
C1024
D784
Attempts:
3 left
💡 Hint
Common Mistakes
Using 512 or 1024 which are common hidden layer sizes but not input size here.
3fill in blank
hard

Fix the error in the code to generate an image tensor with the right shape.

Prompt Engineering / GenAI
image = torch.randn([1], 3, 64, 64)
Drag options to blanks, or click blank then click option'
A3
B1
C64
D256
Attempts:
3 left
💡 Hint
Common Mistakes
Using 3 which is the number of color channels, not batch size.
4fill in blank
hard

Fill both blanks to create a dictionary that maps image labels to their pixel counts.

Prompt Engineering / GenAI
pixel_counts = {label: [1] for label, pixels in images.items() if len(pixels) [2] 1000}
Drag options to blanks, or click blank then click option'
Alen(pixels)
B>
C<
Dsum(pixels)
Attempts:
3 left
💡 Hint
Common Mistakes
Using sum instead of len, or using < instead of >.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that selects images with width greater than 50.

Prompt Engineering / GenAI
selected_images = {name: data for name, data in dataset.items() if data['width'] [1] 50 and data['height'] [2] 50 and data['channels'] == [3]
Drag options to blanks, or click blank then click option'
A>
B<
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > or wrong channel number.