Skip to content

Instantly share code, notes, and snippets.

View tarunk04's full-sized avatar
:octocat:
Focusing

Tarun Kumar tarunk04

:octocat:
Focusing
View GitHub Profile
@tarunk04
tarunk04 / digit-recognition-tutorial-cnn-99-67-accuracy.ipynb
Last active April 27, 2020 21:15
MNIST data set tutorial. In this notebook, I have covered the necessary steps to approach any Machine Learning Classification Problem. Included Image Visualization for better understanding. Quick Links to the functions I have used to explore it in depth. Basic techniques such as Confusion Matrix, Image Augmentation, etc.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tarunk04
tarunk04 / validate.py
Created May 7, 2020 10:23
check sudoku conditions
def validate_cell(self, sudoku_solved, val, i, j):
# getting index for block ( 9 blocks of 3x3 size)
block_i = i // 3
block_j = j // 3
# check block
for b_i in range(block_i * 3, block_i * 3 + 3):
for b_j in range(block_j * 3, block_j * 3 + 3):
if sudoku_solved[b_i][b_j] == val:
return False
@tarunk04
tarunk04 / solve_sudoku.py
Created May 7, 2020 10:27
recursive function
def __solve_backtrack__(self, i, j, visualize=False):
# Changing row if col index reaches end of the row
if j > 8:
j = 0
i += 1
# end condition
if i > 8:
if visualize == False:
eel.draw_sudoku(self.sudoku_solved)
return True
@tarunk04
tarunk04 / generate_solved_sudoku.py
Created May 7, 2020 11:12
generate_solved_sudoku
def __generator__(self, grid, i, j):
number = [1, 2, 3, 4, 5, 6, 7, 8, 9]
if j > 8:
j = 0
i += 1
# end condition
if i > 8:
return True
# skipping cell if the cell has already a number
@tarunk04
tarunk04 / generate_solved_sudoku.py
Created May 7, 2020 11:15
generate_solved_sudoku
def __generator__(self, grid, i, j):
number = [1, 2, 3, 4, 5, 6, 7, 8, 9]
if j > 8:
j = 0
i += 1
# end condition
if i > 8:
return True
# skipping cell if the cell has already a number
@tarunk04
tarunk04 / generating_puzzle.py
Created May 7, 2020 11:17
generating_puzzle by removing cell
def generate_sudoku(self, level=2):
# generate solved sudoku
self.generate_solved_sudoku()
if level == 1:
remove_cell = random.randint(32, 38)
if level == 2:
remove_cell = random.randint(40, 46)
if level == 3:
remove_cell = random.randint(48, 52)
if level == 4:
@tarunk04
tarunk04 / script.js
Created May 7, 2020 11:35
Functions exposed to python
// JavaScript functions exposed to python
eel.expose(draw_sudoku)
eel.expose(update_sudoku)
// Function for drawing sudoku
function draw_sudoku(data) {
for (i = 0; i < 81; i++) {
// row and col values for corresponding i values
row = ~~(i / 9);
col = i % 9;
@tarunk04
tarunk04 / App.py
Created May 7, 2020 11:45
Python functions exposed to javascript
# python functions exposed to javascript
@eel.expose
def generate_new_sudoku(level):
global current_sudoku_onboard
# generating sudoku for required level
current_sudoku_onboard = Sudoku().generate_sudoku(int(level))
# drawing sudoku by calling javascript function from python
eel.draw_sudoku(current_sudoku_onboard)
@tarunk04
tarunk04 / example1-code.py
Last active February 4, 2021 18:49
Code for progress bar
#Importing the progress bar library
from progress import Progress as P
import time
images = 2478 # number of images to process
# Create a progress bar instance
p = P(images,mode = 'no-bar')
# Creating one element for image counter
counter = P.Element("Images Processed", 0)
#Importing the progress bar library
from progress import Progress as P
import time
import random
p = P(70, mode='bar') # progress bar object
# defining progress bar elements
epoch = P.Element("Epoch", 0)