Skip to content

Instantly share code, notes, and snippets.

Model Approach 1 2 3 4 5
Number of Top Neighbors
1 of 5 18.54% 11.14% 5.86% 4.73% 5.83%
5 of 5 1.55% 15.73% 45.74% 57.10% 43.78%
Avg 2.25 3.00 3.84 4.05 3.81
Model Approach Top-1 Acc Change Top-5 Acc Change
2 +16.74 +23.42
3 +17.13 +23.49
4 +16.40 +22.42
5 +16.73 +23.64
Model Approach True Class Top 20 Nearest Neighbors All Other
One hot encoding 1.0 0.0 0.0
Uniform label smoothing 0.9 0.1/4349 0.1/4349
Uniform label smoothing 0.9 0.1/20 0.0
Label smoothing Based on semantic similarities Based on semantic similarities 0.0
Label smoothing + Curriculum learning Based on semantic similarities Based on semantic similarities 0.0
@binwei
binwei / baseline_clip_pt_finetuner.py
Last active February 14, 2022 05:12
implementation of finetuning fused embedding from CLIP
def forward(self, x):
image_features, text_features = x
concat_features = torch.cat((image_features, text_features), dim=-1)
weights = torch.nn.functional.softmax(self.atten_p(concat_features), dim=-1)
fused_feature = weights[:, 0].unsqueeze(1) * image_features + weights[:, 1].unsqueeze(1) * text_features
logits = self.ft_network(fused_feature)
return logits
def training_step(self, batch, batch_idx):
import acm.graphics.*;
import acm.program.*;
public class BouncingBall extends GraphicsProgram {
/**
* Initialize the ball and its velocity components
*/
public void init() {
ball = new GBall(BALL_RADIUS);
add(ball, getWidth() / 2, getHeight() / 2);
@binwei
binwei / CassandraTest.scala
Created August 25, 2014 17:29
Run Spark example with Cassandra using the New Hadoop API and Cassandra support for Hadoop.
// paste the code in spark shell
import java.nio.ByteBuffer
import java.util.SortedMap
import scala.collection.JavaConversions._
import org.apache.cassandra.db.IColumn
import org.apache.cassandra.hadoop.ColumnFamilyOutputFormat
import org.apache.cassandra.hadoop.ConfigHelper