我试着跑
#!/usr/bin/env python
import os
from numpy import *
b= ones((3, 3))
print b
save('fff', b)
a = load('fff.npy')
print a.shape
print 'fertig'
Run Code Online (Sandbox Code Playgroud)
但它引起了:
Traceback (most recent call last):
File "savetest.py", line 9, in <module>
a = load('fff.npy')
File "/usr/lib/python2.6/dist-packages/numpy/lib/io.py", line 195, in load
return format.read_array(fid)
File "/usr/lib/python2.6/dist-packages/numpy/lib/format.py", line 353, in read_array
shape, fortran_order, dtype = read_array_header_1_0(fp)
File "/usr/lib/python2.6/dist-packages/numpy/lib/format.py", line 250, in read_array_header_1_0
d = safe_eval(header)
File "/usr/lib/python2.6/dist-packages/numpy/lib/utils.py", line 840, in safe_eval
ast = compiler.parse(source, "eval")
File "/usr/lib/python2.6/compiler/transformer.py", line 53, …Run Code Online (Sandbox Code Playgroud) 在我的理解中,epoch 是在整个数据集上任意频繁地重复运行,然后分部分处理,即所谓的批处理。每次train_on_batch计算损失后,权重都会更新,下一批将获得更好的结果。这些损失是我对神经网络质量和学习状态的指标。
在几个来源中,每个时期都会计算(并打印)损失。因此,我不确定我这样做是否正确。
目前我的 GAN 看起来像这样:
for epoch:
for batch:
fakes = generator.predict_on_batch(batch)
dlc = discriminator.train_on_batch(batch, ..)
dlf = discriminator.train_on_batch(fakes, ..)
dis_loss_total = 0.5 * np.add(dlc, dlf)
g_loss = gan.train_on_batch(batch,..)
# save losses to array to work with later
Run Code Online (Sandbox Code Playgroud)
这些损失是针对每个批次的。我如何在一个时代获得它们?顺便说一句:我需要一个时代的损失,为了什么?
python machine-learning keras generative-adversarial-network
我正在尝试使用Fortan90验证目录是否存在.在我发现的各种网站上:
logical :: dir_e
inquire(file='./docs/.', exist=dir_e)
if ( dir_e ) then
write(*,*) "dir exists!"
else
! workaround: it calls an extern program...
call system('mkdir docs')
end if
Run Code Online (Sandbox Code Playgroud)
但是,inquire返回False目录是否存在,如果我执行此代码两次,我收到一条错误消息
无法制作dir,文件已经存在
如果我使用:
inquire(file='./docs/test', exist=dir_e)
Run Code Online (Sandbox Code Playgroud)
使用现有文件测试,inquire返回true.
如何检查目录的存在?我正在使用ubuntu 11.04和ifort编译器.
我想绘制概率函数(如二项分布),但我找不到返回给定参数概率的函数.要自己编写,我需要二项式系数(我可以自己写),我也没有找到函数.有这么简单和/或容易吗?
澄清一下:我不想画直方图,我不想在一条线上画一条线.
我想编写一个接受用户输入的程序。到目前为止我很好。但是用户输入的数量会失控,并且在调试时手动完成是不切实际的。有没有可能让 eclipse 为我做用户输入?如果是,它看起来如何?用户输入是一堆以不同方式分隔的整数。有没有办法继续使用扫描仪,因为我也想测试扫描仪?