Information Retrieval basis
Precision and RecallWe use precision and recall as the measurements to estimate the efficiency of a retrieval system.
Now there is a ‘contingency’ table.
and now we define the measurements using formulas.
& PRECISION = \frac{|A\cap B|}{|B|} \\
& RECALL = \frac{|A\cap B|}{|A|} \\
& FALLOUT = \frac{|\overline {A} \cap B|}{|\overline A|}and There is a function relationship between all three involving a parameter called generality(G), which is a measure of the density of the relevant documents in ...
3.3 线性回归的简洁实现
3.3 线性回归的简洁实现1234import numpy as npimport torchfrom torch.utils import data#新导入一个data包from d2l import torch as d2l
3.3.1 生成数据集123true_w = torch.tensor([2, -3.4])true_b = 4.2features, labels = d2l.synthetic_data(true_w, true_b, 1000)#生成1000行数据,给出真实的特征和最后的结果
3.3.2 读取数据集1234567#we use the api to read data and we apply the features and labels as parameters of api, assigning batch_size by #data_iterdef load_array(data_arrays, batch_size, is_train=True): #@ #is_train represents whether the data wil ...
3.1 Linear regression
3.1.2 向量化加速123456%matplotlib inlineimport mathimport timeimport numpy as npimport torchfrom d2l import torch as d2l
1234n = 10000#10000维向量a = torch.ones(n)b = torch.ones(n)a, b
(tensor([1., 1., 1., ..., 1., 1., 1.]),
tensor([1., 1., 1., ..., 1., 1., 1.]))
12345678910111213141516171819202122232425class Timer():#@save """记录多次运行时间""" def __init__(self): self.times = [] self.start() def start(self): """启动计时器"& ...
2.6 Probability and Statistics
2.6 Probability and Statistics12345%matplotlib inlineimport randomimport torchfrom torch.distributions.multinomial import Multinomialfrom d2l import torch as d2l
12345num_toss = 100heads = sum([random.random() > 0.5 for _ in range(100)])#random() between 0 and 1tails = num_toss - headsprint("heads tails: ", [heads, tails])#完成了一个抽样过程,利用random函数
heads tails: [59, 41]
123fair_probs = torch.tensor([0.5, 0.5])Multinomial(100, fair_probs).sample()#We take 100 draws and set the probility ...
2.4 calculus with pytorch
2.4 Calculus12345678%matplotlib inline#This is a magic command in order to display the function curves directly in the notebook but not interactively.import numpy as npfrom matplotlib_inline import backend_inlinefrom d2l import torch as d2ldef f(x): return 3 * x ** 2 - 4 * x
123456789def numerical_lim(f, x, h): return (f(x + h) - f(x)) / hh = 0.1for i in range(5): print(f'h = {h:.5f}, numerical limit = {numerical_lim(f, 1, h):.5f}') #namely figure out th ...
lab-hackthebox-Archetype-windowsRCE
首先用openvpn连接到vpn服务,然后进行常规扫描
12nmap -sC -sV ipnmap -sS -Pn -n -p- --open ip --min-rate=5000
综合两次扫描结果,我们会发现很多服务
可以看出又是smb服务,那么我们又要用smbclient来看共享文件夹。
123smbclient -N -L \\\\ip\\-N:no password login-L: probe for services in target ip
然后我们进入没有权限限制的backups目录。
1smbclient -N \\\\ip\backups
发现一个prod.dtsConfig文件,我们get下来并且查看。这个文件是我们登陆smb会话时,在目录中自动保存的。
1get prod.dtsConfig
拿到用户名密码
1用户名sql_svc密码Mag4c0rp123主机ARCHETYPE
我们需要连接到microsoft sql server简称mssql
这里采用通用连接工具Impacket tool可在github上下载,或者
1python -m pip ins ...
Linear Algebra with pytorch
2.3.1 Scalars12345import torchx = torch.tensor(3.0)y = torch.tensor(2.0)x + y, x * y, x / y, x ** y
(tensor(5.), tensor(6.), tensor(1.5000), tensor(9.))
2.3.2 Vectors123x = torch.arange(3)x#It will start from 0 to 2.
tensor([0, 1, 2])
1234x[2]len(x)x.shape#foundamental operations.
torch.Size([3])
2.3.3 Matrices12A = torch.arange(6).reshape(3, 2)A, A.T
(tensor([[0, 1],
[2, 3],
[4, 5]]),
tensor([[0, 2, 4],
[1, 3, 5]]))
123A = torch.tensor([[1, 2, 3], [2, 0, 4], [3, 4, 5 ...
homework1 preprocess dataset
123456import torchimport osimport pandas as pddata_file = os.path.join('.', 'data', 'abalone.csv')data = pd.read_csv(data_file)print(data)
M 0.455 0.365 0.095 0.514 0.2245 0.101 0.15 15
0 M 0.350 0.265 0.090 0.2255 0.0995 0.0485 0.0700 7
1 F 0.530 0.420 0.135 0.6770 0.2565 0.1415 0.2100 9
2 M 0.440 0.365 0.125 0.5160 0.2155 0.1140 0.1550 10
3 I 0.330 0.255 0.080 0.2050 0.0895 0.0395 0.0550 7
4 ...
css开发练习
这里是一个示例
123456<style> body {background-color: yellow;} h1 {font-size: 36pt;} h2 {color: blue;} p {margin-left: 50px;}</style>
我们再来写一下,在每个大括号中,也就是对应其左边名称的性质,比如p就是普通行的性质,h1就是大标题的性质,h2就是次标题的性质。
我们还可以针对p写很多条性质,不仅仅是颜色,还有其他,例如
123456p{ color: red; text-align:center; font-family:arial;}
deep learning pre knowledge
1import torch
12x = torch.arange(12)#row vectorx
tensor([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
1x.shape#size of tensor
torch.Size([12])
1x.numel()#number of elements, the product of the number of rows and columns, called size大小
12
12X1 = x.reshape(3, 4)X1#Changing the shape doesn't change the size12
tensor([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
12X2 = x.reshape(3, -1)X2#automatically adjust the shape using -1
tensor([[ 0, 1, 2, 3],
[ 4, ...