mlp_clf_mnist_test
import os
os.environ['CUDA_VISIBLE_DEVICES'] = "0"
from mlp_clf import MLPClassifier
import numpy as np
import tensorflow as tf
from sklearn.datasets import load_svmlight_file
from sklearn.utils import shuffle
#from scipy.sparse import csr_matrix
def mean(numbers): #计算平均值
s = 0.0
for num in numbers:
s = s + num
return s/len(numbers)
def dev(numbers, mean): #计算方差
sdev = 0.0
for num in numbers:
sdev = sdev + (num - mean)**2
return pow(sdev / (len(numbers)-1), 0.5) if __name__ == '__main__':
mze_array=[]
mae_array=[]
mse_array=[]
trainfile = "test_housing.0"
testfile = "train_housing.0"
X_train0, y_train = load_svmlight_file(trainfile)
X_test0 , y_test = load_svmlight_file(testfile)
X_train = X_train0.todense()
X_test = X_test0.todense()
attribute = np.shape(X_train)[-1]#tf.shape(X_train)
n_class = tf.reduce_max(y_train)
print("n_class:", n_class) X_train, y_train = shuffle(X_train, y_train, random_state=0)
y_train = y_train - 1
y_test = y_test - 1
clf = MLPClassifier(attribute, 5, [100]*3)
log = clf.fit(X_train, y_train, n_epoch=1000, keep_prob=0.8, val_data=(X_test, y_test))
Y_pred = clf.predict(X_test)
mze = 1- (Y_pred == y_test).mean()
mae = np.abs(Y_pred.ravel()-y_test.ravel()).astype(float).mean()
mse = np.power(Y_pred.ravel()-y_test.ravel(),2).astype(float).mean()
print("mze: %.4f" % mze)
print("mae:", mae)
print("mse:", mse)
Rudolf Wille. Restructuring lattice theory: An approach based on hierarchies of concepts. In Sébastien Ferré andSebastian Rudolph, editors,Formal Concept Analysis, pages 314–339, Berlin, Heidelberg, 2009. Springer BerlinHeidelberg.
R. Wille. Restructuring lattice theory: An approach based on hierarchies of concepts. In
I. Rival, editor, Ordered Sets, pages 445–470. Reidel, Dordrecht-Boston, 1982.
mlp_clf_mnist_test的更多相关文章
随机推荐
- insert into TABLE by SELECT ...
insert into isp_rmi3 ( select r.id, r.blue_id, r.sell_channel,NULL, r.interface_id, NULL, NULL, r.ur ...
- go语言入门教程:基本语法之变量声明及注意事项
一.变量的使用 1.1 什么是变量 变量是为存储特定类型的值而提供给内存位置的名称.在go中声明变量有多种语法. 所以变量的本质就是一小块内存,用于存储数据,在程序运行过程中数值可以改变 1.2 声明 ...
- vmware中centos6.7系统图形化安装Oracle显示乱码问题解决
root下: 修改环境属性 vi /etc/sysconfig/i18n LANG="en_US.UTF-8 1.在每次调用图形界面以前,我们使用export临时设置LANG(ORACLE ...
- cxgrid 非编辑状态下复制当前列的值 真折腾人
1.自带的CTRL +C 只能复制整行,不知是不是版本问题. 2.有分组这个代码就不行了 s:= G1DBView.DataController.Values[G1DBView.Controller. ...
- flutter packages.
connectivity This plugin allows Flutter apps to discover network connectivity and configure themselv ...
- shell实现rpm -e 一键卸载所有相关包以及依赖
原理也比较简单, 刚好用到就稍微写了一下, 做个笔记 #!/bin/bash #************************************************************ ...
- docker17.03.2安装
之前安装过docker 卸载 yum -y remove docker docker-common docker-selinux docker-engine docker-engine-selinux ...
- iOS日期问题
由于项目需要,需要获取去设备的当前时间,组成一个字符串,比如 2018年9月15日 15点30分30秒,需要转换成字符创:180915153030. 很简单的一个需求,于是就使用了日期格式话当前时间: ...
- Vue/Egg大型项目开发(二)数据库设计
项目Github地址:前端(https://github.com/14glwu/stuer)后端(https://github.com/14glwu/stuer-server) 项目线上预览:http ...
- C#线程同步(1)- 临界区&Lock
文章原始出处 http://xxinside.blogbus.com/logs/46441956.html 预备知识:线程的相关概念和知识,有多线程编码的初步经验. 一个机会,索性把线程同步的问题在C ...