float转int的问题,跪求大神解释?

public class Test {
public static void main(String[] args) {
System.out.println(float2Int(999998));
System.out.println(float2Int(999999));
System.out.println(float2Int(1000000));

}

static int float2Int(float value) {
    value = value * 100;
    return Float.valueOf(value).intValue();
}

}
输出结果:
99999800
99999904
100000000
问题来了,为毛999999输出的结果为99999904????

5个回答

浮点数计算存在误差,主要有两个误差,一个是浮点本身的精度误差,特别是float,它的精度是有限的。还有一个是二进制和十进制转换的误差。

Float.valueOf(VALUE)是把Float字符串转换成float的封装类Float
float的尾数位是23bit,对应7~8位十进制数,所以有效数字有的编译器是7位,也有的是8位也即一个整数转换为float的话,会表示成科学计数法,由小数(精度)和指数构成,对0,1四舍五入。

float:2^23 = 8388608,一共七位,这意味着最多能有7位有效数字,但绝对能保证的为6位,也即float的精度为6~7位有效数字;
你的位数太大了,就会丢失精确度,你用99999结果就是对的

精度有损失。你看看这个方法的源码

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
跪求大神帮帮忙,都好说。。。
实验目的: 1. 掌握常用控件的属性、方法、事件 2. 掌握窗体的常用属性、方法和事件 3. 掌握Windows应用程序人机界面可视化设计方法 4. 掌握事件驱动模型的思想 5. 巩固C#语言中类的定义、继承、流程控制语句等基础知识 实验步骤: (1) 在.Net环境中建立Windows窗体应用程序; (2) 定义枚举类型 Public enum SexType {男, 女, 未知}; Public enum ProTitle (助教,讲师,副教授、教授、未知) Public enum StuTitle {班长,副班长,学委,学员} (3) 定义下面类  Person类(抽象类) 包含的字段:姓名Name(字符串型)、身高Height(单精度型,单位:米)、体重Weight(单精度,单位:kg)、性别Sex(枚举类型SexType) 包含的属性:身份证号ID(字符串型,长度固定为18,且不包含空格字符)、年龄Age(只读方法) 包含的方法: Public abstract void Saying(); //该方法为抽象方法 构造函数(带参数和不带参数的各定义一个): Public Person(){}; //在该构造函数对字段进行初始化,按默认值进行初始化,其中身份证号码初始化为“999999999999999999” Public person(string name, string id, float height, float weight, SexType sex) {}; //添加代码,利用实例化时传递的参数对类中的字段进行初始化 Public abstract void Write(FileStream fs); //功能:将数据保存到文件中 Public abstract void Read(FileStream fs); //功能:从文件中读取数据  Teacher类,该类从Person类继承 包含的字段:职称Title(ProTitle枚举类型)、课程Courses(集合类型,集合元素类型为字符串,访问控制符为private) 包含的属性:CourseNumber (数据类型:int,只读属性,含义:课程的数量) 包含的方法: Public string CourseAdd(string coursename) //增加一门课程,同一门课程不能重复添加 Public string CourseDelete(string coursename); //删除一门课程,当要删除的课程不存在时,应给出提示 对父类中的抽象函数Saying()进行重写;//在控制台上输出:“我正在讲课,不方便接电话” 对Object类中的虚函数ToString()进行重写;//将有关教师的所有信息整合成一个字符串,并返回。该虚函数在Object中的定义如下: Public virtual string ToString() 对父类的中Read()、Write()方法进行重写。(方法中的代码可暂时不写)  定义结构体 Public struct coursescore { String coursename; //课程的名称 Float score; //课程的成绩 }  定义学生类Student,从Person类派生 包含的字段:学号StuID(字符串类型,长度固定,以实际学号的长度为准)、课程成绩CourseScore(集合类型,集合中的元素类型为结构体coursescore,访问修饰符采用private)、学生身份title(类型为枚举类型StuTitle) 包含的属性: 课程门数CourseNumber,定义为只读属性,表示学生所选的课程门数 包含的方法: Public void CourseAdd(string coursename, float score); Public void CourseAdd(coursescore course); 上述2个方法为重载,功能是实现增加一门课程及该课程的成绩 对父类的中的Saying()进行重写,要求输出“我正在上课,不方便接电话” 对父类的中的Read、Write方法进行重写(方法体中可暂时不写代码) 增加如下方法: //功能:获取学生的所有课程的最高分、最低分和平均分 Public void GetScore(ref double HighScore, ref double LowScore, ref double AverageScore) 参数的含义: HighScore:所有课程中的最高分 LowScore:所有课程中的最低分 AverageScore:所有课程的平均分 对Object类中的虚函数ToString()进行重写,要求该方法将学生的所有信息整合为一个字符串,并返回  Document类 字段: Private List<string> CourseList; //存储课程列表 Private List<Person> PersonList; //存储学生和教师信息的列表 方法: Public Document(); //构造函数 Public void AddCourse(string CourseName) ;//增加课程 Pulic void DeleteCourse(string CourseName); //删除课程 Public void AddPerson(person personobj); //增加学生或教师 Public void DeletePerson(person persin); //删除学生或教师对象 Public void DeletePerson(string ID); //按照身份证号码删除教师或学生 Public person FindPerson(string ID); //按照身份证号码查找教师或学生对象 Public void SaveData(FileStream fs); //将数据保存到文件中 Public void ReadData(FileStream fs); //从文件中读取数据 属性: Public int TeacherNumber; Public int StudentNumber; 事件: Public event NumberChangingEventHandler onPersonNumberChanging;  委托 Public delegate void NumberChangingEventHandler(object sender, EventNumberArgs e);  EventNumberArgs类(用户传递事件参数) 字段: Public int teacherNumber; Public int studentNumber;
Tensorflow用自己的图片做数据集做识别,无法feed数据,跪求大神帮助!
使用tensorflow识别我自己的tfrecord文件时,在训练时无法feed数据,错误是placeholder那里,下面给出错误和我的代码,跪求大神帮助!!! 错误: ``` Traceback (most recent call last): File "/Users/hanjiarong/PycharmProjects/sample5/main.py", line 206, in <module> session.run(opti, feed_dict={x: session.run(batch_image), y: session.run(batch_label), keep_drop: dropout}) File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 905, in run run_metadata_ptr) File "/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1113, in _run str(subfeed_t.get_shape()))) ValueError: Cannot feed value of shape (1, 227, 227, 3) for Tensor 'Placeholder:0', which has shape '(154587, ?)' ``` 下面是我的代码: ``` import tensorflow as tf from encode_to_tfrecords import create_record, create_test_record, read_and_decode, get_batch, get_test_batch n_input = 154587 n_classes = 3 dropout = 0.5 x = tf.placeholder(tf.float32, [None, n_input]) y = tf.placeholder(tf.int32, [None, n_classes]) keep_drop = tf.placeholder(tf.float32) class network(object): def inference(self, images,keep_drop): #################################################################################################################### # 向量转为矩阵 # images = tf.reshape(images, shape=[-1, 39,39, 3]) images = tf.reshape(images, shape=[-1, 227, 227, 3]) # [batch, in_height, in_width, in_channels] images = (tf.cast(images, tf.float32) / 255. - 0.5) * 2 # 归一化处理 #################################################################################################################### # 第一层 定义卷积偏置和下采样 conv1 = tf.nn.bias_add(tf.nn.conv2d(images, self.weights['conv1'], strides=[1, 4, 4, 1], padding='VALID'), self.biases['conv1']) relu1 = tf.nn.relu(conv1) pool1 = tf.nn.max_pool(relu1, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID') # 第二层 conv2 = tf.nn.bias_add(tf.nn.conv2d(pool1, self.weights['conv2'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv2']) relu2 = tf.nn.relu(conv2) pool2 = tf.nn.max_pool(relu2, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID') # 第三层 conv3 = tf.nn.bias_add(tf.nn.conv2d(pool2, self.weights['conv3'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv3']) relu3 = tf.nn.relu(conv3) # pool3=tf.nn.max_pool(relu3, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='VALID') conv4 = tf.nn.bias_add(tf.nn.conv2d(relu3, self.weights['conv4'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv4']) relu4 = tf.nn.relu(conv4) conv5 = tf.nn.bias_add(tf.nn.conv2d(relu4, self.weights['conv5'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv5']) relu5 = tf.nn.relu(conv5) pool5 = tf.nn.max_pool(relu5, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID') # 全连接层1,先把特征图转为向量 flatten = tf.reshape(pool5, [-1, self.weights['fc1'].get_shape().as_list()[0]]) # dropout比率选用0.5 drop1 = tf.nn.dropout(flatten, keep_drop) fc1 = tf.matmul(drop1, self.weights['fc1']) + self.biases['fc1'] fc_relu1 = tf.nn.relu(fc1) fc2 = tf.matmul(fc_relu1, self.weights['fc2']) + self.biases['fc2'] fc_relu2 = tf.nn.relu(fc2) fc3 = tf.matmul(fc_relu2, self.weights['fc3']) + self.biases['fc3'] return fc3 def __init__(self): # 初始化权值和偏置 with tf.variable_scope("weights"): self.weights = { # 39*39*3->36*36*20->18*18*20 'conv1': tf.get_variable('conv1', [11, 11, 3, 96], initializer=tf.contrib.layers.xavier_initializer_conv2d()), # 18*18*20->16*16*40->8*8*40 'conv2': tf.get_variable('conv2', [5, 5, 96, 256], initializer=tf.contrib.layers.xavier_initializer_conv2d()), # 8*8*40->6*6*60->3*3*60 'conv3': tf.get_variable('conv3', [3, 3, 256, 384], initializer=tf.contrib.layers.xavier_initializer_conv2d()), # 3*3*60->120 'conv4': tf.get_variable('conv4', [3, 3, 384, 384], initializer=tf.contrib.layers.xavier_initializer_conv2d()), 'conv5': tf.get_variable('conv5', [3, 3, 384, 256], initializer=tf.contrib.layers.xavier_initializer_conv2d()), 'fc1': tf.get_variable('fc1', [6 * 6 * 256, 4096], initializer=tf.contrib.layers.xavier_initializer()), 'fc2': tf.get_variable('fc2', [4096, 4096], initializer=tf.contrib.layers.xavier_initializer()), 'fc3': tf.get_variable('fc3', [4096, 1000], initializer=tf.contrib.layers.xavier_initializer()), } with tf.variable_scope("biases"): self.biases = { 'conv1': tf.get_variable('conv1', [96, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv2': tf.get_variable('conv2', [256, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv3': tf.get_variable('conv3', [384, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv4': tf.get_variable('conv4', [384, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv5': tf.get_variable('conv5', [256, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'fc1': tf.get_variable('fc1', [4096, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'fc2': tf.get_variable('fc2', [4096, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'fc3': tf.get_variable('fc3', [1000, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)) } # 计算softmax交叉熵损失函数 def sorfmax_loss(self, predicts, labels): predicts = tf.nn.softmax(predicts) labels = tf.one_hot(labels, self.weights['fc3'].get_shape().as_list()[1]) loss = tf.nn.softmax_cross_entropy_with_logits(logits=predicts, labels=labels) # loss =-tf.reduce_mean(labels * tf.log(predicts))# tf.nn.softmax_cross_entropy_with_logits(predicts, labels) self.cost = loss return self.cost # 梯度下降 def optimer(self, loss, lr=0.01): train_optimizer = tf.train.GradientDescentOptimizer(lr).minimize(loss) return train_optimizer #定义训练 # def train(self): create_record('/Users/hanjiarong/Documents/testdata/tfrtrain') # image, label = read_and_decode('train.tfrecords') # batch_image, batch_label = get_batch(image, label, 30) #连接网络 网络训练 net = network() inf = net.inference(x, dropout) loss = net.sorfmax_loss(inf,y) opti = net.optimer(loss) correct_pred = tf.equal(tf.argmax(inf, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32)) # #定义测试 create_test_record('/Users/hanjiarong/Documents/testdata/tfrtest') # image_t, label_t = read_and_decode('test.tfrecords') # batch_test_image, batch_test_label = get_test_batch(image_t, label_t, 50) # # #生成测试 image, label = read_and_decode('train.tfrecords') batch_image, batch_label = get_batch(image, label, 1) # val, l = session.run([batch_image, batch_label]) # print(val.shape, l) with tf.Session() as session: init = tf.initialize_all_variables() session.run(init) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord) max_iter = 100000 iter = 1 print("begin1") while iter * 30 < max_iter: # loss_np, _, label_np, image_np, inf_np = session.run([loss, opti, batch_label, batch_image, inf]) session.run(opti, feed_dict={x: session.run(batch_image), y: session.run(batch_label), keep_drop: dropout}) print("begin6") if iter % 10 == 0: loss, acc = session.run([loss, accuracy], feed_dict={x: batch_image, y: batch_label, keep_drop: 1.}) print("Iter " + str(iter * 30) + ", Minibatch Loss= " + \ "{:.6f}".format(loss) + ", Training Accuracy= " + "{:.5f}".format(acc)) iter += 1 print("Optimization Finished!") image, label = read_and_decode('test.tfrecords') batch_test_image, batch_test_label = get_batch(image, label, 2) img_test, lab_test = session.run([batch_test_image, batch_test_label]) test_accuracy = session.run(accuracy, feed_dict={x: img_test, y: lab_test, keep_drop: 1.}) print("Testing Accuracy:", test_accuracy) ```
MinGw编译GMP库时出错,跪求大神解答
![出错截图](https://img-ask.csdn.net/upload/201512/11/1449818918_325729.jpg) Config.log如下: This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by GNU MP configure 6.1.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ ./configure CPPGLAGS=-D_USE_MINGW_ANSI_STDIO=0--enable-static --disable-shared ## --------- ## ## Platform. ## ## --------- ## hostname = Mr-Chen uname -m = i686 uname -r = 1.0.17(0.48/3/2) uname -s = MINGW32_NT-6.1 uname -v = 2011-04-24 23:39 /usr/bin/ uname -p = unknown /bin/ uname -X = unknown /bin/arch = unknown /usr/bin/arch -k = unknown /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = unknown /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown PATH: . PATH: /usr/local/bin PATH: /mingw/bin PATH: /bin PATH: /d/ActivePerl/site/bin PATH: /d/ActivePerl/bin PATH: /c/Program Files (x86)/NVIDIA Corporation/PhysX/Common PATH: /c/Windows/system32 PATH: /c/Windows PATH: /c/Windows/System32/Wbem PATH: /c/Windows/System32/WindowsPowerShell/v1.0/ PATH: %QUARTUS_ROOTDIR%/bin PATH: /c/Program Files (x86)/Common Files/Ulead Systems/MPEG PATH: /c/Program Files (x86)/Microsoft SQL Server/80/Tools/Binn/ PATH: /d/Latex/CTEX/UserData/miktex/bin PATH: /d/Latex/CTEX/MiKTeX/miktex/bin PATH: /d/Latex/CTEX/CTeX/ctex/bin PATH: /d/Latex/CTEX/CTeX/cct/bin PATH: /d/Latex/CTEX/CTeX/ty/bin PATH: /d/Latex/CTEX/Ghostscript/gs9.05/bin PATH: /d/Latex/CTEX/GSview/gsview PATH: /d/Latex/CTEX/WinEdt PATH: /c/Program Files/Microsoft SQL Server/110/Tools/Binn/ PATH: /c/MinGW/bin/ PATH: /d/ActivePerl/site/bin/ PATH: /d/ActivePerl/bin/ PATH: /c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn/ PATH: /c/Program Files/Microsoft SQL Server/100/Tools/Binn/ PATH: /c/Program Files/Microsoft SQL Server/100/DTS/Binn/ PATH: /d/VS2010/VC/bin/ PATH: /d/MinGw/bin ## ----------- ## ## Core tests. ## ## ----------- ## configure:3055: checking build system type configure:3069: result: sandybridge-pc-mingw32 configure:3089: checking host system type configure:3102: result: sandybridge-pc-mingw32 configure:3139: checking for a BSD-compatible install configure:3207: result: /bin/install -c configure:3218: checking whether build environment is sane configure:3273: result: yes configure:3424: checking for a thread-safe mkdir -p configure:3463: result: /bin/mkdir -p configure:3470: checking for gawk configure:3486: found /bin/gawk configure:3497: result: gawk configure:3508: checking whether make sets $(MAKE) configure:3530: result: yes configure:3559: checking whether make supports nested variables configure:3576: result: yes configure:3705: checking whether to enable maintainer-specific portions of Makefiles configure:3714: result: no User: ABI= CC= CFLAGS=(unset) CPPFLAGS=(unset) MPN_PATH= GMP: abilist=64 x32 32 cclist=gcc icc cc configure:5749: gcc 2>&1 | grep xlc >/dev/null configure:5752: $? = 1 configure:5806: checking compiler gcc -O2 -pedantic -fomit-frame-pointer -m64 Test compile: configure:5820: gcc -O2 -pedantic -fomit-frame-pointer -m64 conftest.c >&5 conftest.c:1:0: sorry, unimplemented: 64-bit mode not compiled in configure:5823: $? = 1 failed program was: int main () { return 0; } configure:6909: result: no configure:5727: cc -c conftest.c >&5 configure:5730: $? = 0 configure:5733: checking whether cc is gcc configure:5735: result: yes configure:5749: cc 2>&1 | grep xlc >/dev/null configure:5752: $? = 1 configure:5806: checking compiler cc -O2 -pedantic -fomit-frame-pointer -m64 Test compile: configure:5820: cc -O2 -pedantic -fomit-frame-pointer -m64 conftest.c >&5 conftest.c:1:0: sorry, unimplemented: 64-bit mode not compiled in configure:5823: $? = 1 failed program was: int main () { return 0; } configure:6909: result: no configure:5749: gcc 2>&1 | grep xlc >/dev/null configure:5752: $? = 1 configure:5806: checking compiler gcc -O2 -pedantic -fomit-frame-pointer -mx32 Test compile: configure:5820: gcc -O2 -pedantic -fomit-frame-pointer -mx32 conftest.c >&5 cc1.exe: error: unrecognized command line option '-mx32' configure:5823: $? = 1 failed program was: int main () { return 0; } configure:6909: result: no configure:5727: cc -c conftest.c >&5 configure:5730: $? = 0 configure:5733: checking whether cc is gcc configure:5735: result: yes configure:5749: cc 2>&1 | grep xlc >/dev/null configure:5752: $? = 1 configure:5806: checking compiler cc -O2 -pedantic -fomit-frame-pointer -mx32 Test compile: configure:5820: cc -O2 -pedantic -fomit-frame-pointer -mx32 conftest.c >&5 cc1.exe: error: unrecognized command line option '-mx32' configure:5823: $? = 1 failed program was: int main () { return 0; } configure:6909: result: no configure:5749: gcc 2>&1 | grep xlc >/dev/null configure:5752: $? = 1 configure:5806: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer Test compile: configure:5820: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:5823: $? = 0 configure:5828: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 5829: ./a.out: No such file or directory ./configure: line 5829: ./b.out: No such file or directory configure:5831: $? = 0 Test compile: function pointer return configure:5874: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:5877: $? = 0 configure:5882: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 5883: ./a.out: No such file or directory ./configure: line 5883: ./b.out: No such file or directory configure:5885: $? = 0 Test compile: cmov instruction configure:5930: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:5933: $? = 0 configure:5938: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 5939: ./a.out: No such file or directory ./configure: line 5939: ./b.out: No such file or directory configure:5941: $? = 0 Test compile: double -> ulong conversion configure:5987: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:5990: $? = 0 configure:5995: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 5996: ./a.out: No such file or directory ./configure: line 5996: ./b.out: No such file or directory configure:5998: $? = 0 Test compile: double negation configure:6042: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6045: $? = 0 configure:6050: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6051: ./a.out: No such file or directory ./configure: line 6051: ./b.out: No such file or directory configure:6053: $? = 0 Test compile: double -> float conversion configure:6098: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6101: $? = 0 configure:6106: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6107: ./a.out: No such file or directory ./configure: line 6107: ./b.out: No such file or directory configure:6109: $? = 0 Test compile: gnupro alpha ev6 char spilling configure:6183: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6186: $? = 0 configure:6191: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6192: ./a.out: No such file or directory ./configure: line 6192: ./b.out: No such file or directory configure:6194: $? = 0 Test compile: __builtin_alloca availability configure:6234: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o): In function `main': C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain@16' collect2: ld returned 1 exit status configure:6237: $? = 1 failed program was: int k; int foo () { __builtin_alloca (k); } Test compile: abs int -> double conversion configure:6358: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6361: $? = 0 configure:6366: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6367: ./a.out: No such file or directory ./configure: line 6367: ./b.out: No such file or directory configure:6369: $? = 0 Test compile: long long reliability test 1 configure:6423: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 conftest.c:6:23: warning: ISO C90 does not support 'long long' [-Wlong-long] configure:6426: $? = 0 configure:6431: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6432: ./a.out: No such file or directory ./configure: line 6432: ./b.out: No such file or directory configure:6434: $? = 0 Test compile: long long reliability test 2 configure:6484: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 conftest.c: In function 'f': conftest.c:7:26: warning: ISO C90 does not support 'long long' [-Wlong-long] configure:6487: $? = 0 configure:6492: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6493: ./a.out: No such file or directory ./configure: line 6493: ./b.out: No such file or directory configure:6495: $? = 0 Test compile: freebsd hacked gcc configure:6545: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6548: $? = 0 configure:6553: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6554: ./a.out: No such file or directory ./configure: line 6554: ./b.out: No such file or directory configure:6556: $? = 0 Test compile: mpn_lshift_com optimization configure:6644: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6647: $? = 0 configure:6652: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6653: ./a.out: No such file or directory ./configure: line 6653: ./b.out: No such file or directory configure:6655: $? = 0 Test compile: mpn_lshift_com optimization 2 configure:6752: gcc -m32 -O2 -pedantic -fomit-frame-pointer conftest.c >&5 configure:6755: $? = 0 configure:6760: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 6761: ./a.out: No such file or directory ./configure: line 6761: ./b.out: No such file or directory configure:6763: $? = 0 configure:6909: result: yes configure: testlist sizeof-long-4 configure:7084: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer has sizeof(long)==4 configure:7097: gcc -m32 -O2 -pedantic -fomit-frame-pointer -c conftest.c >&5 configure:7100: $? = 0 configure:7105: result: yes configure:7423: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=sandybridge Test compile: configure:7437: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=sandybridge conftest.c >&5 conftest.c:1:0: error: bad value (sandybridge) for -mtune= switch configure:7440: $? = 1 failed program was: int main () { return 0; } configure:8526: result: no configure:7423: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 Test compile: configure:7437: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7440: $? = 0 configure:7445: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7446: ./a.out: No such file or directory ./configure: line 7446: ./b.out: No such file or directory configure:7448: $? = 0 Test compile: function pointer return configure:7491: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7494: $? = 0 configure:7499: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7500: ./a.out: No such file or directory ./configure: line 7500: ./b.out: No such file or directory configure:7502: $? = 0 Test compile: cmov instruction configure:7547: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7550: $? = 0 configure:7555: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7556: ./a.out: No such file or directory ./configure: line 7556: ./b.out: No such file or directory configure:7558: $? = 0 Test compile: double -> ulong conversion configure:7604: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7607: $? = 0 configure:7612: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7613: ./a.out: No such file or directory ./configure: line 7613: ./b.out: No such file or directory configure:7615: $? = 0 Test compile: double negation configure:7659: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7662: $? = 0 configure:7667: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7668: ./a.out: No such file or directory ./configure: line 7668: ./b.out: No such file or directory configure:7670: $? = 0 Test compile: double -> float conversion configure:7715: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7718: $? = 0 configure:7723: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7724: ./a.out: No such file or directory ./configure: line 7724: ./b.out: No such file or directory configure:7726: $? = 0 Test compile: gnupro alpha ev6 char spilling configure:7800: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7803: $? = 0 configure:7808: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7809: ./a.out: No such file or directory ./configure: line 7809: ./b.out: No such file or directory configure:7811: $? = 0 Test compile: __builtin_alloca availability configure:7851: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o): In function `main': C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain@16' collect2: ld returned 1 exit status configure:7854: $? = 1 failed program was: int k; int foo () { __builtin_alloca (k); } Test compile: abs int -> double conversion configure:7975: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:7978: $? = 0 configure:7983: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7984: ./a.out: No such file or directory ./configure: line 7984: ./b.out: No such file or directory configure:7986: $? = 0 Test compile: long long reliability test 1 configure:8040: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 conftest.c:6:23: warning: ISO C90 does not support 'long long' [-Wlong-long] configure:8043: $? = 0 configure:8048: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8049: ./a.out: No such file or directory ./configure: line 8049: ./b.out: No such file or directory configure:8051: $? = 0 Test compile: long long reliability test 2 configure:8101: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 conftest.c: In function 'f': conftest.c:7:26: warning: ISO C90 does not support 'long long' [-Wlong-long] configure:8104: $? = 0 configure:8109: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8110: ./a.out: No such file or directory ./configure: line 8110: ./b.out: No such file or directory configure:8112: $? = 0 Test compile: freebsd hacked gcc configure:8162: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:8165: $? = 0 configure:8170: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8171: ./a.out: No such file or directory ./configure: line 8171: ./b.out: No such file or directory configure:8173: $? = 0 Test compile: mpn_lshift_com optimization configure:8261: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:8264: $? = 0 configure:8269: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8270: ./a.out: No such file or directory ./configure: line 8270: ./b.out: No such file or directory configure:8272: $? = 0 Test compile: mpn_lshift_com optimization 2 configure:8369: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 conftest.c >&5 configure:8372: $? = 0 configure:8377: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8378: ./a.out: No such file or directory ./configure: line 8378: ./b.out: No such file or directory configure:8380: $? = 0 configure:8526: result: yes configure:7423: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=sandybridge Test compile: configure:7437: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=sandybridge conftest.c >&5 conftest.c:1:0: error: bad value (sandybridge) for -march= switch configure:7440: $? = 1 failed program was: int main () { return 0; } configure:8526: result: no configure:7423: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 Test compile: configure:7437: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7440: $? = 0 configure:7445: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7446: ./a.out: No such file or directory ./configure: line 7446: ./b.out: No such file or directory configure:7448: $? = 0 Test compile: function pointer return configure:7491: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7494: $? = 0 configure:7499: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7500: ./a.out: No such file or directory ./configure: line 7500: ./b.out: No such file or directory configure:7502: $? = 0 Test compile: cmov instruction configure:7547: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7550: $? = 0 configure:7555: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7556: ./a.out: No such file or directory ./configure: line 7556: ./b.out: No such file or directory configure:7558: $? = 0 Test compile: double -> ulong conversion configure:7604: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7607: $? = 0 configure:7612: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7613: ./a.out: No such file or directory ./configure: line 7613: ./b.out: No such file or directory configure:7615: $? = 0 Test compile: double negation configure:7659: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7662: $? = 0 configure:7667: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7668: ./a.out: No such file or directory ./configure: line 7668: ./b.out: No such file or directory configure:7670: $? = 0 Test compile: double -> float conversion configure:7715: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7718: $? = 0 configure:7723: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7724: ./a.out: No such file or directory ./configure: line 7724: ./b.out: No such file or directory configure:7726: $? = 0 Test compile: gnupro alpha ev6 char spilling configure:7800: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7803: $? = 0 configure:7808: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7809: ./a.out: No such file or directory ./configure: line 7809: ./b.out: No such file or directory configure:7811: $? = 0 Test compile: __builtin_alloca availability configure:7851: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a(main.o): In function `main': C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to `WinMain@16' collect2: ld returned 1 exit status configure:7854: $? = 1 failed program was: int k; int foo () { __builtin_alloca (k); } Test compile: abs int -> double conversion configure:7975: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:7978: $? = 0 configure:7983: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 7984: ./a.out: No such file or directory ./configure: line 7984: ./b.out: No such file or directory configure:7986: $? = 0 Test compile: long long reliability test 1 configure:8040: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 conftest.c:6:23: warning: ISO C90 does not support 'long long' [-Wlong-long] configure:8043: $? = 0 configure:8048: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8049: ./a.out: No such file or directory ./configure: line 8049: ./b.out: No such file or directory configure:8051: $? = 0 Test compile: long long reliability test 2 configure:8101: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 conftest.c: In function 'f': conftest.c:7:26: warning: ISO C90 does not support 'long long' [-Wlong-long] configure:8104: $? = 0 configure:8109: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8110: ./a.out: No such file or directory ./configure: line 8110: ./b.out: No such file or directory configure:8112: $? = 0 Test compile: freebsd hacked gcc configure:8162: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:8165: $? = 0 configure:8170: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8171: ./a.out: No such file or directory ./configure: line 8171: ./b.out: No such file or directory configure:8173: $? = 0 Test compile: mpn_lshift_com optimization configure:8261: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:8264: $? = 0 configure:8269: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8270: ./a.out: No such file or directory ./configure: line 8270: ./b.out: No such file or directory configure:8272: $? = 0 Test compile: mpn_lshift_com optimization 2 configure:8369: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 conftest.c >&5 configure:8372: $? = 0 configure:8377: ./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest ./configure: line 8378: ./a.out: No such file or directory ./configure: line 8378: ./b.out: No such file or directory configure:8380: $? = 0 configure:8526: result: yes configure:7423: checking compiler gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 -mno-cygwin Test compile: configure:7437: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 -mno-cygwin conftest.c >&5 cc1.exe: error: unrecognized command line option '-mno-cygwin' configure:7440: $? = 1 failed program was: int main () { return 0; } configure:8526: result: no configure:8679: checking for gcc configure:8706: result: gcc configure:8935: checking for C compiler version configure:8944: gcc --version >&5 gcc.exe (GCC) 4.6.2 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. configure:8955: $? = 0 configure:8944: gcc -v >&5 Using built-in specs. COLLECT_GCC=c:\MinGW\bin\gcc.exe COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/lto-wrapper.exe Target: mingw32 Configured with: ../gcc-4.6.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw Thread model: win32 gcc version 4.6.2 (GCC) configure:8955: $? = 0 configure:8944: gcc -V >&5 gcc.exe: error: unrecognized option '-V' gcc.exe: fatal error: no input files compilation terminated. configure:8955: $? = 1 configure:8944: gcc -qversion >&5 gcc.exe: error: unrecognized option '-qversion' gcc.exe: fatal error: no input files compilation terminated. configure:8955: $? = 1 configure:8975: checking whether the C compiler works configure:8997: gcc -m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7 D:\gmp-6.1.0 conftest.c >&5 c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find D:\gmp-6.1.0: Permission denied collect2: ld returned 1 exit status configure:9001: $? = 1 configure:9039: result: no configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "GNU MP" | #define PACKAGE_TARNAME "gmp" | #define PACKAGE_VERSION "6.1.0" | #define PACKAGE_STRING "GNU MP 6.1.0" | #define PACKAGE_BUGREPORT "gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html" | #define PACKAGE_URL "http://www.gnu.org/software/gmp/" | #define PACKAGE "gmp" | #define VERSION "6.1.0" | #define WANT_ASSEMBLY 1 | #define WANT_FFT 1 | #define HAVE_HOST_CPU_sandybridge 1 | #define HOST_DOS64 1 | #define HAVE_SPEED_CYCLECOUNTER 2 | #define HAVE_CALLING_CONVENTIONS 1 | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:9044: error: in `/d/gmp-6.1.0': configure:9046: error: C compiler cannot create executables See `config.log' for more details ## ---------------- ## ## Cache variables. ## ## ---------------- ## ac_cv_build=sandybridge-pc-mingw32 ac_cv_env_ABI_set= ac_cv_env_ABI_value= ac_cv_env_CCC_set= ac_cv_env_CCC_value= ac_cv_env_CC_FOR_BUILD_set= ac_cv_env_CC_FOR_BUILD_value= ac_cv_env_CC_set= ac_cv_env_CC_value= ac_cv_env_CFLAGS_set= ac_cv_env_CFLAGS_value= ac_cv_env_CPPFLAGS_set= ac_cv_env_CPPFLAGS_value= ac_cv_env_CPP_FOR_BUILD_set= ac_cv_env_CPP_FOR_BUILD_value= ac_cv_env_CPP_set= ac_cv_env_CPP_value= ac_cv_env_CXXCPP_set= ac_cv_env_CXXCPP_value= ac_cv_env_CXXFLAGS_set= ac_cv_env_CXXFLAGS_value= ac_cv_env_CXX_set= ac_cv_env_CXX_value= ac_cv_env_LDFLAGS_set=set ac_cv_env_LDFLAGS_value='D:\gmp-6.1.0' ac_cv_env_LIBS_set= ac_cv_env_LIBS_value= ac_cv_env_LT_SYS_LIBRARY_PATH_set= ac_cv_env_LT_SYS_LIBRARY_PATH_value= ac_cv_env_M4_set= ac_cv_env_M4_value= ac_cv_env_YACC_set= ac_cv_env_YACC_value= ac_cv_env_YFLAGS_set= ac_cv_env_YFLAGS_value= ac_cv_env_build_alias_set= ac_cv_env_build_alias_value= ac_cv_env_host_alias_set= ac_cv_env_host_alias_value= ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_host=sandybridge-pc-mingw32 ac_cv_path_install='/bin/install -c' ac_cv_path_mkdir=/bin/mkdir ac_cv_prog_AWK=gawk ac_cv_prog_ac_ct_CC=gcc ac_cv_prog_make_make_set=yes am_cv_make_support_nested_variables=yes ## ----------------- ## ## Output variables. ## ## ----------------- ## ABI='32' ACLOCAL='${SHELL} /d/gmp-6.1.0/missing aclocal-1.15' AMTAR='$${TAR-tar}' AM_BACKSLASH='\' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' AM_DEFAULT_VERBOSITY='1' AM_V='$(V)' AR='' AS='' ASMFLAGS='' AUTOCONF='${SHELL} /d/gmp-6.1.0/missing autoconf' AUTOHEADER='${SHELL} /d/gmp-6.1.0/missing autoheader' AUTOMAKE='${SHELL} /d/gmp-6.1.0/missing automake-1.15' AWK='gawk' CALLING_CONVENTIONS_OBJS='x86call.lo x86check$U.lo' CC='gcc' CCAS='' CC_FOR_BUILD='' CFLAGS='-m32 -O2 -pedantic -fomit-frame-pointer -mtune=corei7 -march=corei7' CPP='' CPPFLAGS='' CPP_FOR_BUILD='' CXX='' CXXCPP='' CXXFLAGS='' CYGPATH_W='echo' DEFN_LONG_LONG_LIMB='/* #undef _LONG_LONG_LIMB */' DEFS='' DLLTOOL='' DSYMUTIL='' DUMPBIN='' ECHO_C='' ECHO_N='-n' ECHO_T='' EGREP='' ENABLE_STATIC_FALSE='' ENABLE_STATIC_TRUE='' EXEEXT='' EXEEXT_FOR_BUILD='' FGREP='' GMP_LDFLAGS='' GMP_LIMB_BITS='' GMP_NAIL_BITS='0' GREP='' HAVE_CLOCK_01='' HAVE_CPUTIME_01='' HAVE_GETRUSAGE_01='' HAVE_GETTIMEOFDAY_01='' HAVE_HOST_CPU_FAMILY_power='0' HAVE_HOST_CPU_FAMILY_powerpc='0' HAVE_SIGACTION_01='' HAVE_SIGALTSTACK_01='' HAVE_SIGSTACK_01='' HAVE_STACK_T_01='' HAVE_SYS_RESOURCE_H_01='' INSTALL_DATA='${INSTALL} -m 644' INSTALL_PROGRAM='${INSTALL}' INSTALL_SCRIPT='${INSTALL}' INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' LD='' LDFLAGS='D:\gmp-6.1.0' LEX='' LEXLIB='' LEX_OUTPUT_ROOT='' LIBCURSES='' LIBGMPXX_LDFLAGS='' LIBGMP_DLL='' LIBGMP_LDFLAGS='' LIBM='' LIBM_FOR_BUILD='' LIBOBJS='' LIBREADLINE='' LIBS='' LIBTOOL='' LIPO='' LN_S='' LTLIBOBJS='' LT_SYS_LIBRARY_PATH='' M4='' MAINT='#' MAINTAINER_MODE_FALSE='' MAINTAINER_MODE_TRUE='#' MAKEINFO='${SHELL} /d/gmp-6.1.0/missing makeinfo' MANIFEST_TOOL='' MKDIR_P='/bin/mkdir -p' NM='' NMEDIT='' OBJDUMP='' OBJEXT='' OTOOL64='' OTOOL='' PACKAGE='gmp' PACKAGE_BUGREPORT='gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html' PACKAGE_NAME='GNU MP' PACKAGE_STRING='GNU MP 6.1.0' PACKAGE_TARNAME='gmp' PACKAGE_URL='http://www.gnu.org/software/gmp/' PACKAGE_VERSION='6.1.0' PATH_SEPARATOR=':' RANLIB='' SED='' SET_MAKE='' SHELL='/bin/sh' SPEED_CYCLECOUNTER_OBJ='pentium.lo' STRIP='' TAL_OBJECT='' TUNE_LIBS='' TUNE_SQR_OBJ='' U_FOR_BUILD='' VERSION='6.1.0' WANT_CXX_FALSE='' WANT_CXX_TRUE='' WITH_READLINE_01='' YACC='' YFLAGS='' ac_ct_AR='' ac_ct_CC='gcc' ac_ct_CXX='' ac_ct_DUMPBIN='' am__EXEEXT_FALSE='' am__EXEEXT_TRUE='' am__isrc='' am__leading_dot='.' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' bindir='${exec_prefix}/bin' build='sandybridge-pc-mingw32' build_alias='' build_cpu='sandybridge' build_os='mingw32' build_vendor='pc' datadir='${datarootdir}' datarootdir='${prefix}/share' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' dvidir='${docdir}' exec_prefix='NONE' gmp_srclinks='' host='sandybridge-pc-mingw32' host_alias='' host_cpu='sandybridge' host_os='mingw32' host_vendor='pc' htmldir='${docdir}' includedir='${prefix}/include' infodir='${datarootdir}/info' install_sh='${SHELL} /d/gmp-6.1.0/install-sh' libdir='${exec_prefix}/lib' libexecdir='${exec_prefix}/libexec' localedir='${datarootdir}/locale' localstatedir='${prefix}/var' mandir='${datarootdir}/man' mkdir_p='$(MKDIR_P)' mpn_objects='' mpn_objs_in_libgmp='' oldincludedir='/usr/include' pdfdir='${docdir}' prefix='NONE' program_transform_name='s,x,x,' psdir='${docdir}' sbindir='${exec_prefix}/sbin' sharedstatedir='${prefix}/com' sysconfdir='${prefix}/etc' target_alias='' ## ----------- ## ## confdefs.h. ## ## ----------- ## /* confdefs.h */ #define PACKAGE_NAME "GNU MP" #define PACKAGE_TARNAME "gmp" #define PACKAGE_VERSION "6.1.0" #define PACKAGE_STRING "GNU MP 6.1.0" #define PACKAGE_BUGREPORT "gmp-bugs@gmplib.org, see https://gmplib.org/manual/Reporting-Bugs.html" #define PACKAGE_URL "http://www.gnu.org/software/gmp/" #define PACKAGE "gmp" #define VERSION "6.1.0" #define WANT_ASSEMBLY 1 #define WANT_FFT 1 #define HAVE_HOST_CPU_sandybridge 1 #define HOST_DOS64 1 #define HAVE_SPEED_CYCLECOUNTER 2 #define HAVE_CALLING_CONVENTIONS 1 configure: exit 77
基于opencv的人脸描述,用语言来描述输入脸的特征。建了对象,数据显示都是0。跪求大神急急急!!!
我写了一个类Facedescribe,在main函数里建了一个这个类的对象a,运行后得到的数据都是0;如果直接把Eye1_Eye2()和Faceheight( )放在main函数里,得到的输出数据eye1_eye2和faceheight正常。跪求大神建的这个类不对吗,类Facedescribe和main函数如下: class Facedescribe{ private: double eye1_eye2; //两眼瞳孔之间的距离 double facewidth; //脸宽 double faceheight; //脸长 double nosewidth; //鼻子宽度 double mouthwidth; //嘴巴宽度 public: Facedescribe() :eye1_eye2(0), facewidth(0), faceheight(0), nosewidth(0), mouthwidth(0){ } //定位瞳孔,求出两眼瞳孔之间的距离 double Eye1_Eye2() { eye1_eye2 = sqrt(pow(cvRound(landmarks[38 * 2 + 1]) - cvRound(landmarks[39 * 2 + 1]), 2) + pow(cvRound(landmarks[38 * 2]) - cvRound(landmarks[39 * 2]), 2)); cout << "eye1_eye2 = " << eye1_eye2 << endl; return eye1_eye2; } double faceheightb = eye1_eye2 * 8;//脸长与眼宽的黄金比例 double Faceheight( ) { double faceheight = sqrt(pow(cvRound(landmarks[6 * 2 + 1]) - cvRound(landmarks[14 * 2 + 1]), 2) + pow(cvRound(landmarks[6 * 2]) - cvRound(landmarks[14 * 2]), 2)); cout << "faceheight = " << faceheight << endl; return faceheight; } bool Facemodel() { if (faceheight > faceheightb) { cout << "长脸" << endl; return true; } else { cout << "不是长脸" << endl; return false; } } }; int main() { //const char* const path = "../data"; cv::Mat_<unsigned char> img(cv::imread(path, CV_LOAD_IMAGE_GRAYSCALE)); if (!img.data) { printf("Cannot load %s\n", path); exit(1); } int foundface; float landmarks[2 * stasm_NLANDMARKS]; // x,y coords (note the 2) if (!stasm_search_single(&foundface, landmarks, (const char*)img.data, img.cols, img.rows, path, "../data")) { printf("Error in stasm_search_single: %s\n", stasm_lasterr()); exit(1); } if (!foundface) printf("No face found in %s\n", path); else { // draw the landmarks on the image as white dots圆点 (image is monochrom单色的,黑白的) stasm_force_points_into_image(landmarks, img.cols, img.rows); for (int i = 0; i <stasm_NLANDMARKS; i++) img(cvRound(landmarks[i * 2 + 1]), cvRound(landmarks[i * 2])) = 255; } cv::imwrite("minimal.bmp", img); cv::imshow("stasm minimal", img); cv::waitKey(); Facedescribe a; a.Eye1_Eye2(); a.Faceheight(); a.Facemodel(); system("pause"); }
python opencv 图片前景与背景的分割,拜大神求如何改错
在网上找到了一个用Kmeans算法对图片前景与背景的分割的例子,很适合现在的学习,可一直有一个错误不会修改,跪求大神了。 ``` ```# -*- coding: utf-8 -*- import cv2 import numpy as np import math def panelAbstract(srcImage): # read pic shape imgHeight,imgWidth = srcImage.shape[:2] imgHeight = int(imgHeight);imgWidth = int(imgWidth) # 均值聚类提取前景:二维转一维 imgVec = np.float32(srcImage.reshape((-1,3))) criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER,10,1.0) flags = cv2.KMEANS_RANDOM_CENTERS label,clusCenter = cv2.kmeans(imgVec,2,None,criteria,10,flags) clusCenter = np.uint8(clusCenter) clusResult = clusCenter[label.flatten()] imgres = clusResult.reshape((srcImage.shape)) imgres = cv2.cvtColor(imgres,cv2.COLOR_BGR2GRAY) bwThresh = int((np.max(imgres)+np.min(imgres))/2) _,thresh = cv2.threshold(imgres,bwThresh,255,cv2.THRESH_BINARY_INV) threshRotate = cv2.merge([thresh,thresh,thresh]) # 确定前景外接矩形 #find contours contours = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) minvalx = np.max([imgHeight,imgWidth]);maxvalx = 0 minvaly = np.max([imgHeight,imgWidth]);maxvaly = 0 maxconArea = 0;maxAreaPos = -1 for i in range(len(contours)): if maxconArea < cv2.contourArea(contours[i]): maxconArea = cv2.contourArea(contours[i]) maxAreaPos = i objCont = contours[maxAreaPos] # 旋转校正前景 rect = cv2.minAreaRect(objCont) for j in range(len(objCont)): minvaly = np.min([minvaly,objCont[j][0][0]]) maxvaly = np.max([maxvaly,objCont[j][0][0]]) minvalx = np.min([minvalx,objCont[j][0][1]]) maxvalx = np.max([maxvalx,objCont[j][0][1]]) if rect[2] <=-45: rotAgl = 90 +rect[2] else: rotAgl = rect[2] if rotAgl == 0: panelImg = srcImage[minvalx:maxvalx,minvaly:maxvaly,:] else: rotCtr = rect[0] rotCtr = (int(rotCtr[0]),int(rotCtr[1])) rotMdl = cv2.getRotationMatrix2D(rotCtr,rotAgl,1) imgHeight,imgWidth = srcImage.shape[:2] #图像的旋转 dstHeight = math.sqrt(imgWidth *imgWidth + imgHeight*imgHeight) dstRotimg = cv2.warpAffine(threshRotate,rotMdl,(int(dstHeight),int(dstHeight))) dstImage = cv2.warpAffine(srcImage,rotMdl,(int(dstHeight),int(dstHeight))) dstRotimg = cv2.cvtColor(dstRotimg,cv2.COLOR_BGR2GRAY) _,dstRotBW = cv2.threshold(dstRotimg,127,255,0) contours = cv2.findContours(dstRotBW,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) maxcntArea = 0;maxAreaPos = -1 for i in range(len(contours)): if maxcntArea < cv2.contourArea(contours[i]): maxcntArea = cv2.contourArea(contours[i]) maxAreaPos = i x,y,w,h = cv2.boundingRect(contours[maxAreaPos]) #提取前景:panel panelImg = dstImage[int(y):int(y+h),int(x):int(x+w),:] return panelImg if __name__=="__main__": srcImage = cv2.imread('11.jpg') a=panelAbstract(srcImage) cv2.imshow('figa',a) cv2.waitKey(0) cv2.destroyAllWindows() 这是原地址https://blog.csdn.net/Dawn__Z/article/details/82115160 报错如下(知道错是什么意思就是不会改):Traceback (most recent call last): File "D:\Workspaces\MyEclipse 2015\pythonTest\src\cc.py", line 70, in a=panelAbstract(srcImage) File "D:\Workspaces\MyEclipse 2015\pythonTest\src\cc.py", line 7, in panelAbstract imgHeight,imgWidth = srcImage.shape[:2] AttributeError: 'NoneType' object has no attribute 'shape'
cuda简单图像处理,结果图像是全黑的,不知道哪里出问题了,跪求指导!
__device__ float near_color(float3 color1, float3 color2){ //BGR to YUV float Y1 = 0.299*color1.z + 0.587*color1.y + 0.114*color1.x; float U1 = -0.147*color1.z - 0.289*color1.y + 0.436*color1.x; float V1 = 0.615*color1.z - 0.515*color1.y - 0.100*color1.x; double Y2 = 0.299*color2.z + 0.587*color2.y + 0.114*color2.x; double U2 = -0.147*color2.z - 0.289*color2.y + 0.436*color2.x; double V2 = 0.615*color2.z - 0.515*color2.y - 0.100*color2.x; float distance = (U1 - U2)*(U1 - U2) + (V1 - V2)*(V1 - V2) + (Y1 - Y2)*(Y1 - Y2); return distance; } __global__ void near_color_edge_detect(float3* dataIn, float4 *dataOut, int width, int height) { int xIndex = threadIdx.x + blockIdx.x * blockDim.x; int yIndex = threadIdx.y + blockIdx.y * blockDim.y; float3 colorC, colorL, colorR, colorT, colorB; double nearcolor_value = 0.00; float4 out; if (xIndex + 1 < width && yIndex + 1 < height &&xIndex - 1 >= 0 && yIndex - 1 >= 0) { colorC = dataIn[yIndex *width + xIndex ]; colorL = dataIn[yIndex *width + xIndex - 1]; colorR = dataIn[yIndex *width + xIndex + 1]; colorT = dataIn[(yIndex - 1) *width + xIndex]; colorB = dataIn[(yIndex + 1) *width + xIndex]; out.x = 1.0; out.y = 1.0; out.z = 1.0; out.w = 1.0; if ( (near_color(colorL, colorR) >= nearcolor_value) ) { if (near_color(colorL, colorC) < near_color(colorC, colorR)) { out.x = 1.0; out.y = 0.0; out.z = 0.0; out.w = 1.0; } else{ out.x = -1.0; out.y = 0.0; out.z = 0.0; out.w = 1.0; } } if (near_color(colorT, colorB) >= nearcolor_value) { if (near_color(colorT, colorC)<near_color(colorC, colorB)) { out.x = 0.0; out.y = 1.0; out.z = 0.0; out.w = 1.0; } else{ out.x = 0.0; out.y = -1.0; out.z = 0.0; out.w = 1.0; } } dataOut[yIndex *width + xIndex] = out; } } 刚刚接触cuda编程,想把之前写的一个函数改写一下,结果输出的结果总是全黑的,不知道是哪里出了问题,估计是在使用near_color函数做if else判断的时候出了问题,求知道的大神不吝赐教,非常感谢!
c语言 结构体指针输出信息不完整
#include<stdio.h> struct stu{ char *name; int num; int age; char group; float score; }stus[5] = {{"Zhou ping", 5, 18, 'C', 145.0}, {"Zhang ping", 4, 19, 'A', 130.5}, {"Liu fang", 1, 18, 'A', 148.5}, {"Wang ming", 3, 17, 'B', 144.5} }, *p=stus; int main () { int j; int pjf ( struct stu w[],int i ); int charu ( struct stu a[],int n); pjf (stus,5); stus[4]=stus[3]; charu(stus,3); for(j=0;j<5;j++) { printf("%s,%d,%d,%c,%f\n",p[j].name,p[j].num,p[j].age,p[j].group,p[j].score); } return 0; } int pjf ( struct stu w[],int i ) { int sum=0; for(i=0;i<5;i++) { sum+=w[i].score; } printf ("%f\n",sum/4.0); return 0; } int charu ( struct stu a[],int n) { printf("请输入一条记录\n"); scanf("%s,%d,%d,%c,%f",&a[3].name,&a[3].num,&a[3].age,&a[3].group,&a[3].score); return 0; } ![图片说明](https://img-ask.csdn.net/upload/201703/08/1488959301_623774.png) 应该输出5组信息但是只有3组,不知道什么原因,跪求大神
c语言结构体数组赋值新值但旧值还在
#include<stdio.h> #include<string.h> struct stu{ char name[20]; int num; int age; char group; float score; }stus[5] = {{"Zhou ping", 5, 18, 'C', 145.0}, {"Zhang ping", 4, 19, 'A', 130.5}, {"Liu fang", 1, 18, 'A', 148.5}, {"Wang ming", 3, 17, 'B', 144.5} } ; int main () { struct stu*p=stus; int j; char name[20]; int pjf ( struct stu w[],int i ); int charu ( struct stu a[3]); int shang ( struct stu *a); pjf (stus,5); (p+4)[0]=(p+3)[0]; charu(stus); printf(" \n"); for(j=0;j<5;j++) { printf("%s,%d,%d,%c,%7.2f\n",p[j].name,p[j].num,p[j].age,p[j].group,p[j].score); } printf(" \n"); shang (stus); for(j=0;j<4;j++) { printf("%s,%d,%d,%c,%7.2f\n",p[j].name,p[j].num,p[j].age,p[j].group,p[j].score); } return 0; } int pjf ( struct stu w[],int i ) { int sum=0; for(i=0;i<5;i++) { sum+=w[i].score; } printf ("平均分是 %7.2f\n",sum/4.0); return 0; } int charu ( struct stu a[3]) { printf("请输入一条记录 姓名,学号,年龄,小组,成绩 (逗号隔开)\n"); scanf("%s,%d,%d,%c,%f",a[3].name,a[3].num,a[3].age,a[3].group,a[3].score); return 0; } int shang ( struct stu *a) { (a+2)[0]=(a+3)[0]; (a+3)[0]=(a+4)[0]; return 0; } ![图片说明](https://img-ask.csdn.net/upload/201703/10/1489120045_776100.png) 圈出的就是问题所在,为什么原来的数值还在,跪求大神
斐波那契堆JAVA实现的问题
最近在做用斐波那契堆改进Prim算法的作业。但是Java代码调试了两个周还是有问题,只能正确输出前3项。 还有几天就要提交作业了,在次跪求大神们帮忙瞧瞧代码。 代码如下: public class FibonacciNode { FibonacciNode child, left, right, parent; int vertex; float element; int degree; Boolean mark; /** Constructor **/ public FibonacciNode(int vertex, float element) { this.right=this; this.left=this; this.parent=null; this.child=null; this.vertex=vertex; this.element=element; this.degree=0; this.mark=false; } } public class FibonacciHeap { FibonacciNode root; int count; public FibonacciHeap(){ root=null; count=0; } //Return the number of nodes of the current heap public int size(){ return count; } //Judge if the heap is empty public boolean isEmpty(){ return root==null; } //Clear the whole heap public void clear(){ root=null; count=0; } //Insert a node to the heap. public void insert(int vertex, Float element){ FibonacciNode node=new FibonacciNode(vertex, element); if(root==null) root=node; else{ addNode(node, root); if(root.element>node.element){ root=node; } } count++; } //Add b to the tail of a //Notify that a and b are both the heads of a double-linked list private void catList(FibonacciNode a, FibonacciNode b){ FibonacciNode tmp= a.right; a.right =b.right; b.right.left= a; b.right= tmp; tmp.left= b; } //Get the minimum node of the heap and remove it from the heap public FibonacciNode extractMin(){ if(root==null){ return null; } if(root.child!=null){ FibonacciNode m = root; FibonacciNode start=root.child; for(int i=0; i<m.degree; i++){ if(start!=null){ start.parent=null; addNode(start, root); start=start.right; } } } //remove root from the root list of heap FibonacciNode min=root; min.left.right=min.right; min.right.left=min.left; //if min.right==min, then the root of the heap has no child if(min.right==min){ this.root=null; } else{ root=min.right; consolidate(); } //decrease the number of the nodes count--; return min; } /* // 将min每一个儿子(儿子和儿子的兄弟)都添加到"斐波那契堆的根链表"中 while (m.child != null){ FibonacciNode child=m.child; removeNode(child); if(child.right==child) m.child=null; else m.child=child.right; addNode(child, min); child.parent=null; } */ /* if(min.child!=null){ //set all the min's child's parent as null System.out.println("2:22222"); FibonacciNode startChild=min.child; startChild.parent=null; for(FibonacciNode x=startChild.right; x!=startChild; x=x.right){ x.parent=null; System.out.println("3:22222"); } //merge the children to the root list catList(root, startChild); } */ //unify two node if they have the same degree private void consolidate() { FibonacciNode[] cons=new FibonacciNode[this.count]; for(int i=0; i<this.count; i++) cons[i] = null; while (root!=null) { FibonacciNode x =root; if(x==x.right) root=null; else{ removeNode(x); root=x.right; } int d=x.degree; while(cons[d]!=null) { FibonacciNode y=cons[d]; if (x.element>y.element) { FibonacciNode tmp=x; x=y; y=tmp; } link(y, x); cons[d]=null; d++; } cons[d] = x; } root = null; for(int i=0; i<cons.length; i++){ if(cons[i] != null) { if(root == null) root = cons[i]; else{ addNode(cons[i], root); if ((cons[i]).element < root.element) root = cons[i]; } } } } //remove node1 from the root list and make it as node2's child private void link(FibonacciNode node1, FibonacciNode node2) { // remove node1 from the root list node1.left.right = node1.right; node1.right.left = node1.left; // set node as root's child if (node2.child == null) node2.child = node1; else{ node1.right=node2.child.right; node2.child.right=node1; node1.left=node2.child; node1.right.left=node1; } node1.parent = node2; node2.degree++; node1.mark = false; } //add node to the list rooted at root private void addNode(FibonacciNode node, FibonacciNode root) { node.left=root; node.right=root.right; root.right=node; node.right.left=node; } public void decreaseKey(FibonacciNode node, int key) { if (key > node.element) { System.out.println("decrease failed: the new key is no smaller than current key"); return; } if (root==null||node==null) return; node.element=key; FibonacciNode parent = node.parent; //if parent is null or node's element is no smaller than it's parent's, nothing is needed to be done if (parent!=null&&(node.element<parent.element)) { //remove node and add it to the root list cut(node, parent); cascadingCut(parent); } // update the root node if (node.element<root.element) root=node; } private void removeNode(FibonacciNode node) { node.left.right = node.right; node.right.left = node.left; } private void renewDegree(FibonacciNode parent){ parent.degree -= 1; if(parent. parent != null) renewDegree(parent.parent); } //remove node from it's parent and add it to the root list private void cut(FibonacciNode node, FibonacciNode parent) { removeNode(node); renewDegree(parent); //node has no sibling if (node==node.right) parent.child=null; else parent.child=node.right; node.parent=null; node.left=node.right=node; node.mark=false; //add to the root list of heap addNode(node, root); } //recurse cut the parent' parent, until reach the root list private void cascadingCut(FibonacciNode node) { FibonacciNode parent = node.parent; if (parent!=null) { if(node.mark==false) node.mark=true; else{ cut(node, parent); cascadingCut(parent); } } } //Add heap other to the current heap public void union(FibonacciHeap other) { if (this.root==null) //this is empty, just return the othe this.root=other.root; else if((other.root)!=null) {// both this and other are not empty catList(this.root, other.root); if(this.root.element>other.root.element) this.root=other.root; } this.count=this.count+other.count; other=null; return; } } 测试程序: public class FibonacciHeapTest { public static void main(String[] args){ FibonacciHeap heap=new FibonacciHeap(); for(int i=10; i>0; i--){ heap.insert(9-i, (float)i); } for(int i=0; i<10; i++){ System.out.println(heap.extractMin().element); } } } 运行结果: 1.0 2.0 3.0 4.0 Exception in thread "main" java.lang.NullPointerException at MST.FibonacciHeapTest.main(FibonacciHeapTest.java:10)
创建窗口过程中的问题
本人最近在做毕业设计,需要基于OpenGL显示,在创建窗口的过程中遇到了hWnd创建失败的问题,但是没有办法查出来具体问题在哪,请教各位大神了。。跪求解答,万分感谢,救急!!! #define WIN32_LEAN_AND_MEAN //裁剪过大的windows库 #include "windows.h" #include "gl\gl.h" #include "gl\glu.h" #include "GLaux.h" static LPCTSTR lpszAppName = "OpenGL App"; float angle = 0.0f; HDC g_HDC; //HBRUSH hBlueBrush,hRedBrush; void SetupPixelFormat(HDC hDC) { GLuint nPixelFormat; //像素格式变量 static PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0, }; nPixelFormat = ChoosePixelFormat(hDC,&pfd); SetPixelFormat(hDC, nPixelFormat, &pfd); } //windows事件处理器 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static HGLRC hRC; static HDC hDC; int width,height; switch(message) { case WM_CREATE: hDC = GetDC(hWnd); g_HDC = hDC; SetupPixelFormat(hDC); hRC = wglCreateContext(hDC); wglMakeCurrent(hDC,hRC); /*MessageBox(NULL,"error5。","关闭错误",MB_OK | MB_ICONINFORMATION);return 0; break;*/ case WM_CLOSE: wglMakeCurrent(hDC,NULL); wglDeleteContext(hRC); PostQuitMessage(0); /* MessageBox(NULL,"error4。","关闭错误",MB_OK | MB_ICONINFORMATION);return 0; break;*/ case WM_SIZE: height = HIWORD(lParam); width = LOWORD(lParam); if(height == 0) {height = 1;} glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 1.0f, 1000.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); /*MessageBox(NULL,"error3。","关闭错误",MB_OK | MB_ICONINFORMATION);return 0; break;*/ /* case WM_PAINT: { PAINTSTRUCT ps; HBRUSH hOldBrush; BeginPaint(hWnd, &ps); hOldBrush = SelectObject(ps.hdc, hRedBrush); Rectangle(ps.hdc, 100,100,150,150); SelectObject(ps.hdc, hOldBrush); EndPaint(hWnd, &ps); } break; */ default: return DefWindowProc(hWnd,message,wParam,lParam);//break; } return (0L); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wc; MSG msg; HWND hWnd; BOOL done; /* hBlueBrush = CreateSolidBrush(RGB(0,0,255)); hRedBrush = CreateSolidBrush(RGB(255,0,0)); */ wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW ; wc.lpfnWndProc = (WNDPROC)WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(hInstance, IDC_ARROW); wc.hbrBackground = NULL; wc.lpszClassName = lpszAppName; wc.lpszMenuName = NULL; wc.hIconSm = LoadIcon(wc.hInstance,IDI_WINLOGO); if(!RegisterClassEx(&wc)) // return 0; {MessageBox(NULL,"error1。","关闭错误",MB_OK | MB_ICONINFORMATION);return 0;} hWnd = CreateWindowEx( NULL, "MyClass", "The OpenGL window Application", WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 100,100, 400,400, NULL, NULL, hInstance, NULL); if(!hWnd) { MessageBox(NULL,"error2。","关闭错误",MB_OK | MB_ICONINFORMATION); return 0; } ShowWindow(hWnd, SW_SHOW); UpdateWindow(hWnd); done = FALSE; while(!done) { PeekMessage(&msg, hWnd, NULL, NULL, PM_REMOVE); if(msg.message == WM_QUIT) {done = TRUE;} else { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); angle = angle + 0.1f; if(angle >= 360.f) angle = 0.0f; glTranslatef(0.0f, 0.0f, -5.0f); //向后移动五个单位 glRotatef(angle, 0.0f, 0.0f, 1.0f); //绕z轴转 glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_TRIANGLES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glEnd(); SwapBuffers(g_HDC); TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; }
softmax分类器,分类概率都是nan是怎么回事?
训练结果有测试集和训练集的准确率,但是调取测试集的预测值时,全都是nan,我需要得到测试结果实际应用的。请问怎么解决?拿一个二分类为例 以下是前期搭建框架 import numpy as np import tensorflow as tf x=tf.placeholder("float", [None,115]) y=tf.placeholder("float", [None,2]) W=tf.Variable(tf.zeros([115,2])) b=tf.Variable(tf.zeros([2])) actv= tf.nn.softmax(tf.matmul(x,W)+b) ####网上查到说下面这个loss函数中如果是log(0)的话就会有nan,但那应该连训练结果都没有才对吧?我现在能得到训练结果,但是结果都是nan怎么办? cost=tf.reduce_mean(-tf.reduce_sum(y*tf.log(actv), reduction_indices=1)) learning_rate=0.01 optm= tf.train.GradientDescentOptimizer(learning_rate).minimize(cost) pred=tf.equal(tf.argmax(actv, 1), tf.argmax(y, 1)) accr=tf.reduce_mean(tf.cast(pred,"float")) init=tf.global_variables_initializer() sess=tf.InteractiveSession() sess=tf.Session() sess.run(init) training_lenth=len(G)####(回测长度) training_epochs =50 #训练次数 batch_size = len(G) #每次迭代用多少样本(用全套) ##display_step = 5 #展示 print('Down') 训练重点来了,我需要得到result的实际结果 lenth=2 for epoch in range(training_epochs): avg_cost=0 num_batch=int(len(G)/batch_size) for i in range((lenth-1),lenth): batch_xs=np.array(G[i]) batch_ys=np.array(F[i]) sess.run(optm, feed_dict={x: batch_xs, y: batch_ys}) feeds={x:batch_xs, y: batch_ys} avg_cost += sess.run (cost, feed_dict=feeds)/(num_batch*lenth) feeds_train = {x: batch_xs, y: batch_ys} feeds_test = {x: G[i+1], y: F[i+1]} train_acc = sess.run(accr, feed_dict=feeds_train) #feed_dict 针对place holder占位 test_acc = sess.run(accr,feed_dict=feeds_test) result=sess.run(actv,feed_dict=feeds_test) 但是实际给我的结果中,test_acc和train_acc都是有的,但是具体分类的概率值都是nan。 result=sess.run(actv,feed_dict=feeds_train) print (train_acc)# print(test_acc) train_acc a=sess.run([accr,actv],feed_dict=feeds_test) print(a) 0.930233 0.465116 [0.46511629, array([[ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan], [ nan, nan]], dtype=float32)] 求大神指教,跪送分
C++初学问题!!求讲解
新手,我写了一个职工管理系统,没有语法错误。但运行不了,应该是类和链表有问题,但我太菜,不知道怎么解决,求大神帮忙。 以下是我的程序(因为有格式问题,可能略乱,跪求忽视) #include "stdafx.h" #include <iostream> #include <fstream> #include <process.h> #include <cstring> #include <conio.h> using namespace std; void MainMenuControl(); int MainMenu(); class CStaff { public: CStaff( char *id, char *name, char *birth, char *depart, char *title, char *rank, float tel, char sex= 'M' ) { strcpy(this->id,id); strcpy(this->name,name); strcpy(this->birth,birth); strcpy(this->depart,depart); strcpy(this->title,title); strcpy(this->rank,rank); this->tel= tel; this->sex= sex; } friend class CStaffList; void ShowInfo() { cout<<"**工号"<<"\t"<<"姓名"<<"\t"<<"性别"<<"\t"<<"出生年月"<<"\t" <<"部门"<<"\t"<<"职称"<<"\t"<<"工资级别"<<"\t"<<"电话**"<<endl; cout<<"**"<<this->id<<"\t"<<this->name<<"\t"<<( this->sex == 'M'?"男":"女" )<<"\t"<<this->birth<<"\t" <<this->depart<<"\t"<<this->title<<"\t"<<this->rank<<"\t"<<this->tel<<"**"<<endl; } private: char id[10]; char name[15]; char sex; char birth[10]; char depart[10]; char title[10]; char rank[10]; float tel; CStaff *next; }; class CStaffList { private: CStaff *Staff; CStaff *p; void Clear() { CStaff *pt= Staff; while(pt) { Staff= pt->next; delete pt; pt= Staff; } }//重新载入的时候清除原内存 public: CStaffList() { Staff= 0; Load(); } ~CStaffList() { CStaff *pt; pt= Staff; while(pt) { pt= pt->next; delete Staff; Staff= pt; } Staff= 0; } void Add();//录入 void modify();//链接编辑和检索函数 void Modify();//修改 void Browsing();//显示到屏幕上 void Save(); //数据存盘 void Load(); //数据装入 void Retrieval();//检索 }; int main() { MainMenuControl(); return 0; } int MainMenu() { cout<<"********************************************************************************"<<endl; cout<<"** 职工档案管理系统 **"<<endl; cout<<"********************************************************************************"<<endl; cout<<"** **"<<endl; cout<<"** 信息浏览.......Information Browsing...1 **"<<endl; cout<<"** 信息检索.......Information Retrieval..2 **"<<endl; cout<<"** 添加职工信息...Add Staff Information..3 **"<<endl; cout<<"** 职工信息编辑...Information Modify.....4 **"<<endl; cout<<"** 数据导入.......Load Information ......5 **"<<endl; cout<<"** 数据保存.......Save Information.......6 **"<<endl; cout<<"** 退出...........Exit...................0 **"<<endl; cout<<" 请输入项目号进入应用:"; int choice; cin>>choice; return choice; } void MainMenuControl() { while(1) { int choice= MainMenu(); CStaffList s1; switch(choice) { case 1: s1.Browsing(); break; case 2: s1.Retrieval();break; case 3: s1.Add(); break; case 4: s1.modify(); break; case 5: s1.Load(); break; case 6: s1.Save(); break; case 0: cout<<"*************************系统退出,欢迎下次使用*********************************"<<endl; exit(0); default: break; } system("cls"); } } void CStaffList::Load()//数据装入 { char id[10]; char name[15]; char sex; char birth[10]; char depart[10]; char title[10]; char rank[10]; float tel; fstream file; file.open("staff_file.txt",ios::in); if(!file) { cout<<"** 不能打开文件文件:staff_file.txt!! **"<<endl; exit(1); } file>>id>>name>>sex>>birth>>depart>>title>>rank>>tel;//预读第一行(项目名称),不录入 CStaffList::Clear(); CStaff *p1,*p0;//p1用于创建新的内存空间的,p0用于找到尾地址,链接作用 file>>id>>name>>sex>>birth>>depart>>title>>rank>>tel;//录入第二行 获得首地址 p1= new CStaff( id, name, birth, depart, title, rank, tel, sex ); p0= Staff= p1; while( !file.eof())//从第三行开始循环录入 { file>>id>>name>>sex>>birth>>depart>>title>>rank>>tel; p1= new CStaff( id, name, birth, depart, title, rank, tel, sex ); p0->next= p1; p0= p0->next; } p0= NULL; file.close(); } void CStaffList::Save() { CStaff *p1; fstream file; file.open("staff_file.txt",ios::trunc); if(!file) { cout<<"** 不能打开文件文件:staff_file.txt!! **"<<endl; exit(1); } if(Staff) { file<<"工号"<<"\t"<<"姓名"<<"\t"<<"性别"<<"\t"<<"出生年月"<<"\t" <<"部门"<<"\t"<<"职称"<<"\t"<<"工资级别"<<"\t"<<"电话"<<"\n"; for( p1= Staff; p1 != NULL; p1= p1->next ) file<<p1->id<<"\t"<<p1->name<<"\t"<<( p1->sex == 'M'?"男":"女" )<<"\t"<<p1->birth<<"\t" <<p1->depart<<"\t"<<p1->title<<"\t"<<p1->rank<<"\t"<<p1->tel<<"\n"; } else { cout<<"** 无成员,请添加:staff_file.txt!! **"<<endl; return; } file.close(); //返回主菜单 cout<<"** 按任意键返回主菜单 **"<<endl; char ch; ch= getch(); return; } void CStaffList::Add() { CStaff *p1; char id[10]; cout<<">> 工号:"; cin>>id; char name[15]; cout<<">> 姓名:"; cin>>name; char sex; cout<<">> 性别(M/W):"; cin>>sex; char birth[10]; cout<<">> 生日(1970.1.1):";cin>>birth; char depart[10];cout<<">> 部门:"; cin>>depart; char title[10]; cout<<">> 职称:"; cin>>title; char rank[10]; cout<<">> 工资级别:"; cin>>rank; float tel; cout<<">> 电话:"; cin>>tel; p1= new CStaff( id, name, birth, depart, title, rank, tel, sex ); p1->next= 0; if(Staff) { CStaff *p0; for( p0= Staff; p0->next!= NULL; p0= p0->next ); p0->next= p1; } else { Staff= p1; } //链接到save函数进行保存和文件数据同步 cout<<"** 请按『s』键进行保存 **"<<endl; char c; cin>>c; while(1) { if( c== 's'||'S' ) { CStaffList::Save();return; } else { cout<<" 输入有误,重新输入:"; cin>>c; } } } void CStaffList::Retrieval() { while(1) { cout<<"** 请选择查找方式 **"<<endl; cout<<"** 1. 按工号进行搜索 Search by ID **"<<endl; cout<<"** 2. 按姓名进行搜素 Search by Name **"<<endl; cout<<"** 0. 返回主菜单 Return MainMenu **"<<endl; int choice; cin>>choice; CStaff *p1; p1= Staff; char c; switch(choice) { case 1: //按id筛选查找结点 char id[10]; cin>>id; for( ; p1 != NULL; p1= p1->next ) if( strcmp( p1->id,id) == 0 ) break; if( p1 == NULL ) { cout<<"** 您所查找的用户不存在 **"<<endl;break; } else { cout<<"** 你所查找的信息如下: **"<<endl; p1->ShowInfo(); } //在检索的基础上进行编辑操作 cout<<" 是否对该用户进行编辑?Y/N"<<endl; cin>>c; while(1) { if( c == 'y'||'Y') { p= p1; CStaffList::Modify(); } else if( c == 'n'||'N') break; else { cout<<" 输入有误,请重新输入:"; cin>>c; } } break; case 2: //按姓名找结点 char name[10]; cin>>name; for( ; p1 != NULL; p1= p1->next ) if( strcmp( p1->name,name) == 0 ) break; if( p1 == NULL ) { cout<<"** 您所查找的用户不存在 **"<<endl;break; } else p1->ShowInfo(); cout<<" 是否对该用户进行编辑?Y/N:"; cin>>c; while(1) { if( c == 'y'||'Y') { p= p1; CStaffList::Modify(); } else if( c == 'n'||'N') break; else { cout<<" 输入有误,请重新输入:"; cin>>c; } } break; case 0: return; } } } void CStaffList::modify()//没有实际作用,连接到检索菜单 { cout<<"** 1.检索所要编辑的职工 **"<<endl; cout<<"** 0. 返回主菜单 **"<<endl; int choice; while(1) { cout<<" 请输入您的选择:"; cin>>choice; switch(choice) { case 1: CStaffList::Retrieval(); case 0: return; default:cout<<"** 输入有误,请重新输入! **"<<endl; break; } } } void CStaffList::Modify() { while(1) { cout<<"** 请选择你所需要修改信息,请填序号: **"<<endl; cout<<"** 1. 工号 2.姓名 **"<<endl; cout<<"** 3. 性别 4.出生日期 **"<<endl; cout<<"** 5. 部门 6.职称 **"<<endl; cout<<"** 7. 工资级别 8.电话 **"<<endl; int choice; cin>>choice; switch(choice) { case 1: cout<<">> 工号:"; cin>>p->id; break; case 2: cout<<">> 姓名:"; cin>>p->name; break; case 3: cout<<">> 性别(M/W):"; cin>>p->sex; break; case 4: cout<<">> 出生年月(1970.1.1):";cin>>p->birth; break; case 5: cout<<">> 部门:"; cin>>p->depart;break; case 6: cout<<">> 职称:"; cin>>p->title; break; case 7: cout<<">> 工资等级:"; cin>>p->rank; break; case 8: cout<<">> 电话:"; cin>>p->tel; break; } cout<<"** 已修改,信息如下: **:"<<endl; p->ShowInfo(); char c; cin>>c; while(1) { cout<<" 是否保存并退出编辑?Y/N:"; if( c == 'y'||'Y' ) { CStaffList::Save();return; } else if( c == 'n'||'N' )break; else { cout<<"** 输入有误,请重新输入: **"; cin>>c; } } } p= Staff; } void CStaffList::Browsing() { CStaff *p1; cout<<"** 职工信息如下 **"<<endl; cout<<"**工号"<<"\t"<<"姓名"<<"\t"<<"性别"<<"\t"<<"出生年月"<<"\t" <<"部门"<<"\t"<<"职称"<<"\t"<<"工资级别"<<"\t"<<"电话**"<<endl; for( p1= Staff; p1!= NULL; p1= p1->next ) cout<<"**"<<p1->id<<"\t"<<p1->name<<"\t"<<(p1->sex=='M'?"男":"女")<<"\t"<<p1->birth<<"\t" <<p1->depart<<"\t"<<p1->title<<"\t"<<p1->rank<<"\t"<<p1->tel<<"**"<<endl; }
ARM板自身的四通道ADC采集的声音波形怎么会这样?偏置电压怎么相差如此之大?
![图片说明](https://img-ask.csdn.net/upload/201512/09/1449645183_723903.jpg) 用TQ2440开发板ADC做声音采集,AD转换频率是0.5MHz,AD转换时间是10us,采样频率是25KHz,采样点数是1024。采集数据写入文件,代码如下: (在上层应用ioctl()控制ADC通道切换,四通道引脚悬空或接地或接3.3V时数据均能够正常显示,但是在接入麦克风之后出现波形如图所示那样,跪求大神指导) int main () { FILE *fp0, *fp1, *fp2, *fp3; int count = 0; int fd, ret, value; char buffer[30]; float temp; char channel; // unsigned long arg = 0x63; fd = open(DEVICE_NAME, 0); fp0 = fopen("sample1.txt", "w"); fp1 = fopen("sample2.txt", "w"); fp2 = fopen("sample3.txt", "w"); fp3 = fopen("sample4.txt", "w"); if(fp0 == NULL || fp1 == NULL || fp2 == NULL || fp3 == NULL) { printf("Open file error!\n"); exit(1); } printf("open fd = %d\n", fd); if(fd < 0) { perror("Open ADC Device Failed!\n"); exit(1); } while(1) { if(count < COUNT) { count++; for(channel = 0; channel < 4; channel++) { ioctl(fd, channel, 1); memset(buffer, 0, 30); ret = read(fd, buffer, sizeof(buffer) - 1); if(ret > 0) { buffer[ret] = '\0'; sscanf(buffer, "%d\n", &value); temp =((float)value*3.3)/1024.0; switch(channel) { case 0: fprintf(fp0, "%f\n", temp); break; case 1: fprintf(fp1, "%f\n", temp); break; case 2: fprintf(fp2, "%f\n", temp); break; case 3: fprintf(fp3, "%f\n", temp); break; } // printf("ADC AIN[%d]:voltage:%4.2f Value: %d\n", channel, temp, value); } else { perror("read ADC device!\n"); exit(1); } } } else { printf("The count of number is OK!\n"); break; } // sleep(1); } fclose(fp0); fclose(fp1); fclose(fp2); fclose(fp3); close(fd); return 0; }
Tensorflow利用自制的数据集做图像识别,程序卡在读取tfrecord文件不跑
我利用自己的图片做了一个数据集训练神经网络,在feed数据的时候数据类型不合适,加了session.run()程序就卡在这里不动了,下面贴出代码,跪求大神指导。 程序卡在print(“begin4”)和print(“begin5”)之间 ``` import tensorflow as tf from encode_to_tfrecords import create_record, create_test_record, read_and_decode, get_batch, get_test_batch n_input = 154587 n_classes = 3 dropout = 0.5 x = tf.placeholder(tf.float32, [None, n_input]) y = tf.placeholder(tf.int32, [None, n_classes]) keep_drop = tf.placeholder(tf.float32) class network(object): def inference(self, images,keep_drop): #################################################################################################################### # 向量转为矩阵 # images = tf.reshape(images, shape=[-1, 39,39, 3]) images = tf.reshape(images, shape=[-1, 227, 227, 3]) # [batch, in_height, in_width, in_channels] images = (tf.cast(images, tf.float32) / 255. - 0.5) * 2 # 归一化处理 #################################################################################################################### # 第一层 定义卷积偏置和下采样 conv1 = tf.nn.bias_add(tf.nn.conv2d(images, self.weights['conv1'], strides=[1, 4, 4, 1], padding='VALID'), self.biases['conv1']) relu1 = tf.nn.relu(conv1) pool1 = tf.nn.max_pool(relu1, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID') # 第二层 conv2 = tf.nn.bias_add(tf.nn.conv2d(pool1, self.weights['conv2'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv2']) relu2 = tf.nn.relu(conv2) pool2 = tf.nn.max_pool(relu2, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID') # 第三层 conv3 = tf.nn.bias_add(tf.nn.conv2d(pool2, self.weights['conv3'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv3']) relu3 = tf.nn.relu(conv3) # pool3=tf.nn.max_pool(relu3, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='VALID') conv4 = tf.nn.bias_add(tf.nn.conv2d(relu3, self.weights['conv4'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv4']) relu4 = tf.nn.relu(conv4) conv5 = tf.nn.bias_add(tf.nn.conv2d(relu4, self.weights['conv5'], strides=[1, 1, 1, 1], padding='SAME'), self.biases['conv5']) relu5 = tf.nn.relu(conv5) pool5 = tf.nn.max_pool(relu5, ksize=[1, 3, 3, 1], strides=[1, 2, 2, 1], padding='VALID') # 全连接层1,先把特征图转为向量 flatten = tf.reshape(pool5, [-1, self.weights['fc1'].get_shape().as_list()[0]]) # dropout比率选用0.5 drop1 = tf.nn.dropout(flatten, keep_drop) fc1 = tf.matmul(drop1, self.weights['fc1']) + self.biases['fc1'] fc_relu1 = tf.nn.relu(fc1) fc2 = tf.matmul(fc_relu1, self.weights['fc2']) + self.biases['fc2'] fc_relu2 = tf.nn.relu(fc2) fc3 = tf.matmul(fc_relu2, self.weights['fc3']) + self.biases['fc3'] return fc3 def __init__(self): # 初始化权值和偏置 with tf.variable_scope("weights"): self.weights = { # 39*39*3->36*36*20->18*18*20 'conv1': tf.get_variable('conv1', [11, 11, 3, 96], initializer=tf.contrib.layers.xavier_initializer_conv2d()), # 18*18*20->16*16*40->8*8*40 'conv2': tf.get_variable('conv2', [5, 5, 96, 256], initializer=tf.contrib.layers.xavier_initializer_conv2d()), # 8*8*40->6*6*60->3*3*60 'conv3': tf.get_variable('conv3', [3, 3, 256, 384], initializer=tf.contrib.layers.xavier_initializer_conv2d()), # 3*3*60->120 'conv4': tf.get_variable('conv4', [3, 3, 384, 384], initializer=tf.contrib.layers.xavier_initializer_conv2d()), 'conv5': tf.get_variable('conv5', [3, 3, 384, 256], initializer=tf.contrib.layers.xavier_initializer_conv2d()), 'fc1': tf.get_variable('fc1', [6 * 6 * 256, 4096], initializer=tf.contrib.layers.xavier_initializer()), 'fc2': tf.get_variable('fc2', [4096, 4096], initializer=tf.contrib.layers.xavier_initializer()), 'fc3': tf.get_variable('fc3', [4096, 1000], initializer=tf.contrib.layers.xavier_initializer()), } with tf.variable_scope("biases"): self.biases = { 'conv1': tf.get_variable('conv1', [96, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv2': tf.get_variable('conv2', [256, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv3': tf.get_variable('conv3', [384, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv4': tf.get_variable('conv4', [384, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'conv5': tf.get_variable('conv5', [256, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'fc1': tf.get_variable('fc1', [4096, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'fc2': tf.get_variable('fc2', [4096, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)), 'fc3': tf.get_variable('fc3', [1000, ], initializer=tf.constant_initializer(value=0.1, dtype=tf.float32)) } # 计算softmax交叉熵损失函数 def sorfmax_loss(self, predicts, labels): predicts = tf.nn.softmax(predicts) labels = tf.one_hot(labels, self.weights['fc3'].get_shape().as_list()[1]) loss = tf.nn.softmax_cross_entropy_with_logits(logits=predicts, labels=labels) # loss =-tf.reduce_mean(labels * tf.log(predicts))# tf.nn.softmax_cross_entropy_with_logits(predicts, labels) self.cost = loss return self.cost # 梯度下降 def optimer(self, loss, lr=0.01): train_optimizer = tf.train.GradientDescentOptimizer(lr).minimize(loss) return train_optimizer #定义训练 # def train(self): create_record('/Users/hanjiarong/Documents/testdata/tfrtrain') # image, label = read_and_decode('train.tfrecords') # batch_image, batch_label = get_batch(image, label, 30) #连接网络 网络训练 net = network() inf = net.inference(x, dropout) loss = net.sorfmax_loss(inf,y) opti = net.optimer(loss) correct_pred = tf.equal(tf.argmax(inf, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32)) # #定义测试 create_test_record('/Users/hanjiarong/Documents/testdata/tfrtest') # image_t, label_t = read_and_decode('test.tfrecords') # batch_test_image, batch_test_label = get_test_batch(image_t, label_t, 50) # # #生成测试 init = tf.initialize_all_variables() with tf.Session() as session: session.run(init) coord = tf.train.Coordinator() threads = tf.train.start_queue_runners(coord=coord) max_iter = 100000 iter = 1 print("begin1") while iter * 30 < max_iter: print("begin2") image, label = read_and_decode('train.tfrecords') print("begin3") batch_image, batch_label = get_batch(image, label, 1) print("begin4") batch_image = session.run(batch_image) batch_label = session.run(batch_label) print("begin5") # loss_np, _, label_np, image_np, inf_np = session.run([loss, opti, batch_label, batch_image, inf]) session.run(opti, feed_dict={x: batch_image, y: batch_label, keep_drop: dropout}) print("begin6") if iter % 10 == 0: loss, acc = session.run([loss, accuracy], feed_dict={x: batch_image, y: batch_label, keep_drop: 1.}) print("Iter " + str(iter * 30) + ", Minibatch Loss= " + \ "{:.6f}".format(loss) + ", Training Accuracy= " + "{:.5f}".format(acc)) iter += 1 print("Optimization Finished!") image, label = read_and_decode('test.tfrecords') batch_test_image, batch_test_label = get_batch(image, label, 2) img_test, lab_test = session.run([batch_test_image, batch_test_label]) test_accuracy = session.run(accuracy, feed_dict={x: img_test, y: lab_test, keep_drop: 1.}) print("Testing Accuracy:", test_accuracy) ```
相见恨晚的超实用网站
搞学习 知乎:www.zhihu.com 简答题:http://www.jiandati.com/ 网易公开课:https://open.163.com/ted/ 网易云课堂:https://study.163.com/ 中国大学MOOC:www.icourse163.org 网易云课堂:study.163.com 哔哩哔哩弹幕网:www.bilibili.com 我要自学网:www.51zxw
花了20分钟,给女朋友们写了一个web版群聊程序
参考博客 [1]https://www.byteslounge.com/tutorials/java-ee-html5-websocket-example
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
引言 本文主要是记录一下面试字节跳动的经历。 三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时
开源一个功能完整的SpringBoot项目框架
福利来了,给大家带来一个福利。 最近想了解一下有关Spring Boot的开源项目,看了很多开源的框架,大多是一些demo或者是一个未成形的项目,基本功能都不完整,尤其是用户权限和菜单方面几乎没有完整的。 想到我之前做的框架,里面通用模块有:用户模块,权限模块,菜单模块,功能模块也齐全了,每一个功能都是完整的。 打算把这个框架分享出来,供大家使用和学习。 为什么用框架? 框架可以学习整体
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过
Python——画一棵漂亮的樱花树(不同种樱花+玫瑰+圣诞树喔)
最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,我整理了一下,挑了一些我觉得不错的代码分享给大家(这些我都测试过,确实可以生成喔~) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码 import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch
深深的码丨Java HashMap 透析
HashMap 相关概念 HashTab、HashMap、TreeMap 均以键值对像是存储或操作数据元素。HashTab继承自Dictionary,HashMap、TreeMap继承自AbstractMap,三者均实现Map接口 **HashTab:**同步哈希表,不支持null键或值,因为同步导致性能影响,很少被使用 **HashMap:**应用较多的非同步哈希表,支持null键或值,是键值对...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 顺便拉下票,我在参加csdn博客之星竞选,欢迎投票支持,每个QQ或者微信每天都可以投5票,扫二维码即可,http://m234140.nofollow.ax.
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 欢迎 改进 留言。 演示地点跳到演示地点 html代码如下`&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;music&lt;/title&gt; &lt;meta charset="utf-8"&gt
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐厅的约会 餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”我楞了一下,心里想女朋友今天是怎么了,怎么突然问出这么专业的问题,但做为一个专业人士在女朋友面前也不能露怯啊,想了一下便说:“我先给你讲讲我前同事老王的故事吧!” 大龄程序员老王 老王是一个已经北漂十多年的程序员,岁数大了,加班加不动了,升迁也无望,于是拿着手里
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
JDK12 Collectors.teeing 你真的需要了解一下
前言 在 Java 12 里面有个非常好用但在官方 JEP 没有公布的功能,因为它只是 Collector 中的一个小改动,它的作用是 merge 两个 collector 的结果,这句话显得很抽象,老规矩,我们先来看个图(这真是一个不和谐的图????): 管道改造经常会用这个小东西,通常我们叫它「三通」,它的主要作用就是将 downstream1 和 downstre...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
致 Python 初学者
欢迎来到“Python进阶”专栏!来到这里的每一位同学,应该大致上学习了很多 Python 的基础知识,正在努力成长的过程中。在此期间,一定遇到了很多的困惑,对未来的学习方向感到迷茫。我非常理解你们所面临的处境。我从2007年开始接触 python 这门编程语言,从2009年开始单一使用 python 应对所有的开发工作,直至今天。回顾自己的学习过程,也曾经遇到过无数的困难,也曾经迷茫过、困惑过。开办这个专栏,正是为了帮助像我当年一样困惑的 Python 初学者走出困境、快速成长。希望我的经验能真正帮到你
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
加快推动区块链技术和产业创新发展,2019可信区块链峰会在京召开
11月8日,由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办,科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。   区块链技术被认为是继蒸汽机、电力、互联网之后,下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力,电力解决了人类基本的生活需求,互联网彻底改变了信息传递的方式,区块链作为构造信任的技术有重要的价值。   1...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
8年经验面试官详解 Java 面试秘诀
作者 |胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。 Java程序员准备和投递简历的实...
面试官如何考察你的思维方式?
1.两种思维方式在求职面试中,经常会考察这种问题:北京有多少量特斯拉汽车?某胡同口的煎饼摊一年能卖出多少个煎饼?深圳有多少个产品经理?一辆公交车里能装下多少个乒乓球?一个正常成年人有多少根头发?这类估算问题,被称为费米问题,是以科学家费米命名的。为什么面试会问这种问题呢?这类问题能把两类人清楚地区分出来。一类是具有文科思维的人,擅长赞叹和模糊想象,它主要依靠的是人的第一反应和直觉,比如小孩...
碎片化的时代,如何学习
今天周末,和大家聊聊学习这件事情。 在如今这个社会,我们的时间被各类 APP 撕的粉碎。 刷知乎、刷微博、刷朋友圈; 看论坛、看博客、看公号; 等等形形色色的信息和知识获取方式一个都不错过。 貌似学了很多,但是却感觉没什么用。 要解决上面这些问题,首先要分清楚一点,什么是信息,什么是知识。 那什么是信息呢? 你一切听到的、看到的,都是信息,比如微博上的明星出轨、微信中的表情大战、抖音上的...
so easy! 10行代码写个"狗屁不通"文章生成器
前几天,GitHub 有个开源项目特别火,只要输入标题就可以生成一篇长长的文章。 背后实现代码一定很复杂吧,里面一定有很多高深莫测的机器学习等复杂算法 不过,当我看了源代码之后 这程序不到50行 尽管我有多年的Python经验,但我竟然一时也没有看懂 当然啦,原作者也说了,这个代码也是在无聊中诞生的,平时撸码是不写中文变量名的, 中文...
相关热词 c# clr dll c# 如何orm c# 固定大小的字符数组 c#框架设计 c# 删除数据库 c# 中文文字 图片转 c# 成员属性 接口 c#如何将程序封装 16进制负数转换 c# c#练手项目
立即提问