Skip to content

Commit

Permalink
npy to tsv
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemcdonald committed Mar 27, 2019
1 parent 73f7427 commit cdc8b81
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 4 deletions.
113 changes: 113 additions & 0 deletions notebooks/Convert npy to tsv.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(59278, 2)"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fn = '../data/embeddings/vgg-features/0.001_02.npy'\n",
"data = np.load(fn) # for example\n",
"data.shape"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'../data/embeddings/vgg-features/0.001_02'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"base, ext = os.path.splitext(fn)\n",
"base"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"np.savetxt(base + '.tsv', data, fmt='%.6f', delimiter='\\t')"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"-0.108286\t0.956712\n",
"-2.474535\t1.238178\n",
"-3.612925\t-0.142234\n",
"-4.482140\t1.240151\n",
"-5.837327\t-0.116471\n",
"3.578581\t-3.199628\n",
"-3.753419\t-0.572464\n",
"-0.245753\t-1.700461\n",
"5.664521\t-1.772062\n",
"6.661889\t-0.146352\n"
]
}
],
"source": [
"!head {base}.tsv"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [conda env:tf3k]",
"language": "python",
"name": "conda-env-tf3k-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 4 additions & 4 deletions notebooks/Create Mosaic.ipynb

Large diffs are not rendered by default.

0 comments on commit cdc8b81

Please sign in to comment.