Skip to content

Instantly share code, notes, and snippets.

@domitry
Created March 19, 2015 04:19
Show Gist options
  • Select an option

  • Save domitry/3c4bdff4a642be1f971f to your computer and use it in GitHub Desktop.

Select an option

Save domitry/3c4bdff4a642be1f971f to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:02409daf487020a689bb08aff53e2e29dcf334faa027a39e951137922b9642d4"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"%matplotlib inline"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"from scipy import misc"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import matplotlib.pyplot as plt"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"arr = np.array([\n",
" [0.1, 0.2, 0.3, 0.4],\n",
" [0.5, 0.6, 0.7, 0.8]\n",
"])"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 20
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"misc.imsave(\"/home/domitry/hoge.png\", arr)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 26
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"arr=np.array([[[0,1], [1,2]], [[0,1], [1,2]]])"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 32
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"arr = np.array([[[ 1.21255529, -0.3938947 , -0.54578036],\n",
" [ 0.77679747, -1.37460458, 0.96078122],\n",
" [ 2.4723177 , -1.06321895, -1.66590321],\n",
" [ 0.6950469 , -0.4063907 , -0.84338689]],\n",
"\n",
" [[ 0.02496378, 0.16250661, 0.44537154],\n",
" [-0.33413932, 1.21392608, -0.06310973],\n",
" [ 1.18955934, -0.47675383, -0.90231454],\n",
" [ 1.22462106, -1.43571079, -1.70498145]],\n",
"\n",
" [[-0.28524151, 1.70603204, 1.07846832],\n",
" [-0.48489493, -1.60688257, 0.44301993],\n",
" [-1.45467246, -0.49267125, -0.53261089],\n",
" [ 0.07929045, -0.42402181, -1.61823952]],\n",
"\n",
" [[-0.50817877, 1.4740814 , -0.32837248],\n",
" [-0.91768545, -0.19822542, -0.58821714],\n",
" [ 0.02163632, -0.3047007 , 1.44845462],\n",
" [-0.36023185, -0.20242979, 0.5471952 ]],\n",
"\n",
" [[-1.24845898, 0.76220262, -0.63447714],\n",
" [ 0.98508805, 1.73147178, 0.37828854],\n",
" [ 0.64867836, 0.23099023, 0.09250945],\n",
" [ 0.91038644, -1.31757283, -0.64555782]]], dtype=np.float32)\n"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 36
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"arr.shape"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 40,
"text": [
"(5, 4, 3)"
]
}
],
"prompt_number": 40
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"arr"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 41,
"text": [
"array([[[ 1.21255529, -0.3938947 , -0.54578036],\n",
" [ 0.77679747, -1.37460458, 0.96078122],\n",
" [ 2.4723177 , -1.06321895, -1.66590321],\n",
" [ 0.6950469 , -0.4063907 , -0.84338689]],\n",
"\n",
" [[ 0.02496378, 0.16250661, 0.44537154],\n",
" [-0.33413932, 1.21392608, -0.06310973],\n",
" [ 1.18955934, -0.47675383, -0.90231454],\n",
" [ 1.22462106, -1.43571079, -1.70498145]],\n",
"\n",
" [[-0.28524151, 1.70603204, 1.07846832],\n",
" [-0.48489493, -1.60688257, 0.44301993],\n",
" [-1.45467246, -0.49267125, -0.53261089],\n",
" [ 0.07929045, -0.42402181, -1.61823952]],\n",
"\n",
" [[-0.50817877, 1.4740814 , -0.32837248],\n",
" [-0.91768545, -0.19822542, -0.58821714],\n",
" [ 0.02163632, -0.3047007 , 1.44845462],\n",
" [-0.36023185, -0.20242979, 0.5471952 ]],\n",
"\n",
" [[-1.24845898, 0.76220262, -0.63447714],\n",
" [ 0.98508805, 1.73147178, 0.37828854],\n",
" [ 0.64867836, 0.23099023, 0.09250945],\n",
" [ 0.91038644, -1.31757283, -0.64555782]]], dtype=float32)"
]
}
],
"prompt_number": 41
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"arr.reshape(20, 3)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 39,
"text": [
"array([[ 1.21255529, -0.3938947 , -0.54578036],\n",
" [ 0.77679747, -1.37460458, 0.96078122],\n",
" [ 2.4723177 , -1.06321895, -1.66590321],\n",
" [ 0.6950469 , -0.4063907 , -0.84338689],\n",
" [ 0.02496378, 0.16250661, 0.44537154],\n",
" [-0.33413932, 1.21392608, -0.06310973],\n",
" [ 1.18955934, -0.47675383, -0.90231454],\n",
" [ 1.22462106, -1.43571079, -1.70498145],\n",
" [-0.28524151, 1.70603204, 1.07846832],\n",
" [-0.48489493, -1.60688257, 0.44301993],\n",
" [-1.45467246, -0.49267125, -0.53261089],\n",
" [ 0.07929045, -0.42402181, -1.61823952],\n",
" [-0.50817877, 1.4740814 , -0.32837248],\n",
" [-0.91768545, -0.19822542, -0.58821714],\n",
" [ 0.02163632, -0.3047007 , 1.44845462],\n",
" [-0.36023185, -0.20242979, 0.5471952 ],\n",
" [-1.24845898, 0.76220262, -0.63447714],\n",
" [ 0.98508805, 1.73147178, 0.37828854],\n",
" [ 0.64867836, 0.23099023, 0.09250945],\n",
" [ 0.91038644, -1.31757283, -0.64555782]], dtype=float32)"
]
}
],
"prompt_number": 39
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment