原文地址Word2Vec Tutorial - The Skip-Gram Model

Word2Vec Tutorial - The Skip-Gram Model

This tutorial covers the skip gram neural network architecture for Word2Vec. My intention with this tutorial was to skip over the usual introductory and abstract insights about Word2Vec, and get into more of the details. Specifically here I’m diving into the skip gram neural network model.

这个教程涵盖了Skip gram nenural network 的 Word2Vec 的结构, 我做这个教程的想法是跳过Word2Vec常见的介绍和抽象的概念,直接获取更多的细节。这里我开始潜入Skip gram neural network 模型.

The Model

The skip-gram neural network model is actually surprisingly simple in its most basic form; I think it’s the all the little tweaks and enhancements that start to clutter the explanation.

skip-gram neural network 模型的基本形式惊人的简单。我认为所有的苦恼都源于杂糅解释。

Let’s start with a high-level insight about where we’re going. Word2Vec uses a trick you may have seen elsewhere in machine learning. We’re going to train a simple neural network with a single hidden layer to perform a certain task, but then we’re not actually going to use that neural network for the task we trained it on! Instead, the goal is actually just to learn the weights of the hidden layer–we’ll see that these weights are actually the “word vectors” that we’re trying to learn.

让我们从高阶的视角开始。Word2Vec使用了一个你可能会在其他机器学习里面见过的技巧。我们将会训练一个简单的只有一层隐藏层的神经网络,用来代表一个任务,但是我们不会真的使用那个神经网络在我们的训练的任务上。取而代之的是,我们的目标实际是学习得到隐藏层的权重,我们将会见到这些权重其实才是“word vectors”我们想要学习得到的。

The Fake Task

So now we need to talk about this “fake” task that we’re going to build the neural network to perform, and then we’ll come back later to how this indirectly gives us those word vectors that we are really after.

We’re going to train the neural network to do the following. Given a specific word in the middle of a sentence (the input word), look at the words nearby and pick one at random. The network is going to tell us the probability for every word in our vocabulary of being the “nearby word” that we chose.

所以现在我们需要讨论一下这个将会建立神经网络模型模拟的“假”的任务。

我们将会训练神经网络做以下的事情。给定一个句子中间的字,在这个字的旁边随机取一个另一个字。神经网络将要告诉我们每一个在字典中的字,成为这个旁边的字的可能性。

The output probabilities are going to relate to how likely it is find each vocabulary word nearby our input word. For example, if you gave the trained network the input word “Soviet”, the output probabilities are going to be much higher for words like “Union” and “Russia” than for unrelated words like “watermelon” and “kangaroo”.

输出的可能性需要与每一个字典中发 有关联。 例如,如果你训练网络的输入字“soviet”, “Union” 和 “Russia”的可能性就要远大于“watermelon” and “kangaroo”。

We’ll train the neural network to do this by feeding it word pairs found in our training documents. The below example shows some of the training samples (word pairs) we would take from the sentence “The quick brown fox jumps over the lazy dog.” I’ve used a small window size of 2 just for the example. The word highlighted in blue is the input word.

我们将会训练这个神经网络完成这些通过给他一对在训练文档中找到的字。 下面的例子展示了一些训练的示例,我们将会从句子“The quick brown fox jumps over the lazy dog.”中取字。我用了一个小的窗口大小-2,仅仅用于示范。蓝色高亮的部分是输入的字。

training_data
training_data
training_data

获取比赛列表

URL

https://games.mobileapi.hupu.com/1/7.1.15/nba/getGames

params

{
'crt': 1516412142416,
'night': 0,
'channel': 'myapp',
'client': self.client,
'time_zone': 'Asia/Shanghai',
'android_id': self.android_id,
}

response

{
"result": {
"games": [{
"date_block": "1\u670816\u65e5 \u5468\u4e8c",
"day": "20180116",
"data": [{
"video_collection": "1",
"gid": "153673",
"away_timeout": "2",
"away_name": "\u9ec4\u8702",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "9",
"away_tid": "30",
"status": "1",
"home_tid": "11",
"offical_roomid": "10",
"begin_time": "1516037400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "118",
"live": "1",
"home_score": "107",
"away_fouls": "5",
"home_fouls_color": "1",
"home_name": "\u6d3b\u585e",
"casino": 0,
"room_id": "10",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153674",
"away_timeout": "0",
"away_name": "\u731b\u9f99",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "6",
"away_tid": "15",
"status": "1",
"home_tid": "6",
"offical_roomid": "36",
"begin_time": "1516039200",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "111",
"live": "1",
"home_score": "117",
"away_fouls": "8",
"home_fouls_color": "1",
"home_name": "76\u4eba",
"casino": 0,
"room_id": "36",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153675",
"away_timeout": "1",
"away_name": "\u96c4\u9e7f",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "6",
"away_tid": "13",
"status": "1",
"home_tid": "7",
"offical_roomid": "10915",
"begin_time": "1516042800",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "104",
"live": "1",
"home_score": "95",
"away_fouls": "7",
"home_fouls_color": "1",
"home_name": "\u5947\u624d",
"casino": 0,
"room_id": "10915",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153676",
"away_timeout": "1",
"away_name": "\u5c3c\u514b\u65af",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "6",
"away_tid": "4",
"status": "1",
"home_tid": "3",
"offical_roomid": "10823",
"begin_time": "1516046400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "119",
"live": "1",
"home_score": "104",
"away_fouls": "2",
"home_fouls_color": "1",
"home_name": "\u7bee\u7f51",
"casino": 0,
"room_id": "10823",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153678",
"away_timeout": "0",
"away_name": "\u9a6c\u523a",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "10",
"away_tid": "21",
"status": "1",
"home_tid": "8",
"offical_roomid": "10907",
"begin_time": "1516046400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "99",
"live": "1",
"home_score": "102",
"away_fouls": "5",
"home_fouls_color": "1",
"home_name": "\u8001\u9e70",
"casino": 0,
"room_id": "10907",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153679",
"away_timeout": "0",
"away_name": "\u70ed\u706b",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "11",
"away_tid": "2",
"status": "1",
"home_tid": "9",
"offical_roomid": "10933",
"begin_time": "1516048200",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "111",
"live": "1",
"home_score": "119",
"away_fouls": "8",
"home_fouls_color": "1",
"home_name": "\u516c\u725b",
"casino": 0,
"room_id": "10933",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153680",
"away_timeout": "1",
"away_name": "\u6e56\u4eba",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "3",
"away_tid": "24",
"status": "1",
"home_tid": "19",
"offical_roomid": "10823",
"begin_time": "1516055400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "114",
"live": "1",
"home_score": "123",
"away_fouls": "4",
"home_fouls_color": "1",
"home_name": "\u7070\u718a",
"casino": 0,
"room_id": "10823",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153677",
"away_timeout": "0",
"away_name": "\u56fd\u738b",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "6",
"away_tid": "23",
"status": "1",
"home_tid": "27",
"offical_roomid": "7",
"begin_time": "1516064400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "88",
"live": "1",
"home_score": "95",
"away_fouls": "8",
"home_fouls_color": "1",
"home_name": "\u96f7\u9706",
"casino": 1,
"room_id": "7",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"away_timeout": "1",
"gid": "153681",
"away_name": "\u52c7\u58eb",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "4",
"away_tid": "28",
"status": "1",
"home_tid": "10",
"offical_roomid": "3",
"begin_time": "1516064400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2", "CCTV5"],
"away_score": "118",
"live": "1",
"home_score": "108",
"away_fouls": "8",
"home_fouls_color": "1",
"home_name": "\u9a91\u58eb",
"casino": 1,
"room_id": "3",
"default_tab": "recap",
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"away_timeout": "2",
"gid": "153682",
"away_name": "\u6b65\u884c\u8005",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "1",
"away_tid": "12",
"status": "1",
"home_tid": "22",
"offical_roomid": "10449",
"begin_time": "1516068000",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"away_score": "109",
"live": "1",
"home_score": "94",
"away_fouls": "6",
"home_fouls_color": "1",
"home_name": "\u7235\u58eb",
"casino": 0,
"room_id": "10449",
"default_tab": "recap",
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153683",
"away_timeout": "2",
"away_name": "\u706b\u7bad",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "5",
"away_tid": "18",
"status": "1",
"home_tid": "29",
"offical_roomid": "10",
"begin_time": "1516073400",
"live_status": "1",
"date_time": "1516032000",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "102",
"live": "1",
"home_score": "113",
"away_fouls": "5",
"home_fouls_color": "1",
"home_name": "\u5feb\u8239",
"casino": 1,
"room_id": "10",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "CCTV5"],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "0",
"gid": "10004661",
"chat_disable": "1",
"away_name": "\u5341\u4f73\u7403",
"game_name": "0",
"process": "\u5df2\u7ed3\u675f",
"type": "1",
"is_olympic": "0",
"relation_gid": "0",
"away_tid": "992",
"status": "1",
"home_tid": "991",
"offical_roomid": "10908",
"begin_time": "1516104002",
"live_status": "0",
"date_time": "1516032000",
"related_lrw_id": "0",
"match_type": "REGULAR",
"season": "2017",
"home_score": "0",
"away_score": "0",
"live": "0",
"live_info": "",
"lid": "1",
"home_name": "\u7cbe\u5f69\u77ac\u95f4",
"stage": "\u4eca\u65e5\u5341\u4f73\u7403",
"casino": 1,
"home_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206823609_110x88.png",
"away_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206857381_110x88.png",
"room_id": "10908",
"default_tab": "recap",
"tvs": [],
"date": "1\u670816\u65e5 \u5468\u4e8c",
"type_block": "\u4eca\u65e5\u5341\u4f73\u7403"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "1\u670817\u65e5 \u5468\u4e09",
"day": "20180117",
"data": [{
"video_collection": "1",
"away_timeout": "2",
"gid": "153684",
"away_name": "\u68ee\u6797\u72fc",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "4",
"away_tid": "20",
"status": "1",
"home_tid": "5",
"offical_roomid": "10823",
"begin_time": "1516147200",
"live_status": "1",
"date_time": "1516118400",
"away_fouls_color": "1",
"match_type": "REGULAR",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"away_score": "102",
"live": "1",
"home_score": "108",
"away_fouls": "8",
"home_fouls_color": "1",
"home_name": "\u9b54\u672f",
"casino": 0,
"room_id": "10823",
"default_tab": "recap",
"date": "1\u670817\u65e5 \u5468\u4e09",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153685",
"away_timeout": "2",
"away_name": "\u9e48\u9e55",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "1",
"away_tid": "14",
"status": "1",
"home_tid": "1",
"offical_roomid": "7",
"begin_time": "1516149000",
"live_status": "1",
"date_time": "1516118400",
"away_fouls_color": "0",
"match_type": "REGULAR",
"away_score": "116",
"live": "1",
"home_score": "113",
"away_fouls": "0",
"home_fouls_color": "1",
"home_name": "\u51ef\u5c14\u7279\u4eba",
"casino": 1,
"room_id": "7",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "CCTV5"],
"date": "1\u670817\u65e5 \u5468\u4e09",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"away_timeout": "0",
"gid": "153686",
"away_name": "\u72ec\u884c\u4fa0",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "7",
"away_tid": "16",
"status": "1",
"home_tid": "17",
"offical_roomid": "10449",
"begin_time": "1516154400",
"live_status": "1",
"date_time": "1516118400",
"away_fouls_color": "1",
"match_type": "REGULAR",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"away_score": "102",
"live": "1",
"home_score": "105",
"away_fouls": "6",
"home_fouls_color": "1",
"home_name": "\u6398\u91d1",
"casino": 0,
"room_id": "10449",
"default_tab": "recap",
"date": "1\u670817\u65e5 \u5468\u4e09",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153687",
"away_timeout": "1",
"away_name": "\u592a\u9633",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "3",
"away_tid": "26",
"status": "1",
"home_tid": "25",
"offical_roomid": "10",
"begin_time": "1516158000",
"live_status": "1",
"date_time": "1516118400",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "111",
"live": "1",
"home_score": "118",
"away_fouls": "4",
"home_fouls_color": "1",
"home_name": "\u5f00\u62d3\u8005",
"casino": 0,
"room_id": "10",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "\u817e\u8baf\u89c6\u9891"],
"date": "1\u670817\u65e5 \u5468\u4e09",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "0",
"gid": "10004663",
"chat_disable": "1",
"away_name": "\u4e94\u4f73\u7403",
"game_name": "0",
"process": "\u5df2\u7ed3\u675f",
"type": "1",
"is_olympic": "0",
"relation_gid": "0",
"away_tid": "992",
"status": "1",
"home_tid": "991",
"offical_roomid": "10908",
"begin_time": "1516190405",
"live_status": "0",
"date_time": "1516118400",
"related_lrw_id": "0",
"match_type": "REGULAR",
"season": "2017",
"home_score": "0",
"away_score": "0",
"live": "0",
"live_info": "",
"lid": "1",
"home_name": "\u7cbe\u5f69\u77ac\u95f4",
"stage": "\u4eca\u65e5\u4e94\u4f73\u7403",
"casino": 1,
"home_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206823609_110x88.png",
"away_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206851874_110x88.png",
"room_id": "10908",
"default_tab": "recap",
"tvs": [],
"date": "1\u670817\u65e5 \u5468\u4e09",
"type_block": "\u4eca\u65e5\u4e94\u4f73\u7403"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "1\u670818\u65e5 \u5468\u56db",
"day": "20180118",
"data": [{
"video_collection": "1",
"gid": "153688",
"away_timeout": "1",
"away_name": "\u5947\u624d",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "8",
"away_tid": "7",
"status": "1",
"home_tid": "30",
"offical_roomid": "36",
"begin_time": "1516233600",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "109",
"live": "1",
"home_score": "133",
"away_fouls": "6",
"home_fouls_color": "1",
"home_name": "\u9ec4\u8702",
"casino": 0,
"room_id": "36",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153689",
"away_timeout": "0",
"away_name": "\u9a6c\u523a",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "10",
"away_tid": "21",
"status": "1",
"home_tid": "3",
"offical_roomid": "10907",
"begin_time": "1516235400",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "100",
"live": "1",
"home_score": "95",
"away_fouls": "8",
"home_fouls_color": "1",
"home_name": "\u7bee\u7f51",
"casino": 1,
"room_id": "10907",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"away_timeout": "0",
"gid": "153690",
"away_name": "\u9e48\u9e55",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "8",
"away_tid": "14",
"status": "1",
"home_tid": "8",
"offical_roomid": "10449",
"begin_time": "1516235400",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"away_score": "93",
"live": "1",
"home_score": "94",
"away_fouls": "1",
"home_fouls_color": "1",
"home_name": "\u8001\u9e70",
"casino": 0,
"room_id": "10449",
"default_tab": "recap",
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153691",
"away_timeout": "1",
"away_name": "\u6d3b\u585e",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "3",
"away_tid": "11",
"status": "1",
"home_tid": "15",
"offical_roomid": "10823",
"begin_time": "1516235400",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "91",
"live": "1",
"home_score": "96",
"away_fouls": "6",
"home_fouls_color": "1",
"home_name": "\u731b\u9f99",
"casino": 0,
"room_id": "10823",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153692",
"away_timeout": "0",
"away_name": "\u5c3c\u514b\u65af",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "3",
"away_tid": "4",
"status": "1",
"home_tid": "19",
"offical_roomid": "10933",
"begin_time": "1516237200",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "99",
"live": "1",
"home_score": "105",
"away_fouls": "5",
"home_fouls_color": "0",
"home_name": "\u7070\u718a",
"casino": 0,
"room_id": "10933",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153693",
"away_timeout": "1",
"away_name": "\u70ed\u706b",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "7",
"away_tid": "2",
"status": "1",
"home_tid": "13",
"offical_roomid": "10915",
"begin_time": "1516237200",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "106",
"home_score": "101",
"live": "1",
"away_fouls": "5",
"home_fouls_color": "1",
"home_name": "\u96c4\u9e7f",
"casino": 0,
"room_id": "10915",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153694",
"away_timeout": "2",
"away_name": "\u6e56\u4eba",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "2",
"away_tid": "24",
"status": "1",
"home_tid": "27",
"offical_roomid": "3",
"begin_time": "1516237200",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "90",
"live": "1",
"home_score": "114",
"away_fouls": "3",
"home_fouls_color": "0",
"home_name": "\u96f7\u9706",
"casino": 1,
"room_id": "3",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153695",
"away_timeout": "1",
"away_name": "\u52c7\u58eb",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "5",
"away_tid": "28",
"status": "1",
"home_tid": "9",
"offical_roomid": "7",
"begin_time": "1516237200",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "119",
"live": "1",
"home_score": "112",
"away_fouls": "4",
"home_fouls_color": "1",
"home_name": "\u516c\u725b",
"casino": 1,
"room_id": "7",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153696",
"away_timeout": "2",
"away_name": "\u7235\u58eb",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "8",
"away_tid": "22",
"status": "1",
"home_tid": "23",
"offical_roomid": "10823",
"begin_time": "1516244400",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "120",
"live": "1",
"home_score": "105",
"away_fouls": "5",
"home_fouls_color": "1",
"home_name": "\u56fd\u738b",
"casino": 0,
"room_id": "10823",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153697",
"away_timeout": "0",
"away_name": "\u6398\u91d1",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "5",
"away_tid": "17",
"status": "1",
"home_tid": "29",
"offical_roomid": "10",
"begin_time": "1516246200",
"live_status": "1",
"date_time": "1516204800",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "104",
"live": "1",
"home_score": "109",
"away_fouls": "12",
"home_fouls_color": "1",
"home_name": "\u5feb\u8239",
"casino": 0,
"room_id": "10",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "\u817e\u8baf\u89c6\u9891"],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "0",
"gid": "10004664",
"chat_disable": "1",
"away_name": "\u5341\u4f73\u7403",
"game_name": "0",
"process": "\u5df2\u7ed3\u675f",
"type": "1",
"is_olympic": "0",
"relation_gid": "0",
"away_tid": "992",
"status": "1",
"home_tid": "991",
"offical_roomid": "10908",
"begin_time": "1516276808",
"live_status": "0",
"date_time": "1516204800",
"related_lrw_id": "0",
"match_type": "REGULAR",
"season": "2017",
"home_score": "0",
"away_score": "0",
"live": "0",
"live_info": "",
"lid": "1",
"home_name": "\u7cbe\u5f69\u77ac\u95f4",
"stage": "\u4eca\u65e5\u5341\u4f73\u7403",
"casino": 1,
"home_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206823609_110x88.png",
"away_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206857381_110x88.png",
"room_id": "10908",
"default_tab": "recap",
"tvs": [],
"date": "1\u670818\u65e5 \u5468\u56db",
"type_block": "\u4eca\u65e5\u5341\u4f73\u7403"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "\u6628\u65e5 \u5468\u4e94",
"day": "20180119",
"data": [{
"video_collection": "0",
"gid": "10004666",
"chat_disable": "0",
"away_name": "\u75af\u72c2\u7ade\u731c",
"game_name": "0",
"process": "\u5df2\u7ed3\u675f",
"type": "1",
"is_olympic": "0",
"relation_gid": "0",
"away_tid": "992",
"status": "1",
"home_tid": "991",
"offical_roomid": "10421",
"begin_time": "1516291500",
"live_status": "1",
"date_time": "1516291200",
"related_lrw_id": "0",
"match_type": "REGULAR",
"season": "2017",
"home_score": "0",
"away_score": "0",
"live": "1",
"live_info": "",
"lid": "1",
"home_name": "\u864e\u6251",
"stage": "",
"casino": 1,
"home_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201708\/10\/BbsImg150234438792430_110x88.png",
"away_logo": "https:\/\/b1.hoopchina.com.cn\/games\/images\/crazyquiz.png",
"room_id": "10421",
"default_tab": "recap",
"tvs": [],
"date": "\u6628\u65e5 \u5468\u4e94",
"type_block": ""
}, {
"video_collection": "1",
"gid": "153698",
"away_timeout": "2",
"away_name": "\u9b54\u672f",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "0",
"home_fouls": "7",
"away_tid": "5",
"status": "1",
"home_tid": "10",
"offical_roomid": "3",
"begin_time": "1516320000",
"live_status": "1",
"date_time": "1516291200",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "103",
"live": "1",
"home_score": "104",
"away_fouls": "6",
"home_fouls_color": "1",
"home_name": "\u9a91\u58eb",
"casino": 1,
"room_id": "3",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "CCTV5"],
"date": "\u6628\u65e5 \u5468\u4e94",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153699",
"away_timeout": "0",
"away_name": "76\u4eba",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "1",
"home_fouls": "5",
"away_tid": "6",
"status": "1",
"home_tid": "1",
"offical_roomid": "10823",
"begin_time": "1516320000",
"live_status": "1",
"date_time": "1516291200",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "89",
"live": "1",
"home_score": "80",
"away_fouls": "7",
"home_fouls_color": "1",
"home_name": "\u51ef\u5c14\u7279\u4eba",
"casino": 1,
"room_id": "10823",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"date": "\u6628\u65e5 \u5468\u4e94",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153700",
"away_timeout": "0",
"away_name": "\u68ee\u6797\u72fc",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "5",
"away_tid": "20",
"status": "1",
"home_tid": "18",
"offical_roomid": "10",
"begin_time": "1516329000",
"live_status": "1",
"date_time": "1516291200",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "98",
"live": "1",
"home_score": "116",
"away_fouls": "4",
"home_fouls_color": "1",
"home_name": "\u706b\u7bad",
"casino": 1,
"room_id": "10",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"date": "\u6628\u65e5 \u5468\u4e94",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "1",
"gid": "153701",
"away_timeout": "1",
"away_name": "\u6b65\u884c\u8005",
"process": "\u5df2\u7ed3\u675f",
"home_timeout": "2",
"home_fouls": "4",
"away_tid": "12",
"status": "1",
"home_tid": "25",
"offical_roomid": "7",
"begin_time": "1516330800",
"live_status": "1",
"date_time": "1516291200",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "86",
"live": "1",
"home_score": "100",
"away_fouls": "6",
"home_fouls_color": "1",
"home_name": "\u5f00\u62d3\u8005",
"casino": 1,
"room_id": "7",
"default_tab": "recap",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u6628\u65e5 \u5468\u4e94",
"type_block": "",
"video_collection_type": 1,
"lid": "1"
}, {
"video_collection": "0",
"gid": "10004665",
"chat_disable": "1",
"away_name": "\u4e94\u4f73\u7403",
"game_name": "0",
"process": "\u5df2\u7ed3\u675f",
"type": "1",
"is_olympic": "0",
"relation_gid": "0",
"away_tid": "992",
"status": "1",
"home_tid": "991",
"offical_roomid": "10908",
"begin_time": "1516363201",
"live_status": "0",
"date_time": "1516291200",
"related_lrw_id": "0",
"match_type": "REGULAR",
"season": "2017",
"home_score": "0",
"away_score": "0",
"live": "0",
"live_info": "",
"lid": "1",
"home_name": "\u7cbe\u5f69\u77ac\u95f4",
"stage": "\u4eca\u65e5\u4e94\u4f73\u7403",
"casino": 1,
"home_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206823609_110x88.png",
"away_logo": "https:\/\/i1.hoopchina.com.cn\/blogfile\/201711\/17\/BbsImg151091206851874_110x88.png",
"room_id": "10908",
"default_tab": "recap",
"tvs": [],
"date": "\u6628\u65e5 \u5468\u4e94",
"type_block": "\u4eca\u65e5\u4e94\u4f73\u7403"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "\u4eca\u65e5 \u5468\u516d",
"day": "20180120",
"data": [{
"gid": "153702",
"away_timeout": "4",
"away_name": "\u9a6c\u523a",
"process": "\u7b2c\u4e09\u8282 5:22",
"home_timeout": "4",
"home_fouls": "3",
"away_tid": "21",
"status": "2",
"home_tid": "15",
"offical_roomid": "10907",
"begin_time": "1516406400",
"live_status": "1",
"date_time": "1516377600",
"away_fouls_color": "0",
"match_type": "REGULAR",
"away_score": "48",
"live": "1",
"home_score": "57",
"away_fouls": "2",
"home_fouls_color": "0",
"home_name": "\u731b\u9f99",
"casino": 1,
"room_id": "10907",
"default_tab": "live",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"away_timeout": "6",
"gid": "153703",
"away_name": "\u70ed\u706b",
"process": "\u7b2c\u4e8c\u8282 59.0\u79d2",
"home_timeout": "3",
"home_fouls": "4",
"away_tid": "2",
"status": "2",
"home_tid": "3",
"offical_roomid": "10915",
"begin_time": "1516408200",
"live_status": "1",
"date_time": "1516377600",
"away_fouls_color": "1",
"match_type": "REGULAR",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"away_score": "48",
"live": "1",
"home_score": "41",
"away_fouls": "3",
"home_fouls_color": "1",
"home_name": "\u7bee\u7f51",
"casino": 0,
"room_id": "10915",
"default_tab": "live",
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"gid": "153704",
"away_timeout": "5",
"away_name": "\u5947\u624d",
"process": "\u7b2c\u4e00\u8282 1.0\u79d2",
"home_timeout": "7",
"home_fouls": "2",
"away_tid": "7",
"status": "2",
"home_tid": "11",
"offical_roomid": "11",
"begin_time": "1516410000",
"live_status": "1",
"date_time": "1516377600",
"away_fouls_color": "0",
"match_type": "REGULAR",
"away_score": "19",
"live": "1",
"home_score": "29",
"away_fouls": "1",
"home_fouls_color": "1",
"home_name": "\u6d3b\u585e",
"casino": 0,
"room_id": "11",
"default_tab": "live",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "CCTV5"],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"gid": "153705",
"away_timeout": "6",
"away_name": "\u56fd\u738b",
"process": "\u7b2c\u4e00\u8282 1:24",
"home_timeout": "6",
"home_fouls": "4",
"away_tid": "23",
"status": "2",
"home_tid": "19",
"offical_roomid": "10449",
"begin_time": "1516410000",
"live_status": "1",
"date_time": "1516377600",
"away_fouls_color": "1",
"match_type": "REGULAR",
"away_score": "17",
"live": "1",
"home_score": "26",
"away_fouls": "7",
"home_fouls_color": "1",
"home_name": "\u7070\u718a",
"casino": 0,
"room_id": "10449",
"default_tab": "live",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"gid": "153706",
"date_time": "1516377600",
"begin_time": "1516413600",
"home_tid": "17",
"home_name": "\u6398\u91d1",
"home_score": "0",
"away_tid": "26",
"away_name": "\u592a\u9633",
"away_score": "0",
"match_type": "REGULAR",
"process": "10:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "casino",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"gid": "153707",
"date_time": "1516377600",
"begin_time": "1516419000",
"home_tid": "24",
"home_name": "\u6e56\u4eba",
"home_score": "0",
"away_tid": "12",
"away_name": "\u6b65\u884c\u8005",
"away_score": "0",
"match_type": "REGULAR",
"process": "11:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "casino",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2", "CCTV5"],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"gid": "153708",
"date_time": "1516377600",
"begin_time": "1516419000",
"home_tid": "22",
"home_name": "\u7235\u58eb",
"home_score": "0",
"away_tid": "4",
"away_name": "\u5c3c\u514b\u65af",
"away_score": "0",
"match_type": "REGULAR",
"process": "11:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "casino",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "\u5e7f\u4e1c\u4f53\u80b2"],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": "",
"lid": "1"
}, {
"gid": "10004669",
"lid": "1",
"type": "1",
"match_type": "REGULAR",
"season": "2017",
"begin_time": "1516449604",
"date_time": "1516377600",
"home_tid": "991",
"home_name": "\u75af\u72c2\u7ade\u731c",
"away_tid": "992",
"away_name": "\u6570\u636e\u4e71\u6597",
"home_score": "0",
"away_score": "0",
"process": "\u5df2\u7ed3\u675f",
"status": "1",
"live": "1",
"stage": "",
"live_status": "1",
"chat_disable": "1",
"is_olympic": "0",
"game_name": "0",
"relation_gid": "0",
"related_lrw_id": "0",
"live_info": "",
"offical_roomid": "10908",
"casino": 1,
"home_logo": "https:\/\/b1.hoopchina.com.cn\/games\/images\/crazyquiz.png",
"away_logo": "https:\/\/b1.hoopchina.com.cn\/games\/images\/datascuffle.png",
"room_id": "10908",
"default_tab": "recap",
"tvs": [],
"date": "\u4eca\u65e5 \u5468\u516d",
"type_block": ""
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "\u660e\u65e5 \u5468\u65e5",
"day": "20180121",
"data": [{
"gid": "153709",
"date_time": "1516464000",
"begin_time": "1516480200",
"home_tid": "10",
"home_name": "\u9a91\u58eb",
"home_score": "0",
"away_tid": "27",
"away_name": "\u96f7\u9706",
"away_score": "0",
"match_type": "REGULAR",
"process": "4:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153710",
"date_time": "1516464000",
"begin_time": "1516485600",
"home_tid": "8",
"home_name": "\u8001\u9e70",
"home_score": "0",
"away_tid": "9",
"away_name": "\u516c\u725b",
"away_score": "0",
"match_type": "REGULAR",
"process": "6:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153711",
"date_time": "1516464000",
"begin_time": "1516492800",
"home_tid": "30",
"home_name": "\u9ec4\u8702",
"home_score": "0",
"away_tid": "2",
"away_name": "\u70ed\u706b",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153712",
"date_time": "1516464000",
"begin_time": "1516492800",
"home_tid": "14",
"home_name": "\u9e48\u9e55",
"home_score": "0",
"away_tid": "19",
"away_name": "\u7070\u718a",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153713",
"date_time": "1516464000",
"begin_time": "1516494600",
"home_tid": "6",
"home_name": "76\u4eba",
"home_score": "0",
"away_tid": "13",
"away_name": "\u96c4\u9e7f",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153714",
"date_time": "1516464000",
"begin_time": "1516498200",
"home_tid": "18",
"home_name": "\u706b\u7bad",
"home_score": "0",
"away_tid": "28",
"away_name": "\u52c7\u58eb",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2", "CCTV5", "\u5e7f\u4e1c\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153715",
"date_time": "1516464000",
"begin_time": "1516500000",
"home_tid": "22",
"home_name": "\u7235\u58eb",
"home_score": "0",
"away_tid": "29",
"away_name": "\u5feb\u8239",
"away_score": "0",
"match_type": "REGULAR",
"process": "10:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153716",
"date_time": "1516464000",
"begin_time": "1516500000",
"home_tid": "20",
"home_name": "\u68ee\u6797\u72fc",
"home_score": "0",
"away_tid": "15",
"away_name": "\u731b\u9f99",
"away_score": "0",
"match_type": "REGULAR",
"process": "10:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2", "\u4e0a\u6d77\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}, {
"gid": "153717",
"date_time": "1516464000",
"begin_time": "1516503600",
"home_tid": "25",
"home_name": "\u5f00\u62d3\u8005",
"home_score": "0",
"away_tid": "16",
"away_name": "\u72ec\u884c\u4fa0",
"away_score": "0",
"match_type": "REGULAR",
"process": "11:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "\u660e\u65e5 \u5468\u65e5",
"type_block": "",
"lid": "1"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "1\u670822\u65e5 \u5468\u4e00",
"day": "20180122",
"data": [{
"gid": "153718",
"date_time": "1516550400",
"begin_time": "1516557600",
"home_tid": "1",
"home_name": "\u51ef\u5c14\u7279\u4eba",
"home_score": "0",
"away_tid": "5",
"away_name": "\u9b54\u672f",
"away_score": "0",
"match_type": "REGULAR",
"process": "2:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670822\u65e5 \u5468\u4e00",
"type_block": "",
"lid": "1"
}, {
"gid": "153719",
"date_time": "1516550400",
"begin_time": "1516566600",
"home_tid": "24",
"home_name": "\u6e56\u4eba",
"home_score": "0",
"away_tid": "4",
"away_name": "\u5c3c\u514b\u65af",
"away_score": "0",
"match_type": "REGULAR",
"process": "4:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670822\u65e5 \u5468\u4e00",
"type_block": "",
"lid": "1"
}, {
"gid": "153720",
"date_time": "1516550400",
"begin_time": "1516568400",
"home_tid": "11",
"home_name": "\u6d3b\u585e",
"home_score": "0",
"away_tid": "3",
"away_name": "\u7bee\u7f51",
"away_score": "0",
"match_type": "REGULAR",
"process": "5:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670822\u65e5 \u5468\u4e00",
"type_block": "",
"lid": "1"
}, {
"gid": "153721",
"date_time": "1516550400",
"begin_time": "1516579200",
"home_tid": "21",
"home_name": "\u9a6c\u523a",
"home_score": "0",
"away_tid": "12",
"away_name": "\u6b65\u884c\u8005",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": ["\u817e\u8baf\u89c6\u9891", "\u817e\u8baf\u4f53\u80b2"],
"date": "1\u670822\u65e5 \u5468\u4e00",
"type_block": "",
"lid": "1"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "1\u670823\u65e5 \u5468\u4e8c",
"day": "20180123",
"data": [{
"gid": "153722",
"date_time": "1516636800",
"begin_time": "1516665600",
"home_tid": "30",
"home_name": "\u9ec4\u8702",
"home_score": "0",
"away_tid": "23",
"away_name": "\u56fd\u738b",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153723",
"date_time": "1516636800",
"begin_time": "1516667400",
"home_tid": "8",
"home_name": "\u8001\u9e70",
"home_score": "0",
"away_tid": "22",
"away_name": "\u7235\u58eb",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153724",
"date_time": "1516636800",
"begin_time": "1516669200",
"home_tid": "14",
"home_name": "\u9e48\u9e55",
"home_score": "0",
"away_tid": "9",
"away_name": "\u516c\u725b",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153725",
"date_time": "1516636800",
"begin_time": "1516669200",
"home_tid": "18",
"home_name": "\u706b\u7bad",
"home_score": "0",
"away_tid": "2",
"away_name": "\u70ed\u706b",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153726",
"date_time": "1516636800",
"begin_time": "1516669200",
"home_tid": "13",
"home_name": "\u96c4\u9e7f",
"home_score": "0",
"away_tid": "26",
"away_name": "\u592a\u9633",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153727",
"date_time": "1516636800",
"begin_time": "1516669200",
"home_tid": "19",
"home_name": "\u7070\u718a",
"home_score": "0",
"away_tid": "6",
"away_name": "76\u4eba",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153728",
"date_time": "1516636800",
"begin_time": "1516671000",
"home_tid": "16",
"home_name": "\u72ec\u884c\u4fa0",
"home_score": "0",
"away_tid": "7",
"away_name": "\u5947\u624d",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153729",
"date_time": "1516636800",
"begin_time": "1516672800",
"home_tid": "17",
"home_name": "\u6398\u91d1",
"home_score": "0",
"away_tid": "25",
"away_name": "\u5f00\u62d3\u8005",
"away_score": "0",
"match_type": "REGULAR",
"process": "10:00\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}, {
"gid": "153730",
"date_time": "1516636800",
"begin_time": "1516678200",
"home_tid": "29",
"home_name": "\u5feb\u8239",
"home_score": "0",
"away_tid": "20",
"away_name": "\u68ee\u6797\u72fc",
"away_score": "0",
"match_type": "REGULAR",
"process": "11:30\u5f00\u59cb",
"status": "3",
"live": "1",
"live_status": "1",
"casino": 1,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670823\u65e5 \u5468\u4e8c",
"type_block": "",
"lid": "1"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}, {
"date_block": "1\u670824\u65e5 \u5468\u4e09",
"day": "20180124",
"data": [{
"gid": "153731",
"date_time": "1516723200",
"begin_time": "1516752000",
"home_tid": "5",
"home_name": "\u9b54\u672f",
"home_score": "0",
"away_tid": "23",
"away_name": "\u56fd\u738b",
"away_score": "0",
"match_type": "REGULAR",
"process": "8:00\u5f00\u59cb",
"status": "3",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670824\u65e5 \u5468\u4e09",
"type_block": "",
"lid": "1"
}, {
"gid": "153732",
"date_time": "1516723200",
"begin_time": "1516755600",
"home_tid": "27",
"home_name": "\u96f7\u9706",
"home_score": "0",
"away_tid": "3",
"away_name": "\u7bee\u7f51",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:00\u5f00\u59cb",
"status": "3",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670824\u65e5 \u5468\u4e09",
"type_block": "",
"lid": "1"
}, {
"gid": "153733",
"date_time": "1516723200",
"begin_time": "1516755600",
"home_tid": "21",
"home_name": "\u9a6c\u523a",
"home_score": "0",
"away_tid": "10",
"away_name": "\u9a91\u58eb",
"away_score": "0",
"match_type": "REGULAR",
"process": "9:00\u5f00\u59cb",
"status": "3",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670824\u65e5 \u5468\u4e09",
"type_block": "",
"lid": "1"
}, {
"gid": "153734",
"date_time": "1516723200",
"begin_time": "1516764600",
"home_tid": "28",
"home_name": "\u52c7\u58eb",
"home_score": "0",
"away_tid": "4",
"away_name": "\u5c3c\u514b\u65af",
"away_score": "0",
"match_type": "REGULAR",
"process": "11:30\u5f00\u59cb",
"status": "3",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670824\u65e5 \u5468\u4e09",
"type_block": "",
"lid": "1"
}, {
"gid": "153735",
"date_time": "1516723200",
"begin_time": "1516764600",
"home_tid": "24",
"home_name": "\u6e56\u4eba",
"home_score": "0",
"away_tid": "1",
"away_name": "\u51ef\u5c14\u7279\u4eba",
"away_score": "0",
"match_type": "REGULAR",
"process": "11:30\u5f00\u59cb",
"status": "3",
"casino": 0,
"offical_roomid": 0,
"room_id": -1,
"default_tab": "preview",
"tvs": [],
"date": "1\u670824\u65e5 \u5468\u4e09",
"type_block": "",
"lid": "1"
}],
"rank_url": "https:\/\/games.mobileapi.hupu.com\/1\/7.1.15\/nba\/getRankPage?client=862561035110764",
"video_url": "nba"
}],
"days": {
"min": 20170101,
"max": 20180412,
"current": 20180120,
"anchor": "153702"
}
},
"is_login": 0,
"crt": 1516412142416,
"runtime": 22.15004
}

class Dept(object):
def __init__(self, x):
self.x = x

def __get__(self, instance, owner):
print('__get__: instance:{} owner:{}'.format(instance, owner))
# if not instance:
# return self
# else:
# return instance
super(Dept, self).__get__(instance, owner)

def __getattr__(self, item): #
print('__getattr__: {}'.format(item))
super(Dept, self).__getattr__(item)

def __getitem__(self, item): # “_ getitem_”只适用于所有的“[]”运算符;
print('__getitem__: {}'.format(item))
super(Dept, self).__getitem__(item)

def __getattribute__(self, item): # “_ getattribute_”只适用于所有的“.”运算符;
print('__getattribute__: {}'.format(item))
super(Dept, self).__getattribute__(item)


__get__

__get__将对象作为数据描述符

class Company:
dept = Dept(20)

c = Company()
c.dept # __get__: instance:<__main__.test2.<locals>.Company object at 0x1059b07f0> owner:<class '__main__.test2.<locals>.Company'>

__getattribute__

适用 '.' 运算符

d = Dept(15)
d.x # __getattribute__: x

__getattr__

__getattribute__ 找不到触发

d = Dept(15)
d.y # __getattribute__: y __getattr__: y

__getitem__

适用 '[]' 运算符

d = Dept(15)
d['x'] # __getitem__: x

mkdir sampleproject.git
cd sampleproject.git
git init --bare


unset GIT_DIR
DeployPath="/home/taidii/document/document/"
echo "==============================================="
cd $DeployPath
echo "deploying the document web"
git pull origin master
echo "================================================"

第二章: 字符串和文本

写在最前

### format的语法

replacement_field ::=  "{" [field_name] ["!" conversion] [":" format_spec] "}"
field_name ::= arg_name ("." attribute_name | "[" element_index "]")*
arg_name ::= [identifier | integer]
attribute_name ::= identifier
element_index ::= integer | index_string
index_string ::= <any source character except "]"> +
conversion ::= "r" | "s" | "a"
format_spec ::= <described in the next section>

format_spec ::= [[fill]align][sign][#][0][width][grouping_option][.precision][type]
fill ::= <any character>
align ::= "<" | ">" | "=" | "^"
sign ::= "+" | "-" | " "
width ::= integer
grouping_option ::= "_" | "," # 千位数的分隔符
precision ::= integer
type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"

2.15 字符串中插入变量

问题

想要创建一个内嵌变量的字符串,变量被用他的值所表示的字符串替换

解决方案

s = '{name} has {n} apples'
# 使用参数
s.format(name='link', n=10)
#'link has 10 apples'

# 使用mapping
s.format_map({'name': 'link', 'n': 10})
#'link has 10 apples'

# vars()
name = 'link'
n = 10
s.format_map(vars())
#'link has 10 apples'

vars() 还有一个有意思的特性就是它也适用于对象实例

class Info:
def __init__(self, name=None, n=None):
self.name = your
self.n =n

info = Info(name='link', n=10)
s.format_map(vars(info))
#'link has 10 apples'

但是这样还不能很好的处理参数的却是,所以我们还可以定义一个新的dict类

class SafeSub(dict):
def __missing__(self, key):
return '{' + key + '}'

info = Info(name='link')
s.format_map(SafeSub(vars()))
##'link has {n} apples'

import sys

def sub(text):
return text.format_map(safesub(sys._getframe(1).f_locals))
# sub() 函数使用 sys._getframe(1) 返回调用者的栈帧。可以从中访问属性 f_locals
# 来获得局部变量。 毫无疑问绝大部分情况下在代码中去直接操作栈帧应该是不推荐的。
# 但是,对于像字符串替换工具函数而言它是非常有用的。 另外,值得注意的是 f_locals
# 是一个复制调用函数的本地变量的字典。 尽管你可以改变 f_locals 的内容,
# 但是这个修改对于后面的变量访问没有任何影响。 所以,虽说访问一个栈帧看上去很邪恶,
# 但是对它的任何操作不会覆盖和改变调用者本地变量的值。

讨论

python 中对于字符串替换有许多其他的解决方案。例如:

name = 'Guido'
n = 37
'%(name)s %(n)d messages.' % vars()

import string
s = string.Template('$name has $n messages.')
s.substitute(vars())

但是 format 和 format_map 比这些方法都要先进。所以应该优先使用。而且还可以对齐,填充,格式化等.

2.16 以指定列宽格式化字符串

问题

你有一些长字符串,想以指定的列宽将它们重新格式化。

解决方案

使用 textwrap 模块来格式字符串输出,比如

s = "Look into my eyes, look into my eyes, the eyes, the eyes, \
the eyes, not around the eyes, don't look around the eyes, \
look into my eyes, you're under."

import textwrap
textwrap.fill(s, width=20)
# Look into my eyes,
# look into my eyes,
# the eyes, the eyes,
# the eyes, not around
# the eyes, don't look
# around the eyes,
# look into my eyes,
# you're under.

textwrap.fill(s, 40, initial_indent='****')
# ****Look into my eyes, look into my
# eyes, the eyes, the eyes, the eyes, not
# around the eyes, don't look around the
# eyes, look into my eyes, you're under.

textwrap.fill(s, 40, subsequent_indent='****')
# Look into my eyes, look into my eyes,
# ****the eyes, the eyes, the eyes, not
# ****around the eyes, don't look around
# ****the eyes, look into my eyes, you're
# ****under.

讨论

textwrap 对于字符串打印非常有用。特别是你想打印输出匹配终端大小的时候.你可以使用os.get_terminal_size()

import os
os.get_terminal_size()
# os.terminal_size(columns=76, lines=32)

2.17 在字符串中处理html和xml

问题

你想将HTML或者XML实体如 &entity; 或 &#code; 替换为对应的文本。 再者,你需要转换文本中特定的字符(比如<, >, 或 &)。

解决方案

如果你想替换文本字符串中的 ‘<’ 或者 ‘>’ ,使用 html.escape() 函数可以很容易的完成。比如:

s = 'Elements are written as "<tag>text</tag>".'
from html import escape, unescape
es = escape(s)
# 'Elements are written as &quot;&lt;tag&gt;text&lt;/tag&gt;&quot;.'

escape(s, quote=False) # 不转化 " 和 '
# 'Elements are written as "&lt;tag&gt;text&lt;/tag&gt;".'

unescape(es)
# 'Elements are written as "<tag>text</tag>".'

讨论

2.18 字符串令牌解析

2.19 实现一个简单的递归下降分析器

2.20 字节字符串上的字符串操作

Upload Python Package To PyPi or PyPiTest

~/.pypirc

[distutils]
index-servers=
pypi
testpypi

[testpypi]
repository: https://test.pypi.org/legacy/
username: your testpypi username
password: your testpypi password

twine upload --repository-url https://test.pypi.org/legacy/ dist/*
pip install --index-url https://test.pypi.org/simple/ your-package
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple your-package

twine upload --repository testpypi dist/*

#python setup.py register -r pypitest
python setup.py sdist upload -r pypitest
#python setup.py register -r pypi
python setup.py sdist upload -r pypi

Automatic Script Creation

https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation >Automatic Script Creation >Packaging and installing scripts can be a bit awkward with the distutils. For one thing, there’s no easy way to have a script’s filename match local conventions on both Windows and POSIX platforms. For another, you often have to create a separate file just for the “main” script, when your actual “main” is a function in a module somewhere. And even in Python 2.4, using the -m option only works for actual .py files that aren’t installed in a package. >setuptools fixes all of these problems by automatically generating scripts for you with the correct extension, and on Windows it will even create an .exe file so that users don’t have to change their PATHEXT settings. The way to use this feature is to define “entry points” in your setup script that indicate what function the generated script should import and run. For example, to create two console scripts called foo and bar, and a GUI script called baz, you might do something like this:

setup(
# other arguments here...
entry_points={
'console_scripts': [
'foo = my_package.some_module:main_func',
'bar = other_module:some_func',
],
'gui_scripts': [
'baz = my_package_gui:start_func',
]
})

Introduction

Convolutional networks are at the core of most stateof-the-art computer vision solutions for a wide variety of tasks. Since 2014 very deep convolutional networks started to become mainstream, yielding substantial gains in various benchmarks. Although increased model size and computational cost tend to translate to immediate quality gains for most tasks (as long as enough labeled data is provided for training), computational efficiency and low parameter count are still enabling factors for various use cases such as mobile vision and big-data scenarios. Here we are exploring ways to scale up networks in ways that aim at utilizing the added computation as efficiently as possible by suitably factorized convolutions and aggressive regularization. We benchmark our methods on the ILSVRC 2012 classification challenge validation set demonstrate substantial gains over the state of the art: 21.2% top-1 and 5.6% top-5 error for single frame evaluation using a network with a computational cost of 5 billion multiply-adds per inference and with using less than 25 million parameters. With an ensemble of 4 models and multi-crop evaluation, we report 3.5% top-5 error and 17.3% top-1 error

卷积神经网络是目前计算机解决多种多样任务的核心。自从2014年深度的卷积网络成为主流,产生了大量的不同的分支。尽管在大多数任务中增加的模型大小和计算耗费趋于能迅速得到高质量的回报,计算的效率和少量的参数依然能有效作用于很多场景。例如手机和大数据。这里我们探索一种方法能够有效率的计算的放大网络。通过分解卷积模型和积极的正则化。

Factorization convolution

example1 如图将一个55的卷积转化为2个33的卷积 则参数变为原来的 (33 + 33)/(5*5) = 72% 但是深度却增加了

#引用: * Rethinking the Inception Architecture for Computer Vision https://arxiv.org/pdf/1512.00567.pdf

Django练习

实现一个博客网站。

与当前浏览的网站类似,但也多一些附加功能 1. 登录登出功能 2. 登录后可以编辑博客的功能 3. 浏览博客的功能

GitFlow

1.概览

2.当前分支master

git pull --rebase origin master

3.第一次开始任务 TDP-xxx, 创建分支, “/”前面可用fix, feature, hotfix, 对应修改bug,新需求功能,紧急修复

git checkout -b feature/yourname_TDP-xxx

4.不是第一次开始任务,切换分支

git checkout feature/yourname_TDP-xxx

5.修改完, 提交修改

git add *
git commit -m'自己修改的内容的描述'
git push origin feature/yourname_TDP-xxx

6.自己本地测试完后线上测试,合并, merge, 切换到 dev分支, 并更新dev分支到最新

git checkout dev
git pull --rebase origin dev
git merge --no-ff feature/yourname_TDP-xxx

7.成功后

git push origin dev

8.在dev上查看自己修改是否成功, 如果没有问题,在gihub上创建pull request

一些python的练习

1. Add Digits

'''
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.

For example:

Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.

Follow up:
Could you do it without any loop/recursion in O(1) runtime?
'''

class Solution(object):
def addDigits(self, num):
pass

My solution

class Solution(object):
def addDigits(self, num):
if num==0:
return 0
return num % 9 if num % 9 !=0 else 9

def addDigits(self, num):
if num==0:
return 0
return (num - 1) % 9 + 1

# 迭代
def addDigits(self, num):
return num if num < 10 else self.addDigits(reduce(lambad x,y: int(x) + int(y), list(str(num))))

2. array partition i

'''
Given an array of 2n integers, your task is to group these integers
into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn)
which makes sum of min(ai, bi) for all i from 1 to n as large as possible.

Example 1:

Input: [1,4,3,2]

Output: 4
Explanation: n is 2, and the maximum sum of pairs is 4.

Note:

n is a positive integer, which is in the range of [1, 10000].
All the integers in the array will be in the range of [-10000, 10000].

'''
class Solution(object):
def arrayPairSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
pass

My solution

class Solution(object):
def arrayPairSum(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
return sum(sorted(nums)[::2])

3. detect capital

'''
Given a word, you need to judge whether the usage of capitals in it is right or not.

We define the usage of capitals in a word to be right when one of the following cases holds:

All letters in this word are capitals, like "USA".
All letters in this word are not capitals, like "leetcode".
Only the first letter in this word is capital if it has more than one letter, like "Google".

Otherwise, we define that this word doesn't use capitals in a right way.

Example 1:

Input: "USA"
Output: True

Example 2:

Input: "FlaG"
Output: False


'''

class Solution(object):
def detectCapitalUse(self, word):
"""
:type word: str
:rtype: bool
"""

My solution

class Solution(object):
def detectCapitalUse(self, word):
"""
:type word: str
:rtype: bool
"""
return word.isupper() or word.istitle()

4. distribute candies

"""
Given an integer array with even length, where different
numbers in this array represent different kinds of candies.
Each number means one candy of the corresponding kind.
You need to distribute these candies equally in number to
brother and sister. Return the maximum number of kinds of
candies the sister could gain.

Example 1:
Input: candies = [1,1,2,2,3,3]
Output: 3
Explanation:
There are three different kinds of candies (1, 2 and 3),
and two candies for each kind.
Optimal distribution: The sister has candies [1,2,3] and
the brother has candies [1,2,3], too.
The sister has three different kinds of candies.
Example 2:
Input: candies = [1,1,2,3]
Output: 2
Explanation: For example, the sister has candies [2,3] and
the brother has candies [1,1].
The sister has two different kinds of candies, the brother
has only one kind of candies.
Note:

The length of the given array is in range [2, 10,000], and
will be even.
The number in given array is in range [-100,000, 100,000].


class Solution(object):
def distributeCandies(self, candies):
"""
:type candies: List[int]
:rtype: int
"""

My solution

class Solution(object):
def distributeCandies(self, candies):
"""
:type candies: List[int]
:rtype: int
"""
return min(len(candies)//2, len(set(candies)))

5.two-sum-ii-input-array-is-sorted

'''
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.

The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.

You may assume that each input would have exactly one solution and you may not use the same element twice.

Input: numbers={2, 7, 11, 15}, target=9
Output: index1=1, index2=2
'''

class Solution(object):

def twoSum(self, numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""

6.single-number

'''
Given an array of integers, every element appears twice except for one. Find that single one.

Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
'''
class Solution(object):
def singleNumber(self, nums):
"""
:type nums: List[int]
:rtype: int
"""

7.reverse-words-in-a-string-iii

"""
Given a string, you need to reverse the order
of characters in each word within a sentence while
still preserving whitespace and initial word order.

Example 1:
Input: "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"
Note: In the string, each word is separated by
single space and there will not be any extra space in the string.
"""


class Solution(object):
def reverseWords(self, s):
"""
:type s: str
:rtype: str
"""

8.sum-of-left-leaves

'''
Find the sum of all left leaves in a given binary tree.

Example:

3
/ \
9 20
/ \
15 7

There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.
'''

# Definition for a binary tree node.
#class TreeNode(object):
# def __init__(self, x, left=None, right=None):
# self.val = x
# self.left = left
# self.right = right

class Solution(object):
def sumOfLeftLeaves(self, root):
"""
:type root: TreeNode
:rtype: int
"""

9.relative-ranks

'''
Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: "Gold Medal", "Silver Medal" and "Bronze Medal".

Example 1:

Input: [5, 4, 3, 2, 1]
Output: ["Gold Medal", "Silver Medal", "Bronze Medal", "4", "5"]
Explanation: The first three athletes got the top three highest scores, so they got "Gold Medal", "Silver Medal" and "Bronze Medal".
For the left two athletes, you just need to output their relative ranks according to their scores.

Note:

N is a positive integer and won't exceed 10,000.
All the scores of athletes are guaranteed to be unique.

'''


class Solution(object):
def findRelativeRanks(self, nums):
"""
:type nums: List[int]
:rtype: List[str]
"""

10.ransom-note

'''
Given an arbitrary ransom note string and another string containing letters
from all the magazines, write a function that will return true if the ransom
note can be constructed from the magazines ; otherwise, it will return false.

Each letter in the magazine string can only be used once in your ransom note.

Note:
You may assume that both strings contain only lowercase letters.

canConstruct("a", "b") -> false
canConstruct("aa", "ab") -> false
canConstruct("aa", "aab") -> true

'''
class Solution(object):
def canConstruct(self, ransomNote, magazine):
"""
:type ransomNote: str
:type magazine: str
:rtype: bool
"""

11.matrix

'''
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.

The distance between two adjacent cells is 1.
Example 1:
Input:

0 0 0
0 1 0
0 0 0
Output:
0 0 0
0 1 0
0 0 0
Example 2:
Input:

0 0 0
0 1 0
1 1 1
Output:
0 0 0
0 1 0
1 2 1
Note:
The number of elements of the given matrix will not exceed 10,000.
There are at least one 0 in the given matrix.
The cells are adjacent in only four directions: up, down, left and right.

'''

class Solution(object):
def updateMatrix(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: List[List[int]]
"""

12.1-bit-and-2-bit-characters

'''
We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).

Now given a string represented by several bits. Return whether the last character must be a one-bit character or not. The given string will always end with a zero.

Example 1:
Input:
bits = [1, 0, 0]
Output: True
Explanation:
The only way to decode it is two-bit character and one-bit character. So the last character is one-bit character.
Example 2:
Input:
bits = [1, 1, 1, 0]
Output: False
Explanation:
The only way to decode it is two-bit character and two-bit character. So the last character is NOT one-bit character.
Note:

1 <= len(bits) <= 1000.
bits[i] is always 0 or 1.
'''


class Solution(object):
def isOneBitCharacter(self, bits):
"""
:type bits: List[int]
:rtype: bool
"""

13.132 Pattern

Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input and checks whether there is a 132 pattern in the list.

Note: n will be less than 15,000.

Example 1:
Input: [1, 2, 3, 4]

Output: False

Explanation: There is no 132 pattern in the sequence.
Example 2:
Input: [3, 1, 4, 2]

Output: True

Explanation: There is a 132 pattern in the sequence: [1, 4, 2].
Example 3:
Input: [-1, 3, 2, 0]

Output: True

Explanation: There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0].

class Solution(object):
def find132pattern(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""

方差,协方差,协方差矩阵, 去中心化, whiting, dewhiting

参考:http://blog.csdn.net/kuang_liu/article/details/16369475 http://blog.csdn.net/beechina/article/details/51074750

平均值

描述样本的中点

方差

描述样本的集中程度,样本集合各个样本点到中点的距离的平均值得平方

协方差(convariance)

各个维度的参数之间的相关性. 正:正相关,负:负相关,0:相对独立

协方差矩阵(convariance matrix)

多维度的协方差

计算方法: * 1.各个维度去中心化,即减去各维度的平均值,使各个维度的平均值都为0, 得到矩阵 X * 2. Cov = X * X.T / (m - 1)

restricted Boltzmann machine, RBM

配分函数, 条件独立

对比分歧(contrastive divergence,CD)算法

Deep belief network

0%