Skip to content

Instantly share code, notes, and snippets.

View ahmadmustafaanis's full-sized avatar

Ahmad Mustafa Anis ahmadmustafaanis

View GitHub Profile
# Socket Programming by Ahmad Mustafa Anis
import socket
class ServerSocket:
def __init__(self, type=socket.AF_INET, family=socket.SOCK_STREAM, port = 8080):
self.type = type
self.family = family
self.mySock = socket.socket(self.type, self.family) #Ipv4 and TCP Socket
self.mySock.bind((socket.gethostname(), port)) #Binded to local computer ip and 8080 port
import socket
class receveingSocket:
def __init__(self, port=8080):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)#ipv4 and tcp
self.sock.connect((socket.gethostname(), port)) #connects to local computer and port 8080
def send_lower_to_server(self):
#include <iostream>
#include <string>
#include <stack>
using namespace std;
class InduvivualWordsReverser {
private:
string h1;
stack < char > s1;
#include <iostream>
using namespace std;
struct node {
int data;
node* next;
node* back;
};
class LinkedList {
#include "BST.h"
node* BST::search(int x)
{
if (x == root->data)
{
return root;
}
node* temp = root;
while (temp)
from sklearn.datasets import load_iris
from tensorflow.keras.models import Sequential
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.layers import Dense
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
iris = load_iris()
X = iris.data
y = iris.target
y = to_categorical(y) #converting output to one-hot vector
model1 = Sequential([
Dense(512, activation='tanh', input_shape = X_train[0].shape),
Dense(512//2, activation='tanh'),
Dense(512//4, activation='tanh'),
Dense(512//8, activation='tanh'),
Dense(32, activation='relu'),
Dense(3, activation='softmax')
])
print(model1.summary())
model1.compile(optimizer='sgd',loss='categorical_crossentropy', metrics=['acc', 'mse'])
model2 = Sequential([
Dense(512, activation='tanh', input_shape = X_train[0].shape, kernel_regularizer='l1'), #Only change is here where we add kernel_regularizer
Dense(512//2, activation='tanh'),
Dense(512//4, activation='tanh'),
Dense(512//8, activation='tanh'),
Dense(32, activation='relu'),
Dense(3, activation='softmax')
])
model2.compile(optimizer='sgd',loss='categorical_crossentropy', metrics=['acc', 'mse'])
import numpy as np
from fastapi import FastAPI, Form
import pandas as pd
from starlette.responses import HTMLResponse
from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
import tensorflow as tf
import re
def preProcess_data(text): #cleaning the data
import numpy as np
import matplotlib.pyplot as plt
import cv2
def template_detection(image, template):
methods = ['cv2.TM_CCOEFF', 'cv2.TM_CCOEFF_NORMED', 'cv2.TM_CCORR',
'cv2.TM_CCORR_NORMED', 'cv2.TM_SQDIFF', 'cv2.TM_SQDIFF_NORMED']