如何将表单的IPython HTML对象输出<IPython.core.display.HTML object>到磁盘上的HTML文件或PDF文件?
我看到了关于如何在Jupyter笔记本中可视化张量流图的这个问题.我发现这个答案来自这个例子,只有一个修改(tensor.tensor_content = bytes("<stripped %d bytes>"%size, 'utf-8')被替换tensor.tensor_content = "<stripped %d bytes>"%size).但是,如果我尝试tensorflow_inception_graph.pb在可视化上重新运行它不起作用:iframe是白色的,并且没有显示节点.
如果你向我解释我做错了什么,我将非常感激.这里有一个简单的例子来重现这个问题.
进口:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import tensorflow as tf
import numpy as np
from IPython.display import clear_output, Image, display, HTML
Run Code Online (Sandbox Code Playgroud)
创建图表:
graph = tf.Graph()
sess = tf.InteractiveSession(graph=graph)
x = tf.placeholder(tf.float32, shape=[None, 25, 25, 3], name='x')
y_true = tf.placeholder(tf.float32, shape=[None, 10], name='y_true')
y_true_cls = tf.argmax(y_true, dimension=1, name='y_true_cls')
print graph.get_operations()
Run Code Online (Sandbox Code Playgroud)
输出:
[<tensorflow.python.framework.ops.Operation at 0x115902850>,
<tensorflow.python.framework.ops.Operation at 0x115902690>,
<tensorflow.python.framework.ops.Operation at …Run Code Online (Sandbox Code Playgroud) 例如,我有一个Python模块和一个iPython模块,
cmd.py
import sys
print sys.argv
Run Code Online (Sandbox Code Playgroud)
test.ipynb
for i in range(5):
%run cmd.py i
Run Code Online (Sandbox Code Playgroud)
当我运行test.ipynb时,它只是多次打印['cmd.py','i'].如何将i的值而不是'i'作为命令行参数传递?
我一直在尝试使用Python中的opencv将图像转换为灰度,但它将图像转换为某种热像仪图像.我究竟做错了什么?以下是图片的代码:
img =X_tr[9999]
plt.imshow(img)
plt.show()
img = cv2.cvtColor(img.astype(np.uint8), cv2.COLOR_RGB2GRAY)
plt.imshow(img)
plt.show()
img.shape
Run Code Online (Sandbox Code Playgroud)
我们可以更改IPython使用的Python解释器的版本吗?
我知道有IPython和IPython3,但问题是,IPython使用Python2.7,而IPython3使用Python3.4.2,我认为没有办法改变它.
如果我希望IPython使用我想要的任何版本的Python解释器,我可以这样做吗?
我希望IPython使用最新的Python版本Python3.6.我能这样做吗?
我试着在我的操作系统上安装ipython笔记本.但是有一个错误.我怎么能解决这个问题?
sudo apt-get install ipython-notebook
Run Code Online (Sandbox Code Playgroud)
读取包列表...完成
构建依赖关系树
读取状态信息...完成
包ipython-notebook不可用,但由另一个packag引用.这可能意味着包丢失,已被淘汰或仅可从其他来源获得
E:包'ipython-notebook'没有安装候选者
我正在尝试将.py文件传递给ipython笔记本环境.我之前从未直接与argparse打过交道.我该如何重写这个main()功能?
我试图删除该行def main():并保留其余代码.
但是args = parser.parse_args()"返回了一个错误:
ipykernel_launcher.py:错误:无法识别的参数:-f.
当我跑.%tb: 显示这个
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--data_dir', type=str, default='data/tinyshakespeare',
help='data directory containing input.txt')
parser.add_argument('--input_encoding', type=str, default=None,
help='character encoding of input.txt, from https://docs.python.org/3/library/codecs.html#standard-encodings')
parser.add_argument('--log_dir', type=str, default='logs',
help='directory containing tensorboard logs')
parser.add_argument('--save_dir', type=str, default='save',
help='directory to store checkpointed models')
parser.add_argument('--rnn_size', type=int, default=256,
help='size of RNN hidden state')
parser.add_argument('--num_layers', type=int, default=2,
help='number of layers in the RNN')
parser.add_argument('--model', type=str, default='lstm',
help='rnn, gru, or lstm')
parser.add_argument('--batch_size', type=int, default=50, …Run Code Online (Sandbox Code Playgroud) 我尝试在我的jupyter notbook中测量查询速度
%time
a10= pd.read_sql('SELECT t.id, t.order_id FROM transactions.t', con=db_connection)
Run Code Online (Sandbox Code Playgroud)
无论我的查询是什么输出总是
Wall time: 0 ns
Run Code Online (Sandbox Code Playgroud)
我假设 %time与之前的单元格没有关系,这个单元格需要超过10个才能执行,为什么Wall time: 0 ns?
我是Python的新手,正在尝试绘制两个函数的计算速度。例如,定义了两个函数(见下文),如何使用IPython / Jupyter中的timeit函数返回每次迭代的时间?
def func1(x) :
return x*x
def func2(x) :
return x+x
%timeit for x in range(100) : func1(x)
%timeit for x in range(100) : func2(x)
Run Code Online (Sandbox Code Playgroud)
我阅读了https://ipython.org/ipython-doc/3/interactive/magics.html,可以使用'-o'返回“可以存储在变量中的TimeitResult,以更详细地检查结果”。
但是,如何将其保存到变量“ func1_time”中?如何读取每次迭代的时间?我的目标是为两个函数绘制x与时间的关系。
任何帮助都感激不尽。谢谢。
ipython ×10
python ×8
jupyter ×2
python-3.x ×2
matplotlib ×1
opencv ×1
pandas ×1
tensorboard ×1
tensorflow ×1
timeit ×1
ubuntu ×1