Example output
1:
// Initializing an array with some values
int[] myArray = {1, 2, 3, 4, 5};
// Adding a new element to the end of the array
int newValue = 6;
myArray = Arrays.copyOf(myArray, myArray.length + 1);
myArray[myArray.length - 1] = newValue;
// Print the updated array
System.out.println(Arrays.toString(myArray));
----------
2:
import tensorflow as tf
# Load the data
mnist = tf.keras.datasets.mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
# Normalize the data
train_images = train_images / 255.0
test_images = test_images / 255.0
# Define the model
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10)
])
# Define the loss function
loss_fn = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True)
# Compile the model
model.compile(optimizer='adam', loss=loss_fn, metrics=['accuracy'])
# Train the model
model.fit(train_images, train_labels, epochs=5)
# Evaluate the model
model.evaluate(test_images, test_labels, verbose=2)