This repository contains-
A deep neural network implemented in PyTorch for recognizing handwritten digits from the MNIST dataset.
- Introduction
- Installation
- Usage
- Network Architecture
- Hyperparameters
- Training
- Testing
- Results
- Troubleshooting
This repository contains the source code for a deep neural network designed to classify handwritten digits using the MNIST dataset. The code is built with PyTorch and provides functionalities for training, testing, and evaluating the model.
- torch.manual_seed(100)
-
Clone the repository:
git clone https://github.com/SalehAhmedShafin/Test-for-Middle-Python-Developer-Machine-Learning-AI cd https://github.com/SalehAhmedShafin/Test-for-Middle-Python-Developer-Machine-Learning-AI
-
Install dependencies:
pip install torch torchvision numpy matplotlib scikit-learn
- Python 3.x
- PyTorch (install via
pip install torch
) - torchvision (install via
pip install torchvision
) - Other dependencies: NumPy, Matplotlib, Scikit-learn (install via
pip install numpy matplotlib scikit-learn
)
The neural network architecture is defined in the DeepNeuralNetworkModel class. It consists of three hidden layers with ReLU activation functions and an output layer.
Customize hyperparameters according to the requirements. Important hyperparameters include num_hidden, learning_rate, num_epochs, and batch_size.
- num_epochs = int(num_iters / (len(train_dataset) / batch_size))
The training process involves iterating over the training dataset, computing the loss, and updating the model parameters using gradient descent. The training loop is implemented in this file.
Testing the model involves evaluating its performance on a separate test dataset. The testing code is implemented in this same file.
After training and testing, i can analyze the results, including accuracy, precision, recall, and F1-score, to assess the model's performance.
- Accuracy: 97.78%
- Precision: 0.9780, Recall: 0.9778, F1-score: 0.9778
If encounter any issues, please check the following:
- Ensure all dependencies are installed.
- Verify that the datasets are correctly loaded and preprocessed.
- Check for typos or errors in the configuration files.
This repository contains Python code for interacting with a user database using SQLite. The code includes functions for inserting, updating, deleting, and retrieving user data.
- Python installed on your system.
- SQLite database library (
sqlite3
) included with Python.
-
Clone or download the repository.
-
Ensure that the required Python packages are installed:
pip install sqlite3
-
Open the Python script or Jupyter notebook containing the code in your preferred editor.
The database consists of a single table named users
with the following structure:
id
(Primary Key): Unique identifier for each user.username
: User's username.email
: User's email address.
-
email_check(email)
- Validates an email address using a regular expression.
-
insert_user(username, email)
- Inserts a new user into the
users
table, ensuring data validity.
- Inserts a new user into the
-
update_user(user_id, new_email)
- Updates the email of a user with a specific
user_id
.
- Updates the email of a user with a specific
-
delete_user(user_id)
- Deletes a user with a specific
user_id
from theusers
table.
- Deletes a user with a specific
-
all_users()
- Retrieves and prints information about all users in the
users
table.
- Retrieves and prints information about all users in the
-
show_user(user_id)
- Retrieves and returns information about a specific user with the given
user_id
.
- Retrieves and returns information about a specific user with the given
-
Import the Code:
- Import the functions into your Python script or Jupyter notebook:
import sqlite3
-
Establish Database Connection:
- Create a connection and cursor:
conn = sqlite3.connect('User_Database.db') cursor = conn.cursor()
-
Use the Functions:
- Utilize the functions for various user database interactions.
-
Commit Changes and Close Connection:
- Always commit changes and close the connection when done:
conn.commit() cursor.close() conn.close()
# Insert Users
insert_user('Saleh', 'saleh@gmail.com')
insert_user('Shafin', 'shafin@gmail.com')
# Display All Users
print("All Users:")
all_users()
# Update User Email
update_user(1, 'ahmedsaleh@gmail.com')
# Show User Information
print("User ID 1 is: ", show_user(1))
# Delete User
delete_user(2)
print("User with ID 2 deleted Successfully.")
# Display All Users Again
print("All Users After Deletion:")
all_users()
This Python script demonstrates the integration of the Google Maps JavaScript API using Selenium. It generates a simple HTML file containing a Google Map and opens it in a web browser for visualization.
- Google Maps Integration: Embeds a Google Map in an HTML file using the Google Maps JavaScript API.
- Dynamic API Key: Allows users to replace the placeholder API key with their own Google Maps API key.
- Selenium Automation: Utilizes Selenium to open the generated HTML file in a web browser.
- Installation
- Usage
- Customization
- Configuration
- Error Handling
- Logging
- Troubleshooting
- Acknowledgments
- Python installed (Download Python)
- Chrome WebDriver installed (Download Chrome WebDriver)
pip install selenium
- Replace API Key:
- Replace the placeholder API key ('YOUR_API_KEY') in the script with your valid Google Maps API key.
- Run the Script:
- Ensure that the Chrome WebDriver is in system's PATH.
- The script will generate an HTML file (google_maps.html) and open it in a Chrome browser.
- Adjust Map Settings:
- Modify the initMap function in the script to customize the initial center and zoom level of the map.
- API Key Configuration:
- Store API keys and other configuration parameters in a configuration file for better management.
- Exception Handling:
- The script includes basic exception handling. Ensure to handle exceptions appropriately in a production environment.
- Logging:
- The script includes basic logging for informational purposes. Adjust the logging configuration based on your needs.
- WebDriver Issues:
- If the script fails due to WebDriver issues, ensure the correct path to the Chrome WebDriver is specified. API Key Errors:
If the map doesn't load, check the browser console for any errors related to the Google Maps API key.
- The script uses Selenium for browser automation (Selenium).
- Google Maps API documentation: Google Maps JavaScript API Documentation