This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]]) | |
Y = np.array([[0], [1], [1], [0]]) | |
x = tf.placeholder(tf.float32, [None, 2]) | |
y = tf.placeholder(tf.float32, [None, 1]) | |
w = tf.Variable(tf.random_normal([2, 1])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with tf.Session() as sess: | |
sess.run(tf.global_variables_initializer()) | |
for i in range(1000): | |
for j in range(4): | |
sess.run(train, feed_dict={x: np.expand_dims(X[j], 0), y: np.expand_dims(Y[j], 0)}) | |
loss_ = sess.run(loss, feed_dict={x: X, y: Y}) | |
print("step: %d, loss: %.3f" % (i, loss_)) | |
print("X: %r" % X) | |
print("pred: %r" % sess.run(out, feed_dict={x: X})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
# 输入训练数据,这里是python的list, 也可以定义为numpy的ndarray | |
x_data = [[1., 0.], [0., 1.], [0., 0.], [1., 1.]] | |
x = tf.placeholder(tf.float32, shape=[None, 2]) # 定义占位符,占位符在运行图的时候必须feed数据 | |
y_data = [[1], [1], [0], [0]] # 训练数据的标签,注意维度 | |
y = tf.placeholder(tf.float32, shape=[None, 1]) | |
# 定义variables,在运行图的过程中会被按照优化目标改变和保存 | |
weights = {'w1': tf.Variable(tf.random_normal([2, 16])), | |
'w2': tf.Variable(tf.random_normal([16, 1]))} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import json | |
import hashlib | |
import tempfile | |
import shutil | |
import logging | |
import subprocess as sp | |
from pathlib import Path | |
from email.utils import parsedate_to_datetime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import shutil | |
import os | |
import torch | |
import torch.nn as nn | |
import torchvision.datasets as datasets | |
import torchvision.transforms as transforms | |
import torchvision.models as models | |
import torch.backends.cudnn as cudnn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tokenizers import Tokenizer | |
from tokenizers.models import WordLevel | |
from tokenizers.trainers import WordLevelTrainer | |
from tokenizers.pre_tokenizers import WhitespaceSplit | |
from tokenizers.processors import RobertaProcessing | |
from model.roberta import RobertaTokenizerFast | |
SPECIAL_TOKENS = ["<s>", "<pad>", "</s>", "<unk>", "<mask>"] | |
UNK_TOKENS = "<unk>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (C) 2017 | |
# | |
# Written by Ashley Lesdalons <ashley.lesdalons@etu.univ-grenoble-alpes.fr> | |
# | |
# ========LICENCE======== | |
# This script is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Lesser General Public | |
# License as published by the Free Software Foundation; either | |
# version 2.1 of the License, or (at your option) any later version. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#TODO This script performs the static analysis part of VUzzer. For a given binary, it computes a weight of each basic block of each function. It also extracts immediates from each CMP instruction. | |
#@author: Sanjay Rawat | |
#@category: VUzzer Static Analysis | |
#@keybinding | |
#@menupath tools.Static Analysis.VUzzer | |
#@toolbar | |
#TODO Add User Code Here | |
#from ghidra.program.model.block import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------------- | |
# This script computes a weight value for each basis block of each functions. the algorithm is: | |
# 1. for each outgoing edge (i->j) of a BB i, assign a equal probability Eij, i.e. Eij= 1/n for a "n edges" BB. | |
# 2. assign root BB a weight of 1 (this is always reachable). | |
# 3. for each BB j, its weight is: W(j) = SUM (over i \in Pred(j)) W(i)*Eij | |
# after completion, it creates a pickle file that contains weights of BBs. | |
##Addintion: it also scans each function to find CMD instruction and check if it has some byte to compare with. All such bytes are saved in a pickle file that will be used to mutate inputs. | |
import idaapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
import multiprocessing as mp | |
from itertools import repeat | |
def build_db(db_name): | |
conn = sqlite3.connect(db_name) | |
cursor = conn.cursor() | |
cursor.execute('''CREATE TABLE IF NOT EXISTS EMPLOYEE ( | |
ID INTEGER PRIMARY KEY, |