Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy import added & Minor typo fixes #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 29 additions & 64 deletions vocabulary-embedding.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Generate intial word embedding for headlines and description"
"Generate initial word embedding for headlines and description"
]
},
{
Expand Down Expand Up @@ -67,7 +67,7 @@
},
"outputs": [],
"source": [
"lower = False # dont lower case the text"
"lower = False # don't lower case the text"
]
},
{
Expand Down Expand Up @@ -118,9 +118,7 @@
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -141,9 +139,7 @@
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -163,9 +159,7 @@
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -192,9 +186,7 @@
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -214,9 +206,7 @@
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -279,9 +269,7 @@
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -300,9 +288,7 @@
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stderr",
Expand Down Expand Up @@ -382,9 +368,7 @@
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"word2idx, idx2word = get_idx(vocab, vocabcount)"
Expand Down Expand Up @@ -428,9 +412,7 @@
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -457,6 +439,8 @@
},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"glove_index_dict = {}\n",
"glove_embedding_weights = np.empty((glove_n_symbols, embedding_dim))\n",
"globale_scale=.1\n",
Expand All @@ -474,9 +458,7 @@
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand Down Expand Up @@ -524,9 +506,7 @@
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -552,7 +532,7 @@
"for i in range(vocab_size):\n",
" w = idx2word[i]\n",
" g = glove_index_dict.get(w, glove_index_dict.get(w.lower()))\n",
" if g is None and w.startswith('#'): # glove has no hastags (I think...)\n",
" if g is None and w.startswith('#'): # glove has no hashtags (I think...)\n",
" w = w[1:]\n",
" g = glove_index_dict.get(w, glove_index_dict.get(w.lower()))\n",
" if g is not None:\n",
Expand Down Expand Up @@ -618,9 +598,7 @@
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -666,9 +644,7 @@
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -720,9 +696,7 @@
{
"cell_type": "code",
"execution_count": 50,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -743,9 +717,7 @@
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -765,9 +737,7 @@
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"data": {
Expand All @@ -789,7 +759,6 @@
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
Expand All @@ -811,9 +780,7 @@
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import cPickle as pickle\n",
Expand All @@ -824,9 +791,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"import cPickle as pickle\n",
Expand All @@ -837,23 +802,23 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}