This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_mlp(dim, regress=False): | |
| model = Sequential() | |
| model.add(Dense(8, input_dim=dim, activation="relu")) | |
| model.add(Dense(4, activation="relu")) | |
| if regress: | |
| model.add(Dense(1, activation="linear")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_cnn( height, width, depth, filters=(16, 32, 64), regress=False): | |
| filters = np.asarray(filters) | |
| input_shape = (height, width, depth) | |
| chanDim = -1 | |
| inputs = Input(shape=input_shape) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from tkinter import * | |
| from tkinter import ttk | |
| from PIL import ImageTk,Image | |
| from tkinter.filedialog import askopenfilename | |
| import cv2 | |
| import uuid | |
| import time | |
| import tkinter | |
| import PIL.Image, PIL.ImageTk | |
| from PIL import Image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Min Steps in Infinite GridBookmark Suggest Edit | |
| import math as mat | |
| def maxsteps(x,y): | |
| steps =0 | |
| cov = (x[0],y[0]) | |
| n = len(x) | |
| for i in range(1,n): | |
| diffX = mat.fabs(cov[0]-x[i]) | |
| diffy = mat.fabs(cov[1]-y[i]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def maxset(A): | |
| minsum =0 | |
| maxsum = 0 | |
| minset=[] | |
| maxseT=[] | |
| for i in A : | |
| if i >0: | |
| minsum+=i | |
| minset.append(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sm(arr,val): | |
| low = 0 | |
| hig = len(arr)-1 | |
| while low < hig: | |
| sum = arr[low]+arr[hig] | |
| if sum == val : | |
| return True | |
| if sum < val : | |
| low+=1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def find_sum_of_two_2(A, val): | |
| i = 0 | |
| j = len(A) - 1 | |
| while i < j: | |
| s = A[i] + A[j] | |
| if s == val: | |
| return True | |
| if s < val: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def binary_search_rec(a, key, low, high): | |
| if low > high: | |
| return -1 | |
| mid = low + ((high - low) / 2) | |
| if a[mid] == key: | |
| return mid | |
| elif key < a[mid]: | |
| return binary_search_rec(a, key, low, mid - 1) | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #How to check if a given number is a power of 2 ? | |
| n = int(raw_input("enter number")) | |
| count =0 | |
| while n != 0 : | |
| n = n & (n - 1) | |
| count+=1 | |
| print(count) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #How to check if a given number is a power of 2 ? | |
| inp = int(raw_input("enter number")) | |
| while inp%2 == 0 : | |
| inp //=2 | |
| answer = 'power of 2 ' if inp == 1 else 'not power of 2 ' | |
| #pritn the answer | |
| print answer |
NewerOlder