如果我站在朝阳上 能否脱去昨日的惆怅
单薄语言能否传达我所有的牵挂
若有天我不复勇往 能否坚持走完这一场
踏遍万水千山总有一地故乡
In the world of locked doors
这两天生活真的很不规律。周一因为想试一试Code Jam 熬到了凌晨四点多才睡,今天又不知道为什么一直睡不着。
由于第一门考试SPM还有一周左右的样子,我这两天绝大多数醒着的时间都用来复习考试了。今天本来只是想要登陆学校的校园中心打印一份模拟试卷做一下的来着,但是一不小心在登陆界面上发现了一个硕大无比的Bug。于是我就愉快的把学校的数据库给拖下来了。
当然,由于学校的数据库规模还是有一点大的,我拖了几千条数据验证思路之后就没有再继续了(考试要紧 考试要紧)。等我考完了,我应该会抽时间给学校写一个POC和修复报告的。
最后感慨一下,学校有好多漂亮的小姐姐呀。
Tensorflow Recurrent Neural Network – LSTM
最近学校里课上完了,给了两周时间来复习考试。可能是因为突然一下从赶Due的紧张中解脱了出来,居然敢写写代码浪起来了。
上个月看到Google有一个ML Winter Camp,然后又想到自己为了赶Due写论文已经两个月没怎么写过代码了,于是深感惭愧,决定抽空玩一玩Tensorflow和之前一直想搞的Sounding Probe。
其实MNIST并不是特别适合用RNN来预测的,但是用来玩一玩还是没有问题的。经过一波强行优化,RNN的Accuracy在测试集上居然可以和CNN有的一拼了。
Tensorflow MNIST Double Layer Model
这已经不知道是我第多少次搭MNIST了,但感觉每次写这个Hello World都会学到一写新的东西。
这次写这个主要是为了学习一下TensorFlow自带的TensorBoard功能,不知道是以前自己太蠢还是怎么回事,一直玩不转TensorBoard的可视化。
这次上手试了试r1.11的版本,发现真的很简单就可以实现了,而且语法也优雅的。
My table
Some of us get dipped in flat, some in satin, some in gloss. But every once in a while you find someone who’s iridescent, and when you do, nothing will ever compare.
兑现承诺是否也算是一种预言?
Banksy说过他的作品不会上拍
St Kilda
These days are hard since I have to struggle with my assignments and exams.
However, no matter how arduous life is, I still love nature.
Sin
It seemed the world was divided into good and bad people.
The good ones slept better
while the bad ones seemed to enjoy the waking hours much more.
891. Sum of Subsequence Widths
Given an array of integers A, consider all non-empty subsequences of A.
For any sequence S, let the width of S be the difference between the maximum and minimum element of S.
Return the sum of the widths of all subsequences of A.
As the answer may be very large, return the answer modulo 10^9 + 7.
Example 1: Input: [2,1,3] Output: 6 Explanation: Subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3]. The corresponding widths are 0, 0, 0, 1, 1, 2, 2. The sum of these widths is 6.
It is a pretty interesting question. Initially, I try to use combinations from itertools package. It works however time out…
So, I am aware of it is a math question.
We can find there are i numbers smaller than A[i], hence we have 2 ^ i subsequences that A[i] is the max number.
Meanwhile, there are len(A) – i – 1 numbers bigger than A[i], and we have 2^(len(A) – i – 1)subsequences in which A[i] is the min number.
According to above, result equal res += A[i] * ((2 ^ i) – 2 ^ (n – i – 1)). At least, we only need to mod 10^9 + 7, and then we get the accepted answer.
def leetcode(A): result = [] for i, a in enumerate(sorted(A)): result += [((1 << i) - (1 << (len(A) - i - 1))) * a] return sum(result) % (10 ** 9 + 7)