1个回答

slightdream1 有没有具体的操作步骤或者教程呢 我也是刚开始学习机器学习这块 感谢
4 个月之前 回复

Isabella's Message 消息的问题
Problem Description Isabella and Steve are very good friends, and they often write letters to each other. They exchange funny experiences, talk about people around, share their feelings and write about almost everything through the letters. When the letters are delivered, they are quite afraid that some other people(maybe their parents) would peek. So they encrypted the letter, and only they know how to decrypt it. This guarantees their privacy. The encrypted message is an N * N matrix, and each grid contains a character. Steve uses a special mask to work as a key. The mask is N * N(where N is an even number) matrix with N*N/4 holes of size 1 * 1 on it. The decrypt process consist of the following steps: 1. Put the mask on the encrypted message matrix 2. Write down the characters you can see through the holes, from top to down, then from left to right. 3. Rotate the mask by 90 degrees clockwise. 4. Go to step 2, unless you have wrote down all the N*N characters in the message matrix. 5. Erase all the redundant white spaces in the message. For example, you got a message shown in figure 1, and you have a mask looks like figure 2. The decryption process is shown in figure 3, and finally you may get a message "good morning". You can assume that the mask is always carefully chosen that each character in the encrypted message will appear exactly once during decryption. However, in the first step of decryption, there are several ways to put the mask on the message matrix, because the mask can be rotated (but not flipped). So you may get different results such as "od morning go" (as showed in figure 4), and you may also get other messages like "orning good m", "ng good morni". Steve didn't know which direction of the mask should be chosen at the beginning, but after he tried all possibilities, he found that the message "good morning" is the only one he wanted because he couldn't recognize some words in the other messages. So he will always consider the message he can understand the correct one. Whether he can understand a message depends whether he knows all the words in the message. If there are more than one ways to decrypt the message into an understandable one, he will choose the lexicographically smallest one. The way to compare two messages is to compare the words of two messages one by one, and the first pair of different words in the two messages will determine the lexicographic order of them. Isabella sends letters to Steve almost every day. As decrypting Isabella's message takes a lot of time, and Steve can wait no longer to know the content of the message, he asked you for help. Now you are given the message he received, the mask, and the list of words he already knew, can you write a program to help him decrypt it? Input The first line contains an integer T(1 <= T <= 100), indicating the number of test cases. Each test case contains several lines. The first line contains an even integer N(2 <= N <= 50), indicating the size of the matrix. The following N lines each contains exactly N characters, reresenting the message matrix. The message only contains lowercase letters and periods('.'), where periods represent the white spaces. You can assume the matrix contains at least one letter. The followingN lines each containsN characters, representing the mask matrix. The asterisk('*') represents a hole, and period('.') otherwise. The next line contains an integer M(1 <= M <= 100), the number of words he knew. Then the following M lines each contains a string represents a word. The words only contain lowercase letters, and its length will not exceed 20. Output For each test case in the input, print one line: "Case #X: Y", where X is the test case number (starting with 1) and Y is Isabella's message. If Steve cannot understand the message, just print the Y as "FAIL TO DECRYPT". Sample Input 3 4 o.do .ng. grmn o.i. .*.. *.*. .... *... 2 good morning 4 ..lf eoyv oeou vrer ..*. .*.. .... *.*. 5 i you the love forever 4 .sle s.c. e.fs ..uu *... .*.. ...* ..*. 1 successful Sample Output Case #1: good morning Case #2: love you forever Case #3: FAIL TO DECRYPT
SVRG为什么实现效果没有SGD好
> 我在用python实现SVRG算法的时候同时和SGD进行比较，在网络结构与激活函数相同的情况下SGD可以收敛，为什么SVRG不能收敛，我确定是按照论文上的算法进行编写，并且与多人的程序(虽然那些程序从来没有运行成功过)进行比较，但是仍然没有用我都不知道怎么解决了 ``` import numpy as np for i in range(max_iterations): batch_mask = np.random.choice(train_size, batch_size) x_batch = x_train[batch_mask] t_batch = t_train[batch_mask] """随机梯度下降法（Stochastic Gradient Descent）""" grads = networks['SGD'].gradient(x_batch, t_batch) optimizers['SGD'].update(networks['SGD'].params, grads) loss = networks['SGD'].loss(x_batch, t_batch) #获得训练误差 train_loss['SGD'].append(loss) #存储训练误差 maxiter = batch_size*2 """SVRG""" fullgrad = networks['SVRG'].gradient(x_batch, t_batch) w = copy.deepcopy(networks['SVRG'].params) wtemp = copy.deepcopy(w) for j in range(100): index = np.random.choice(batch_size, 1) x_index = x_batch[index] t_index = t_batch[index] networks['SVRG'].params = copy.deepcopy(wtemp) g1 = networks['SVRG'].gradient(x_index, t_index) networks['SVRG'].params = copy.deepcopy(w) g2 = networks['SVRG'].gradient(x_index, t_index) optimizers['SVRG'].update(networks['SVRG'].params, g1, g2, fullgrad) # 对参数进行更新 #params[key] = params[key] - self.lr * (g1[key] - (g2[key] - fullgrad[key])) wtemp = copy.deepcopy(networks['SVRG'].params) w = copy.deepcopy(networks['SVRG'].params) loss = networks['SVRG'].loss(x_batch, t_batch) # 获得SVRG训练误差 train_loss['SVRG'].append(loss) # 存储SVRG训练误差 ``` 能有人帮我彻底解决吗，急需

opencv实现边缘梯度直方图+meanshift实现框选物体跟踪，代码出错，不知道错在哪里？

Isabella's Message 的编写和设计
Problem Description Isabella and Steve are very good friends, and they often write letters to each other. They exchange funny experiences, talk about people around, share their feelings and write about almost everything through the letters. When the letters are delivered, they are quite afraid that some other people(maybe their parents) would peek. So they encrypted the letter, and only they know how to decrypt it. This guarantees their privacy. The encrypted message is an N * N matrix, and each grid contains a character. Steve uses a special mask to work as a key. The mask is N * N(where N is an even number) matrix with N*N/4 holes of size 1 * 1 on it. The decrypt process consist of the following steps: 1. Put the mask on the encrypted message matrix 2. Write down the characters you can see through the holes, from top to down, then from left to right. 3. Rotate the mask by 90 degrees clockwise. 4. Go to step 2, unless you have wrote down all the N*N characters in the message matrix. 5. Erase all the redundant white spaces in the message. For example, you got a message shown in figure 1, and you have a mask looks like figure 2. The decryption process is shown in figure 3, and finally you may get a message "good morning". You can assume that the mask is always carefully chosen that each character in the encrypted message will appear exactly once during decryption. However, in the first step of decryption, there are several ways to put the mask on the message matrix, because the mask can be rotated (but not flipped). So you may get different results such as "od morning go" (as showed in figure 4), and you may also get other messages like "orning good m", "ng good morni". Steve didn't know which direction of the mask should be chosen at the beginning, but after he tried all possibilities, he found that the message "good morning" is the only one he wanted because he couldn't recognize some words in the other messages. So he will always consider the message he can understand the correct one. Whether he can understand a message depends whether he knows all the words in the message. If there are more than one ways to decrypt the message into an understandable one, he will choose the lexicographically smallest one. The way to compare two messages is to compare the words of two messages one by one, and the first pair of different words in the two messages will determine the lexicographic order of them. Isabella sends letters to Steve almost every day. As decrypting Isabella's message takes a lot of time, and Steve can wait no longer to know the content of the message, he asked you for help. Now you are given the message he received, the mask, and the list of words he already knew, can you write a program to help him decrypt it? Input The first line contains an integer T(1 <= T <= 100), indicating the number of test cases. Each test case contains several lines. The first line contains an even integer N(2 <= N <= 50), indicating the size of the matrix. The following N lines each contains exactly N characters, reresenting the message matrix. The message only contains lowercase letters and periods('.'), where periods represent the white spaces. You can assume the matrix contains at least one letter. The followingN lines each containsN characters, representing the mask matrix. The asterisk('*') represents a hole, and period('.') otherwise. The next line contains an integer M(1 <= M <= 100), the number of words he knew. Then the following M lines each contains a string represents a word. The words only contain lowercase letters, and its length will not exceed 20. Output For each test case in the input, print one line: "Case #X: Y", where X is the test case number (starting with 1) and Y is Isabella's message. If Steve cannot understand the message, just print the Y as "FAIL TO DECRYPT". Sample Input 3 4 o.do .ng. grmn o.i. .*.. *.*. .... *... 2 good morning 4 ..lf eoyv oeou vrer ..*. .*.. .... *.*. 5 i you the love forever 4 .sle s.c. e.fs ..uu *... .*.. ...* ..*. 1 successful Sample Output Case #1: good morning Case #2: love you forever Case #3: FAIL TO DECRYPT
cuda一个global函数里调用多个核函数出问题。
caffe编写loss层时， 我一个global函数里有多个核函数，但是有时前两个核函数不执行，有时候又执行，不清楚问题出在哪里？ ``` template <typename Dtype> void PixelClustingLossLayer<Dtype>::Forward_gpu( const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) { const int num = bottom[0]->num(); const int data_channels = bottom[0]->channels(); const int mask_channels = bottom[1]->channels(); const int height = bottom[0]->height(); const int width = bottom[0]->width(); const int spatial_dim = height * width; const int nc = num * data_channels; const int data_count = bottom[0]->count(); const int mask_count = bottom[1]->count(); Dtype* pos_num_data = pos_num_.mutable_cpu_data(); Dtype* neg_num_data = neg_num_.mutable_cpu_data(); caffe_gpu_set(mask_count, Dtype(0.), pixel_mask_.mutable_gpu_data()); caffe_gpu_set(num, Dtype(0.), loss_mask_.mutable_gpu_data()); caffe_gpu_set(num*data_channels, Dtype(0.), pos_ave_.mutable_gpu_data()); caffe_gpu_set(num*data_channels, Dtype(0.), neg_ave_.mutable_gpu_data()); caffe_gpu_set(num, Dtype(0.), pos_loss_.mutable_gpu_data()); caffe_gpu_set(num, Dtype(0.), neg_loss_.mutable_gpu_data()); caffe_gpu_set(num, Dtype(0.), center_loss_.mutable_gpu_data()); for(int n=0; n<num; ++n) { caffe_gpu_asum(spatial_dim, bottom[1]->gpu_data() + n * spatial_dim, pos_num_.mutable_cpu_data() + n); neg_num_data[n] = spatial_dim - pos_num_data[n]; } //LOG(INFO)<<"There are "<<pos_num_.cpu_data()[0]<<" pos pixels and "<<neg_num_.cpu_data()[0]<<" neg pixels."; GetTotalValue<Dtype> <<<CAFFE_GET_BLOCKS(data_count), CAFFE_CUDA_NUM_THREADS>>>(data_count, bottom[0]->gpu_data(), bottom[1]->gpu_data(), pos_ave_.mutable_gpu_data(), neg_ave_.mutable_gpu_data(), data_channels, height, width); //LOG(INFO)<<"There are 111 neg pixels."; GetAveValue<Dtype> <<<CAFFE_GET_BLOCKS(nc), CAFFE_CUDA_NUM_THREADS>>>(nc, pos_num_.gpu_data(), neg_num_.gpu_data(), pos_ave_.mutable_gpu_data(), neg_ave_.mutable_gpu_data(), center_loss_.mutable_gpu_data(), data_channels); //LOG(INFO)<<"There are 222 neg pixels."; PowerEuclideanDistance<Dtype> <<<CAFFE_GET_BLOCKS(mask_count), CAFFE_CUDA_NUM_THREADS>>>(mask_count, bottom[0]->gpu_data(), bottom[1]->gpu_data(), pos_ave_.gpu_data(), neg_ave_.gpu_data(), euclidean_dis_.mutable_gpu_data(), mask_channels, data_channels, height, width); ComputePixelLoss<Dtype> <<<CAFFE_GET_BLOCKS(mask_count), CAFFE_CUDA_NUM_THREADS>>>(mask_count, bottom[1]->gpu_data(), euclidean_dis_.gpu_data(), pos_loss_.mutable_gpu_data(), neg_loss_.mutable_gpu_data(), pos_num_.gpu_data(), neg_num_.gpu_data(), pixel_mask_.mutable_gpu_data(), mask_channels, height, width, alpha_); ComputeClassLoss<Dtype> <<<CAFFE_GET_BLOCKS(num), CAFFE_CUDA_NUM_THREADS>>>(num, center_loss_.mutable_gpu_data(), loss_mask_.mutable_gpu_data(), beta_); caffe_gpu_add(num, neg_loss_.gpu_data(), pos_loss_.gpu_data(), loss_.mutable_gpu_data()); caffe_gpu_add(num, loss_.gpu_data(), center_loss_.gpu_data(), loss_.mutable_gpu_data()); Dtype loss; caffe_gpu_asum(num, loss_.gpu_data(), &loss); LOG(INFO)<<loss/Dtype(num); top[0]->mutable_cpu_data()[0] = loss / num; } ``` 主要是GetTotalValue()函数和GetAveValue()函数，偶尔执行，偶尔不执行，头都晕了。 有没有大神指点迷津。
zero-size array to reduction operation minimum which has no identity
pthon报错：zero-size array to reduction operation minimum which has no identity请问这是为什么 原代码如下： dataWOE = data[short_list_2] corr = round(dataWOE.corr(),2) mask = np.zeros_like(corr, dtype=np.bool) mask[np.triu_indices_from(mask)] = True plt.figure(figsize = (5, 5)) cmap = sns.diverging_palette(220, 10, as_cmap=True) sns.heatmap(corr, mask=mask, cmap=cmap, center=0, annot =True, cbar_kws={"shrink": .5}) plt.show()

Isabella's Message 程序的代码的过程
Problem Description Isabella and Steve are very good friends, and they often write letters to each other. They exchange funny experiences, talk about people around, share their feelings and write about almost everything through the letters. When the letters are delivered, they are quite afraid that some other people(maybe their parents) would peek. So they encrypted the letter, and only they know how to decrypt it. This guarantees their privacy. The encrypted message is an N * N matrix, and each grid contains a character. Steve uses a special mask to work as a key. The mask is N * N(where N is an even number) matrix with N*N/4 holes of size 1 * 1 on it. The decrypt process consist of the following steps: 1. Put the mask on the encrypted message matrix 2. Write down the characters you can see through the holes, from top to down, then from left to right. 3. Rotate the mask by 90 degrees clockwise. 4. Go to step 2, unless you have wrote down all the N*N characters in the message matrix. 5. Erase all the redundant white spaces in the message. For example, you got a message shown in figure 1, and you have a mask looks like figure 2. The decryption process is shown in figure 3, and finally you may get a message "good morning". You can assume that the mask is always carefully chosen that each character in the encrypted message will appear exactly once during decryption. However, in the first step of decryption, there are several ways to put the mask on the message matrix, because the mask can be rotated (but not flipped). So you may get different results such as "od morning go" (as showed in figure 4), and you may also get other messages like "orning good m", "ng good morni". Steve didn't know which direction of the mask should be chosen at the beginning, but after he tried all possibilities, he found that the message "good morning" is the only one he wanted because he couldn't recognize some words in the other messages. So he will always consider the message he can understand the correct one. Whether he can understand a message depends whether he knows all the words in the message. If there are more than one ways to decrypt the message into an understandable one, he will choose the lexicographically smallest one. The way to compare two messages is to compare the words of two messages one by one, and the first pair of different words in the two messages will determine the lexicographic order of them. Isabella sends letters to Steve almost every day. As decrypting Isabella's message takes a lot of time, and Steve can wait no longer to know the content of the message, he asked you for help. Now you are given the message he received, the mask, and the list of words he already knew, can you write a program to help him decrypt it? Input The first line contains an integer T(1 <= T <= 100), indicating the number of test cases. Each test case contains several lines. The first line contains an even integer N(2 <= N <= 50), indicating the size of the matrix. The following N lines each contains exactly N characters, reresenting the message matrix. The message only contains lowercase letters and periods('.'), where periods represent the white spaces. You can assume the matrix contains at least one letter. The followingN lines each containsN characters, representing the mask matrix. The asterisk('*') represents a hole, and period('.') otherwise. The next line contains an integer M(1 <= M <= 100), the number of words he knew. Then the following M lines each contains a string represents a word. The words only contain lowercase letters, and its length will not exceed 20. Output For each test case in the input, print one line: "Case #X: Y", where X is the test case number (starting with 1) and Y is Isabella's message. If Steve cannot understand the message, just print the Y as "FAIL TO DECRYPT". Sample Input 3 4 o.do .ng. grmn o.i. .*.. *.*. .... *... 2 good morning 4 ..lf eoyv oeou vrer ..*. .*.. .... *.*. 5 i you the love forever 4 .sle s.c. e.fs ..uu *... .*.. ...* ..*. 1 successful Sample Output Case #1: good morning Case #2: love you forever Case #3: FAIL TO DECRYPT
Unrecognized or unsupported array type in function 'cvGetMat'问题
``` import numpy as np import cv2 img = cv2.imread('messi_2.jpg') mask = cv2.imread('mask2.png',0) dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA) cv2.imshow('dst',dst) cv2.waitKey(0) cv2.destroyAllWindows() ``` (base) C:\Users\lenovo>D:/anaconda/python.exe e:/Desktop/test/test.py Traceback (most recent call last): File "e:/Desktop/test/test.py", line 7, in <module> dst = cv2.inpaint(img,mask,3,cv2.INPAINT_TELEA) cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\core\src\array.cpp:2492: error: (-206:Bad flag (parameter or structure field)) Unrecognized or unsupported array type in function 'cvGetMat' 最终结果这样，哪里错了啊

Java 中Robot类的mouseMove不能正确移动

coherent DMA mask is unset.unable to allocate contiguous DMA memory region of size 4096

Java学习的正确打开方式

linux系列之常用运维命令整理笔录

Python十大装B语法
Python 是一种代表简单思想的语言，其语法相对简单，很容易上手。不过，如果就此小视 Python 语法的精妙和深邃，那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点，并附上详细的实例代码。如能在实战中融会贯通、灵活使用，必将使代码更为精炼、高效，同时也会极大提升代码B格，使之看上去更老练，读起来更优雅。

2019年11月中国大陆编程语言排行榜
2019年11月2日，我统计了某招聘网站，获得有效程序员招聘数据9万条。针对招聘信息，提取编程语言关键字，并统计如下： 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...

《奇巧淫技》系列-python！！每天早上八点自动发送天气预报邮件到QQ邮箱

SQL-小白最佳入门sql查询一

redis分布式锁，面试官请随便问，我都会

Nginx 原理和架构
Nginx 是一个免费的，开源的，高性能的 HTTP 服务器和反向代理，以及 IMAP / POP3 代理服务器。Nginx 以其高性能，稳定性，丰富的功能，简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求，主要负责调度工作进程：加载配置、启动工作进程及非停升级。worker 进程负责处...
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言，也有很多实用的方法，有时候实现一个功能可以用多种方法实现，我这里总结了一些常用的方法和技巧，包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等，会持续更新......
Idon’t know what that dream is that you have, I don't care how disappointing it might have been as you've been working toward that dream,but that dream that you’re holding in your mind, that it’s po...
“狗屁不通文章生成器”登顶GitHub热榜，分分钟写出万字形式主义大作

《程序人生》系列-这个程序员只用了20行代码就拿了冠军

11月8日，由中国信息通信研究院、中国通信标准化协会、中国互联网协会、可信区块链推进计划联合主办，科技行者协办的2019可信区块链峰会将在北京悠唐皇冠假日酒店开幕。 　　区块链技术被认为是继蒸汽机、电力、互联网之后，下一代颠覆性的核心技术。如果说蒸汽机释放了人类的生产力，电力解决了人类基本的生活需求，互联网彻底改变了信息传递的方式，区块链作为构造信任的技术有重要的价值。 　　1...
Java世界最常用的工具类库
Apache Commons Apache Commons有很多子项目 Google Guava 参考博客