Skip to content

Instantly share code, notes, and snippets.

View sicongzhao's full-sized avatar

Sicong Zhao sicongzhao

View GitHub Profile
{
"_format": "hh-sol-artifact-1",
"contractName": "Greeter",
"sourceName": "contracts/Greeter.sol",
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "_greeting",
constructor() ERC721("Pepsi Mic Drop", "PEPSIMICDROP") {
reserveMicDropsId = 1; // item 1-50
micDropsId = 51; // item 51-1893
}
/***
By accepting the limited-edition Pepsi Mic Drop content ("Content") in the form of this non-fungible token ("NFT"), recipient acknowledges and agrees to the following terms and conditions (these "Terms"):
The Content is the property of or licensed to PepsiCo, Inc. ("Owner") and all right, title, and interest (including all copyright, trademark, name, likeness, art, design, drawings and/or other intellectual property) included in and/or associated with the Content are owned by Owner or its licensors. Receipt of the Content or this NFT does not give or grant recipient any right, license, or ownership in or to the Content other than the rights expressly set forth herein. Owner reserves all rights (including with respect to the copyright, trademark, name, likeness, art, design, drawings and/or other intellectual property) in and to the Content not expressly granted to recipient herein. Expressly conditioned on recipient's compliance with its obligations hereunder, recipient of this NFT is granted a limited,
import matplotlib.pyplot as plt
from sklearn.datasets.samples_generator import make_blobs
from sklearn.cluster import KMeans
# Generate data
X, _ = make_blobs(n_samples=300, centers=5,
cluster_std=2, random_state=0)
# Fit K-means with different choice of K,
# and save the corresponding S
from sklearn.cluster import KMeans
import numpy as np
# Generate data to be clustered
X = np.array([[1, 2], [1, 4], [1, 0],
[10, 2], [10, 4], [10, 0]])
# Init K-menas model and clustering
kmeans = KMeans(n_clusters=2).fit(X)
@sicongzhao
sicongzhao / dilation.py
Created April 25, 2020 07:19
Demystify Transposed Convolutional Layer
# Create a TCL layer with kernel_size=2, stride=2, dilation=2
transConv5 = nn.ConvTranspose2d(1, 1, 2, stride=2, dilation=2, bias=False)
# Set kernel weights to be 1
transConv5.weight.data = torch.ones(1,1,2,2)
# Calculate
transConv5(input_data)
# Output:
# tensor([[[[ 1., 0., 3., 0., 2.],
# [ 0., 0., 0., 0., 0.],
@sicongzhao
sicongzhao / output_padding.py
Created April 25, 2020 06:39
Demystify Transposed Convolutional Layer
# Create a TCL layer with stride=2, output_padding=1
transConv4 = nn.ConvTranspose2d(1, 1, 3, stride=2, output_padding=1, bias=False)
# Set kernel weights to be 1
transConv4.weight.data = torch.ones(1,1,3,3)
# Calculate
transConv4(input_data)
# Output:
# tensor([[[[ 1., 1., 3., 2., 2., 0.],
# [ 1., 1., 3., 2., 2., 0.],
@sicongzhao
sicongzhao / padding.py
Last active April 25, 2020 06:08
Demystify Transposed Convolutional Layer
# Create a TCL layer with stride=2, padding=1
transConv3 = nn.ConvTranspose2d(1, 1, 3, stride=2, padding=1, bias=False)
# Set kernel weights to be 1
transConv3.weight.data = torch.ones(1,1,3,3)
# Calculate
transConv3(input_data)
# Output:
# tensor([[[[ 1., 3., 2.],
# [ 4., 10., 6.],
@sicongzhao
sicongzhao / stride.py
Last active April 25, 2020 05:48
Demystify Transposed Convolutional Layer
# Create a TCL layer with stride=2
transConv2 = nn.ConvTranspose2d(1, 1, 3, stride=2, bias=False)
# Set kernel weights to be 1
transConv2.weight.data = torch.ones(1,1,3,3)
# Calculate
transConv2(input_data)
# Output:
# tensor([[[[ 1., 1., 3., 2., 2.],
# [ 1., 1., 3., 2., 2.],
@sicongzhao
sicongzhao / basic.py
Last active April 25, 2020 05:18
Demystify Transposed Convolutional Layers
import torch
from torch import nn
# Create 2x2 input tensor
input_data = torch.tensor([[[[1.,2.],[3.,4.]]]])
# Create a TCL layer with kernel_size=3
transConv1 = nn.ConvTranspose2d(1, 1, 3, bias=False)
# Set kernel weights to be 1
transConv1.weight.data = torch.ones(1,1,3,3)
# Calculate the output