Skip to content

Instantly share code, notes, and snippets.

View arshren's full-sized avatar

Renu arshren

View GitHub Profile
@arshren
arshren / CatrPole_A2C.py
Created February 12, 2023 15:38
Advantage Actor Critic Pytorch code
#Import required Libraries
import gym
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import matplotlib.pyplot as plt
# Create the Actor Network
@arshren
arshren / RL_Q_Learning.py
Created October 29, 2022 10:43
Q-Learning
# Import required libararies
import gym
import matplotlib.pyplot as plt
import random
import numpy as np
from IPython.display import clear_output
#Create an instance of the the Taxi-v3 environment
env= gym.make("Taxi-v3").env
# Creating the q-table
# Fibonaci of 5 using recursion
def calc_fibonaci(n):
if n<=1:
return n
return calc_fibonaci(n-1) + calc_fibonaci(n-2)
print(calc_fibonaci(6))
# Memoization
def calc_fibonaci(n):
cache=[-1 for x in range(n+1)]
# Import libararies
import numpy as np
import pandas as pd
import os
import torch_geometric.transforms as T
from torch_geometric.datasets import Planetoid
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F
# import the necessary packages
from scipy.spatial import distance as dist
import numpy as np
import imutils
from imutils import contours
from imutils import perspective
import cv2
# detect aruco marker
def findArucoMarkers(img, markerSize = 6, totalMarkers=100, draw=True):
# importing libraries
from PIL import Image
import numpy as np
import cv2
import math
# setting variables
tracking_people={}
person_id=0
frame_num = 0
import numpy as np
import cv2
frame_count=0
# Open the Video
video = cv2. VideoCapture('people_motion.avi')
# read the fiurst frame of the video as the initial background image
ret, Prev_frame= video.read()
---
title: "Titanic Data Analysis"
output: html_document
author: Authored by Renu
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Data Analysis of Titanic dataset using R Markdown
@arshren
arshren / Keras_Model_Subclass
Created September 16, 2021 11:14
Keras Model Creation using Model Subclass
#Import required libraries
import tensorflow as tf
from keras.datasets import mnist
#Creating the MNIST Dataset
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test= x_train/255.0, x_test/255.0
x_train=x_train[...,tf.newaxis].astype('float32')
x_test=x_test[...,tf.newaxis].astype('float32')
@arshren
arshren / Keras_Functional_API
Created September 16, 2021 11:01
Code snippet for building model using Keras Functional API
#Import required libraries
import tensorflow as tf
from keras.datasets import mnist
#Creating the MNIST Dataset
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test= x_train/255.0, x_test/255.0
x_train=x_train[...,tf.newaxis].astype('float32')
x_test=x_test[...,tf.newaxis].astype('float32')