工行纸黄金收益及收益率计算工具

使用Python预测黄金AU9999收盘价 使用Python处理黄金数据集,并构建数据模型来预测收盘价格 阅读详情

工行纸黄金不同于股票交易账户, 它直接和银行账户绑定.在进行多次不同重量的买入和卖出后, 统计一段时间的收益和收益率变得比较困难.

下面的这个程序可以对工行的导出纯文本进行自动分析得到收益值和收益率, 并可以对时间有序的多数据文本文件进行统计操作.

[Environment: GCC-4.4.3.]

#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h> /* isdigit */

#define GOLDCALC_VERSION "0.0.3 for ICBC paper gold."
#define GOLDCALC_DATE    "2011-12-28"

//#define DTEST
#ifdef DTEST
	#define dprint(x...) printf(x)
#else
	#define dprint(x...) 
#endif

#define MAX_FILE_NUMBER 10
#define MAX_PATH_LENGTH 150

enum {
	UNKOWN = 0,
	BUY,
	SELL,
};

struct one_trade_node {
	char date[11];
#if 0	
	char time[9];
	char no[10];
#endif
	int  type;
	float  price;
	float  weight;
	float  subsum;
	int  line;
	struct one_trade_node *next;
};		

static double current_price, current_weight, current_sum;

static inline int _validline(char *line)
{
	int i = 0x1 & (isdigit(line[0]) && isdigit(line[1]) && isdigit(line[2]) && isdigit(line[3]));
	return ((i) && (line[4] == '-') && (line[7] == '-'));
}

static double _katof(const char *str)
{
	char p[50];
	bzero(p, sizeof(p));
	char *q = p;
	while ( *str != '\0') {
		if (*str != ',')
			*q = *str, q++;
		str++;	
	}
	return (atof(p));	
}

static inline int _date_order_check(const char *new, const char *old)
{
	int i, ret=1;
	for (i=0; i<10; i++) {
		if (new[i]- old[i] != 0) {
			ret = ((new[i] - old[i] > 0) ? 1 : 0);
			break;
		}	
	}
	return (ret);	
}

static double _get_cost_sum(struct one_trade_node *head)
{
	struct one_trade_node *p = head->next;
	
	if (p->type != BUY) {
		dprint("This data file is probable incomplete, normal one should start with a BUY.\n");
	}	

	double cost, cash;
	int i = 0;
	cost = cash = 0;
	while(p) {
		i++;
		if (p->type == BUY) {
			if (p->subsum > cash) {
 				cost += p->subsum - cash;
				cash = 0;
			}	
			else
				cash -= p->subsum;
		}	
		else {
			cash += p->subsum;
		}	
		p = p->next;
		dprint("%2d cost: %0.2f\n", i, cost);
	}
	dprint("cost sum: %0.2f\n", cost);
	return (cost);
}

static int parser(FILE *fp, struct one_trade_node *head)
{
	char *lineptr = NULL;
	unsigned char *p, *q;
	size_t len;
	ssize_t read;
	int line_num = 0;
	int i;
	char *token, *saveptr;
	static char lastdate[11];
	static int inited = 0;
	struct one_trade_node *node;

	if (!inited) {
		bzero(lastdate, sizeof(lastdate));
		inited++;
	}
	
	while (head->next)
		head = head->next;

	while ((read = getline(&lineptr, &len, fp)) != -1) {
		line_num++;
		if (read < 30 || !_validline(lineptr))
			continue;	
		dprint("\n--------\n");
		dprint("line: %d\n", line_num);

		head->next = node = (struct one_trade_node *)malloc(sizeof(struct one_trade_node));
		bzero(node, sizeof(node));
		p = q = (unsigned char *)lineptr; // for recognizing Chinese characters.
		
		strncpy(node->date, (char*)p, 10);
		dprint("Node's date: %s, last node's date: %s\n", node->date, lastdate);
		if (!_date_order_check(node->date, lastdate)) {
			printf("Invalid date file with disorder date:  OLD: %s -> NEW: %s.\n", lastdate, node->date);
			goto ERROR;
		}	
		strncpy(lastdate, (char*)p, 10);
		
		node->line = line_num;
		for (i=0; i<read-4; i++) {
			if (p[i] == 0xc2 && p[i+1] == 0xf2 && p[i+2] == 0xc8 && p[i+3] == 0xeb)
				node->type = BUY; // buy
			else 
			if (p[i] == 0xc2 && p[i+1] == 0xf4 && p[i+2] == 0xb3 && p[i+3] == 0xf6)
				node->type = SELL; // sell
		}	
	
		for (i=0;;q=NULL,i++) {
			token = strtok_r((char*)q, " ", &saveptr);	
			if (token == NULL) break;
			if (i == 6) {
				node->price = _katof(token);
				dprint("Price token: %s, %.02f\n", token, node->price); 
			}
			if (i == 7) {
				node->weight = _katof(token);
				dprint("Weight token: %s, %.02f\n", token, node->weight); 
			}
			if (i == 8) {
				node->subsum = _katof(token);
				dprint("Subsum token: %s, %.02f\n", token, node->subsum); 
			}	
		}	
		if (node->type == 0 || i != 10 )
			goto ERROR;
		head = head->next;
	}

	if (lineptr)
		free(lineptr);
	return 0;
	
ERROR:	
	if (lineptr)
		free(lineptr);
	printf("Parsering error in line: %d\n", line_num);
	return -1;
}

static void print(struct one_trade_node *head)
{
	double buysum, sellsum, totalsum, earnsum, costsum, earnratio;
	buysum = sellsum = totalsum = earnsum = earnratio = 0;
	struct one_trade_node *last, *q, *p = head->next; 
	q = p;
	printf("---------------------------------------------------------\n");
	if ((int)current_sum == 0)
	printf("Warning: Please confirm that no gold left currently.     \n");
	printf("---------------------------------------------------------\n");
	printf("                   HISTORY RECORD                        \n");
	printf("                   --------------                        \n");
	printf("DATE          TYPE    PRICE       WEIGHT      SUM        \n");
	printf("---------------------------------------------------------\n");

	while (p) {
		printf("%s:   %-4s    %-8.2f    %-8.2f    %-8.2f\n", p->date, (p->type==1) ? "BUY" : "SELL",
			    p->price, p->weight, p->subsum);
		if (p->type == 1)
			buysum += p->subsum;
		else
			sellsum += p->subsum;
		last = p;
		p = p->next;
	}
	if (p == q) {
		printf("No valid  data can display.\n");
		printf("---------------------------------------------------------\n");
		return;
	}
	printf("---------------------------------------------------------\n");
	sellsum += current_sum;
	totalsum = buysum + sellsum;
	earnsum = sellsum - buysum;
	costsum = _get_cost_sum(head); // costsum is the maximum cost value during the investing period.
	earnratio = earnsum / costsum;
	printf("                       SUMMARY                            \n");
	printf("                   ---------------                        \n");
	printf("Current Sum Pending Sell: %.2f Yuan[%.f gram, %.02f Yuan/g]\n", current_sum, current_weight, current_price);
	printf("Totally Earning:          %0.2f Yuan\n", earnsum);
	printf("Totally Earning Ratio:    %.2f%%\n", earnratio*100);
	printf("Totally Cost:             %0.2f Yuan\n", costsum);
	printf("Date Range:               %s -> %s \n", head->next->date, last->date);
	printf("---------------------------------------------------------\n");
	return;
}

static void clear(struct one_trade_node *head)
{
	struct one_trade_node *q, *p;
	p = head;
	while(p) {
		q = p->next;
		free(p);
		p = q;
	}	
	return;
}

static void usage(char *cmd)
{
	printf("---------------------------------------------------------\n");
	printf("goldcalc Version: %s, Date: %s\n", GOLDCALC_VERSION, GOLDCALC_DATE);
	printf("Usage: %s -f $data_file_path -s $current_sum \n", cmd);
	printf("	   \"-p $current_price\" and \"-w $current_weight\" are optional if without -s option.\n");
	printf("       Note: if more than one data file need be parsed, can use several -f option with date in order.\n");
	printf("---------------------------------------------------------\n");
	return;
}


int main(int argc, char **argv)
{
	int opt, ret, i;
	FILE *fp;
	char **p, *path[MAX_PATH_LENGTH];

	if (argc < 3) {
		usage(argv[0]);
		return -1;
	}
	
	for (i=0; i<MAX_FILE_NUMBER; i++) {
		path[i] = (char*)calloc(MAX_PATH_LENGTH, sizeof(char));
	}
	p = path;
	
	current_price = current_weight = current_sum = 0;
	while ((opt = getopt(argc, argv, "p:w:s:i:f:h")) != -1) {
		switch (opt) {
		case 'p':
			current_price = _katof(optarg);
			break;
		case 'w':
			current_weight = _katof(optarg);
			break;
		case 's':
			current_sum = _katof(optarg);
			break;
		case 'i':
		case 'f':
			strncpy(*p, optarg, MAX_PATH_LENGTH-1);
			p++;
			break;
		case 'h':
			usage(argv[0]);
			return 0;
		default:
			printf("Unknown option: -%c\n", opt);
			return -2;
		}
	}
	dprint("current_price: %.2f, current_weight: %.2f, current_sum: %.2f\n", current_price,
		    current_weight, current_sum);

	if (current_price > 0 && current_sum > 0) {
		if ((int)(current_price * current_weight) != (int)current_sum) {
			printf("Error happen in one of current price/weight/sum value.\n");
			return -3;
		}	
	} else if (current_price > 0 ) {
		current_sum = (current_price*current_weight);
	}

	struct one_trade_node *head = (struct one_trade_node *)malloc(sizeof(struct one_trade_node));
	p = path;
	
	while (*p[0] != '\0') {
		if ((fp = fopen(*p, "r")) == NULL) {
			printf("Invalid file path: %s\n",*p);
			return -4;
		}

		dprint("\nData File Number: %d", p-path+1);
		if ((ret = parser(fp, head)) != 0) {
			printf("Parser error for the %d file, check data file content first.\n", p-path+1);
			fclose(fp);	
			return -5;
		}
		p++;
		fclose(fp);	
	}
	
	print(head);
	clear(head);
	for (i=0; i<MAX_FILE_NUMBER; i++) 
	  free(path[i]);
	
	return 0;
}





工行贵金属TD计算器 能快速计算TD盈亏,用法简单,不会因为自己计算错误而造成损失 立即下载

相关推荐

国央企创新负责人如何通过平台实现科研成果的快速识别与转化?.docx

科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。

利用python爬虫获取黄金价格

继续练手,根据之前获取汽油价格的方式获取了金价,暂时没钱投资,看看而已 #!/usr/bin/env python # -*- coding: utf-8 -*- """ 获取每天黄金价格 @author: yufei @site: http://www.antuan.com 2017-05-11 """ import re import urllib2,urllib import rand...

一方 7706

PotPlayer自用皮肤

自用 PotPlayer 皮肤,仅微调了字体大小与颜色,是按个人习惯调整,未做适配性调整。

python实时获取和讯网纸黄金价格信息

python实时获取和讯网纸黄金价格信息

等待被风吹过的夏天...... 7108

基于STM32与MPU6050的实时姿态检测系统设计与实现(源码+硬件解析)

本文详细介绍了基于STM32单片机与MPU6050传感器的实时姿态检测系统设计与实现。通过硬件解析、传感器校准、卡尔曼滤波算法和欧拉角计算,实现高精度姿态检测。提供完整源码和调试技巧,适用于无人机、平衡车等嵌入式开发项目,解决噪声干扰和数据漂移等常见问题。

jupi8的博客 494

10分钟快速搭建OpenClaw(基于Windows+飞书)

OpenClaw 是一款功能强大的 AI 智能体工具,能够帮助用户管理邮件、日历等日常事务。本文详细介绍了在 Windows11 系统上安装和配置 OpenClaw 的完整步骤,包括 Node.js 环境搭建、Git 安装、OpenClaw 部署以及飞书机器人创建与对接。通过简单的命令行操作和可视化界面配置,用户可以快速完成 AI 助手部署,实现智能办公自动化。文中还提供了飞书机器人权限设置等关键环节的图文指引,帮助用户轻松完成系统集成。

Hello, New World! 2925

感悟(4)——投资贵金属半年有感

2015年一月开始,因为手上已经积攒了5W,也是因为心中一直对于金钱的渴望,知道把钱放在银行里永远跑不过通货膨胀,所以一直想把这笔钱用于理财,开始先是把所有的钱都放进支付宝,因为在支付宝里我相信风险非常小,特别是我知道蚂蚁金服获得许可后我更是深信危险系数可以忽略,那时5W一天差不多能拿6块,想想相对放在银行里划算多了,心中小乐了一下。     后来经常看工行网银里面的投资理财,突然发现可以购买贵

shenzhen 1431

语义通信理论必看论文:Towards a Theory of Semantic Communication

了解语义通信发展必看的一篇文章

一去不复返的通信er 3926

纸黄金投资五大要素

作者: 杨宏亮 07-27 08:07 来源: 纸黄金网 黄金市场风云变幻,金价走势受供求、政治、经济、技术和心理等诸多因素影响。有时大起大落,风高浪急。有时多空胶着,波澜不兴。那么投资者在金市中如何树立正确的投资理念?如何把握准确的买卖时机呢?如何才能长期稳定的获利呢?我认为应从以下五个方面入手  一、风险控制是第一位的      美国股神巴菲特曾经说过一

gotohbu的专栏 1285

STM32L452与FPGA通信翻车?手把手教你关闭I2C时钟延展避坑(附OVR错误解决方案)

本文深入解析STM32L452与FPGA在I2C通信中因时钟延展功能导致的常见问题,提供关闭I2C时钟延展的详细配置方法(NOSTRETCH模式),并针对可能出现的OVR错误给出Combined模式解决方案。通过实战案例和波形分析,帮助工程师快速排查和解决嵌入式系统中的I2C兼容性问题。

e3f4g5的博客 215

基于YOLO26的实时目标追踪实战:从训练到视频追踪(附完整可视化代码)

核心组合:YOLO26(高精度检测)+ ByteTrack(稳定追踪)是实时目标追踪的最优工业组合,Ultralytics内置集成无需额外开发;训练优化:追踪场景需优先提升检测框精度(增加box损失权重),保证ID稳定性;可视化核心:为每个ID分配唯一颜色、绘制运动轨迹、显示FPS,是落地场景的必备功能;性能调优:轻量化模型+降分辨率+OpenVINO导出,可在边缘设备(如研华工控机)实现实时追踪。这套代码可直接复用到智慧园区、停车场、工业产线等场景,仅需修改park.yaml中的类别和。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 572

我的学习笔记01-从工行网页抓取白银价格

白银价格来源:http://www.icbc.com.cn/ICBCDynamicSite/Charts/GoldTendencyPicture.aspx 工具:jsoup 前期弯路: 来源  1 发现绝大部分白银数据来源来自网站www.kitco.cn,免费提供网站嵌入曲线gif图,一分钟刷新一次,但数据是图片,没有单纯的数值源,无法抓取 2 百度“白银价格”,可以得到数值,但更新慢,

wan_cong 2991

Python教程:一文了解Python的深拷贝与浅拷贝

理解 Python 中的深拷贝(deep copy)和浅拷贝(shallow copy)是非常重要的,特别是在处理嵌套结构的数据时。让我们深入探讨这两个概念,并通过代码示例进行说明。

旦莫的博客 3968

关于struct的初始化

在对struct 类型的使用时,要注意对其进行初始化,特别是其中的指针类型。因为在对已定义的struct的函数调用当中,会出现对它的进行非空判断后释放内存的危险行为。     如下例:#include #include typedef struct _filter_config_t{ char *category;

晴空's Blog 2387

【Leetcode】269.火星词典(Hard)

应用拓扑排序

明朗晨光的专栏 769

华为OD机试双机位C卷-虚拟文件系统(C/C++/Py/Java/Js/Go)

华为OD机试(机考)双机位C卷 【虚拟文件系统】,提供C语言、Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为OD机试真题【虚拟文件系统】。

qq_45776114的博客 477

++a和a++

今天的笔试题. 名扬/* 写出判断ABCD四个表达式的是否正确, 若正确, 写出经过表达式中 a的值(3分) * int a = 4; * (A)a += (a++); (B) a += (++a) ;(C) (a++) += a;(D) (++a) += (a++); * a = ? */#include int main(){ int a = 4, b;

晴空's Blog 1315

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

switch-case 中的分支中变量定义 编译不通过问题

如下的函数代码,程序无法编译通过。#include void test_switch(int val){ switch (val) { case 1: int abc; printf("you input 1/n"); break; case 2: printf("you input

晴空's Blog 1273

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

C/C++编程Trick

1. 数组名和数组名解引用等同.    #include int main() { int a[10]; printf("a= 0x%0X, &a=0x%0X/n", a, &a); // Array nanme a is equal to &a. return 0; } 

晴空's Blog 914

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

C基本库函数实现

#include #include #include #include // memset char *str_copy(char *s, char *t) { assert (s != NULL && t != NULL); char *p =

晴空's Blog 831

qs, jx笔试总结

#include #include #include /* strlen, strcpy, strncpy */#include #define S(a) a*a/* qs, jx笔试总结 */int getsum(int n);int *tfunc(int input);void loopmove(char *pstr, int steps);

晴空's Blog 574

String的Big-Three

#include #include using namespace std;//林锐P72class String {public: String(const char *str = NULL); //普通构造函数 String(const String &other); // 拷贝构造函数 ~String(void); // 析构函数 String&

晴空's Blog 498

C++的继承关系

#include using namespace std;class Base {public: void f(int x) { cout << "Base::f(int) " << x << endl; } void f(float x) { cout << "Base::f(float) " << x << endl; } void h(int x) {

晴空's Blog 467

C++ 虚函数表

C++中的虚函数的作用主要是实现了多态的机制。关于多态,简而言之就是用父类型别的指针指向其子类的实例,然后通过父类的指针调用实际子类的成员函数。虚表指针所指向的一张表(虚函数的地址表),表的项数就为虚函数的个数(非虚函数不入表),子类要为其重写了的虚函数重写自己的虚表,没有重写的就直接指向其父类的地址,从而达到多态的作用,这些都是在编译的时候由编译器自动完成的。 参考来源:

晴空's Blog 448
上一篇: [Linux设备驱动第三版]小记 [4-6章]
下一篇: 如何真正清空Linux终端的已显示Buffer
linuw
博客等级 码龄18年 2粉丝 45原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值