Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ npx hexo server

More info: Server

Generate static files

1
$ npx hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

final数据

  • 对于基本类型,final使数值恒定不变
  • 对于对象引用,final一旦引用被初始化一个对象,就无法改变指向另一个对象。到那时对象其本身的值是可变的
关于staticfinal
  • static 主要是唯一性,final则是不可变
空白final

声明为final但又未给定

final参数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Gimzo {
public void spin() {
}
}
class FinalArguments {
void with(final Gimzo gimzo){
//! g = new Gimzo(); // Illegal -- g is final
}
void without(Gimzo gimzo){
gimzo = new Gimzo();
gimzo.spin();
}
// void f(final int i) { i ++; } // can't change
int g(final int i) { return i + 1; }
}

public class Main{
public static void main(String[] args){
FinalArguments bf = new FinalArguments();
bf.without(null);
bf.with(null);
}
}
final方法

把方法锁定,防止任何继承类修改它的含义。

final

防止被继承

继承和初始化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Insect{
private int i = 9;
protected int j;
Insect(){
System.out.println("i = " + i + ", j = " + j);
j = 39;
}
private static int x1 = printInt("static Insect.x1 initialized");
static int printInt(String s){
System.out.println(s);
return 47;
}
}

public class Beetle extends Insect{
private int k = printInt("Beetle.l initialized");
public Beetle(){
System.out.println("k = " + k);
System.out.println("j = " + j);
}
private static int x2 = printInt("static Beetle.x2 initialized");
public static void main(String[] args) {
System.out.println("Beetle constructor");
Beetle b = new Beetle();
}
}

加载Beetle类的过程中,编译器注意到它有一个基类。不管是否打算产生于一个基类的对象,这都要发生。

考虑下面的代码,按照道理不可能出现x < y的情况。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Something {
private int x = 0, y = 0;

public void write() {
x = 100;
y = 50;
}

public void read() {
if (x < y)
System.out.print("x < y");
}
}

public class Test {
public static void main(String[] args) {
final Something obj = new Something();

new Thread() {
public void run() {
obj.write();
}
}.run();

new Thread() {
public void run() {
obj.write();
}
}.run();
}
}

但是在实际运行中却可能出现,主要原因就是重排序的影响。犹豫对于x的赋值和y的赋值之间不存在依存关系,编译器可能改变顺序。

Neural network:

cost function \[h_Θ(x) \in \Bbb{R}^K \quad (h_Θ(x))_i = i^{th} output \]

\[J(Θ) = -\frac 1m\left[\sum^m_{i=1}\sum^K_{k=1}y^{(i)}_klog(h_Θ(x^{(i)})_k+(1-y^{(i)}_k)log(1-(h_Θ(x^{(i)}))_k) \right]+\frac{\lambda}{2m}\sum^{L-1}_{l-1}\sum^{s_l}_{i=1}\sum^{s_l+1}_{j=1}(Θ^{(l)}_{ji})^2\] 1. Randomly initialize weights

  1. Implement forward propagation to get \(h_{Θ}(x^{(i)})\) for any \(x^{(i)}\)

  2. Implement code to compute cost function \(J(Θ)\)

Read more »

Linear Structures

Once an item is added, it stays in that position relative to the other elements that came before and came after it. * stacks * queues * deques * lists

Stack abstract data type

  • Satck() return empty stack
  • push(item) return nothing
  • pop() return the item
  • peek() returns the top item from the stack but does not remove it.
  • isEmpty()
  • size()
Read more »

正则表达式

正则表达式通过一些特殊符号的帮助,使用户可以轻松快捷的完成查找、删除、替换等处理程序

正则表达式特殊符号

1
2
3
4
5
6
7
8
9
10
11
12
[:alnum:]代表英文大小写字母及数字
[:alpha:]代表英文大小写字母
[:blank:]代表空格和 tab 键
[:cntrl:]键盘上的控制按键,如 CR,LF,TAB,DEL
[:digit:]代表数字
[:graph:]代表空白字符以外的其他
[:lower:]小写字母
[:print:]可以被打印出来的任何字符
[:punct:]代表标点符号
[:upper:]代表大写字符
[:space:]任何会产生空白的字符如空格,tab,CR 等
[:xdigit:]代表 16 进位的数字类型
Read more »

使用GitHub托管项目时,经常要clone, push等等,需要添加SSH方便操作,具体方法如下

检查电脑是否已经有SSH key

1
$ cd ~/.ssh

检查.ssh是否存在id_rsa.pub和id_dsa.pub,两个文件。如果存在不需要重新生产,可跳过下一步骤。

生产SSH key

1
$ ssh-keygen -t rsa -C "user_email@example.com"

-t 指定密钥类型,默认是RSA,可以略去 -C 设置注释文字,这里用到的是邮箱 -f 指定文件储存的文件名

上述代码省略-f,因此运行后会提示输入文件名保存生成的文件

1
2
Generating public/private rsa key pair.
# Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
这时回车,使用默认文件名

然后会提示设置密码,这个密码主要用于push文件。如果不输入密码,直接回车,之后push时就不需要输入密码

1
2
Enter passphrase (empty for no passphrase):
# Enter same passphrase again:
之后显示如下代码:
1
2
3
4
Your identification has been saved in /c/Users/user/.ssh/id_rsa.
# Your public key has been saved in /c/Users/user/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db user_email@example.com

Read more »

关于Markdown

区块元素

标题

在Markdown中只需要在标题前加#即可,共分为六级,按照#数量区分

1
2
3
4
5
6
# 一级标题
## 二级标题
### 三级标题
#### 四级标题
##### 五级标题
###### 六级标题

#和标题之间建议保留一个字符的空格,这是最标准的Markdown写法

列表

Markdown支持有序列表和无序列表

有序列表在文字前添加 *+-

1
2
3
* Red
+ Green
- Yellow

无序列表是在文字前加上1. 2. 3.

1
2
3
1. First
2. Second
3. Third
Read more »
0%