Skip to content

Instantly share code, notes, and snippets.

View ShakeDewan's full-sized avatar
⚙️
In Production

Shekhar (Shake) Dewan ShakeDewan

⚙️
In Production
View GitHub Profile
@ShakeDewan
ShakeDewan / grpo_demo.py
Created February 7, 2025 11:56 — forked from willccbb/grpo_demo.py
GRPO Llama-1B
# train_grpo.py
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
# Load and prep dataset
@ShakeDewan
ShakeDewan / contemplative-llms.txt
Created January 9, 2025 14:24 — forked from Maharshi-Pandya/contemplative-llms.txt
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
@ShakeDewan
ShakeDewan / spp_deep_network.py
Created January 23, 2020 03:53 — forked from yardstick17/spp_deep_network.py
Spatial pyramid pooling (SPP) is a pooling strategy to result in an output of fixed size. It will turn a 2D input of arbitrary size into an output of fixed dimension. Hence, the convolutional part of a DNN can be connected to a dense part with a fixed number of nodes even if the dimensions of the input image are unknown.
CUSTOM_OUTPUT_CATEGORIES = 2
import keras.backend as K
from keras.engine.topology import Layer
class SpatialPyramidPooling(Layer):
'''Spatial pyramid pooling layer for 2D inputs.
See Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition,
K. He, X. Zhang, S. Ren, J. Sun
# Arguments
from keras.models import Sequential
from keras.layers import Dense
x, y = ...
x_val, y_val = ...
# 1-dimensional MSE linear regression in Keras
model = Sequential()
model.add(Dense(1, input_dim=x.shape[1]))
model.compile(optimizer='rmsprop', loss='mse')
@ShakeDewan
ShakeDewan / hexgame.java
Created October 26, 2018 16:19 — forked from salamander2/hexgame.java
Hexagonal Grid in Java
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
/**********************************
This is the main class of a Java program to play a game based on hexagonal tiles.
The mechanism of handling hexes is in the file hexmech.java.
Written by: M.H.
Date: December 2012