本文整理汇总了Python中trainer.Trainer.onehot_to_int方法的典型用法代码示例。如果您正苦于以下问题:Python Trainer.onehot_to_int方法的具体用法?Python Trainer.onehot_to_int怎么用?Python Trainer.onehot_to_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trainer.Trainer
的用法示例。
在下文中一共展示了Trainer.onehot_to_int方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_stats
# 需要导入模块: from trainer import Trainer [as 别名]
# 或者: from trainer.Trainer import onehot_to_int [as 别名]
def plot_stats(X,Y,model,costs):
#two plots, the decision fcn and points and the cost over time
y_onehot = Trainer.class_to_onehot(Y)
f,(p1,p2) = plot.subplots(1,2)
p2.plot(range(len(costs)),costs)
p2.set_title("Cost over time")
#plot points/centroids/decision fcn
cls_ct = y_onehot.shape[1]
y_cls = Trainer.onehot_to_int(y_onehot)
colors = get_cmap("RdYlGn")(np.linspace(0,1,cls_ct))
#model_cents = model.c.get_value()
#p1.scatter(model_cents[:,0], model_cents[:,1], c='black', s=81)
for curclass,curcolor in zip(range(cls_ct),colors):
inds = [i for i,yi in enumerate(y_cls) if yi==curclass]
p1.scatter(X[inds,0], X[inds,1], c=curcolor)
nx,ny = 200, 200
x = np.linspace(X[:,0].min()-1,X[:,0].max()+1,nx)
y = np.linspace(X[:,1].min()-1,X[:,1].max()+1,ny)
xv,yv = np.meshgrid(x,y)
Z = np.array([z for z in np.c_[xv.ravel(), yv.ravel()]])
Zp = Trainer.onehot_to_int(np.array(model.probability(Z)))
Zp = Zp.reshape(xv.shape)
p1.imshow(Zp, interpolation='nearest',
extent=(xv.min(), xv.max(), yv.min(), yv.max()),
origin = 'lower', cmap=get_cmap("Set1"))
p1.set_title("Decision boundaries and centroids")
f.tight_layout()
plot.show()
示例2: theano_perf
# 需要导入模块: from trainer import Trainer [as 别名]
# 或者: from trainer.Trainer import onehot_to_int [as 别名]
def theano_perf(model, Xnew, Ynew):
#Xnew,ynew = gaussian_data_gen()
#Xnew,ynew = exotic_data_gen()
ynew_onehot = Trainer.class_to_onehot(ynew)
yhat = np.array(model.predict(Xnew))
yhat = Trainer.onehot_to_int(yhat)
errs= 0
for yh,t in zip(yhat,ynew):
errs += 1 if yh != t else 0
err_rate = 100*float(errs)/ynew.shape[0]
print 'Accuracy:',100-err_rate,'Errors:',errs