1. TensorFlow – Image Classification (MNIST Digits) python Copy Edit import tensorflow as tf from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten # Load and preprocess data (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train, x_test = x_train / 255.0 , x_test / 255.0 # Build model model = Sequential([ Flatten(input_shape=( 28 , 28 )), Dense( 128 , activation= 'relu' ), Dense( 10 , activation= 'softmax' ) ]) # Compile and train model. compile (optimizer= 'adam' , loss= 'sparse_categorical_crossentropy' , metrics=[ 'accuracy' ]) model.fit(x_train, y_train, epochs= 5 ) # Evaluate model.evaluate(x_test, y_test) 2. PyTorch – Sentiment Analysis with LSTM python Copy Edit import torch import torch.nn as nn from torchtext.legacy.datasets import IMDB from torchtext.legacy.data import Field, BucketIterator # Defin...
Comments
Post a Comment