<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Cropping2D
[convolutional.Cropping2D.0] cropping ((1,1),(1,1)) on 3x5x4 input, data_format='channels_last'
Step1:  [convolutional.Cropping2D.1] cropping ((1,1),(1,1)) on 3x5x4 input, data_format='channels_first'
Step2:  [convolutional.Cropping2D.2] cropping ((4,2),(3,1)) on 8x7x6 input, data_format='channels_last'
Step3:  [convolutional.Cropping2D.3] cropping ((4,2),(3,1)) on 8x7x6 input, data_format='channels_first'
Step4:  [convolutional.Cropping2D.4] cropping (2,3) on 8x7x6 input, data_format='channels_last'
Step5:  [convolutional.Cropping2D.5] cropping 4 on 8x7x6 input, data_format='channels_last'
Step6:  export for Keras.js tests
<ASSISTANT_TASK:>
Python Code:
data_in_shape = (3, 5, 4)
L = Cropping2D(cropping=((1,1),(1, 1)), data_format='channels_last')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(250)
data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)
DATA['convolutional.Cropping2D.0'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
Explanation: Cropping2D
[convolutional.Cropping2D.0] cropping ((1,1),(1,1)) on 3x5x4 input, data_format='channels_last'
End of explanation
data_in_shape = (3, 5, 4)
L = Cropping2D(cropping=((1,1),(1,1)), data_format='channels_first')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(251)
data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)
DATA['convolutional.Cropping2D.1'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
Explanation: [convolutional.Cropping2D.1] cropping ((1,1),(1,1)) on 3x5x4 input, data_format='channels_first'
End of explanation
data_in_shape = (8, 7, 6)
L = Cropping2D(cropping=((4,2),(3,1)), data_format='channels_last')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(252)
data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)
DATA['convolutional.Cropping2D.2'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
Explanation: [convolutional.Cropping2D.2] cropping ((4,2),(3,1)) on 8x7x6 input, data_format='channels_last'
End of explanation
data_in_shape = (8, 7, 6)
L = Cropping2D(cropping=((4,2),(3,1)), data_format='channels_first')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(253)
data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)
DATA['convolutional.Cropping2D.3'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
Explanation: [convolutional.Cropping2D.3] cropping ((4,2),(3,1)) on 8x7x6 input, data_format='channels_first'
End of explanation
data_in_shape = (8, 7, 6)
L = Cropping2D(cropping=(2,3), data_format='channels_last')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(254)
data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)
DATA['convolutional.Cropping2D.4'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
Explanation: [convolutional.Cropping2D.4] cropping (2,3) on 8x7x6 input, data_format='channels_last'
End of explanation
data_in_shape = (8, 7, 6)
L = Cropping2D(cropping=1, data_format='channels_last')
layer_0 = Input(shape=data_in_shape)
layer_1 = L(layer_0)
model = Model(inputs=layer_0, outputs=layer_1)
# set weights to random (use seed for reproducibility)
np.random.seed(255)
data_in = 2 * np.random.random(data_in_shape) - 1
result = model.predict(np.array([data_in]))
data_out_shape = result[0].shape
data_in_formatted = format_decimal(data_in.ravel().tolist())
data_out_formatted = format_decimal(result[0].ravel().tolist())
print('')
print('in shape:', data_in_shape)
print('in:', data_in_formatted)
print('out shape:', data_out_shape)
print('out:', data_out_formatted)
DATA['convolutional.Cropping2D.5'] = {
    'input': {'data': data_in_formatted, 'shape': data_in_shape},
    'expected': {'data': data_out_formatted, 'shape': data_out_shape}
}
Explanation: [convolutional.Cropping2D.5] cropping 4 on 8x7x6 input, data_format='channels_last'
End of explanation
import os
filename = '../../../test/data/layers/convolutional/Cropping2D.json'
if not os.path.exists(os.path.dirname(filename)):
    os.makedirs(os.path.dirname(filename))
with open(filename, 'w') as f:
    json.dump(DATA, f)
print(json.dumps(DATA))
Explanation: export for Keras.js tests
End of explanation
<END_TASK>