比方说,我有一个数据帧df作为
A B
1 V2
3 W42
1 S03
2 T02
3 U71
Run Code Online (Sandbox Code Playgroud)
我想要一个新的列(在它的末尾df或B用它替换列,因为它无关紧要)只从列中提取int B.那是我想要列C看起来像
C
2
42
3
2
71
Run Code Online (Sandbox Code Playgroud)
所以如果数字前面有一个0,比如03,那么我想返回3而不是03
我怎样才能做到这一点?
我有一个看起来像的训练集
Name Day Area X Y Month Night
ATTACK Monday LA -122.41 37.78 8 0
VEHICLE Saturday CHICAGO -1.67 3.15 2 0
MOUSE Monday TAIPEI -12.5 3.1 9 1
Run Code Online (Sandbox Code Playgroud)
Name是结果/因变量.我转换Name,Area并Day为因素,但我不知道我是否应该为Month和Night,只取整数值1-12和0-1分别.
然后我将数据转换为矩阵
ynn <- model.matrix(~Name , data = trainDF)
mnn <- model.matrix(~ Day+Area +X + Y + Month + Night, data = trainDF)
Run Code Online (Sandbox Code Playgroud)
然后我设置调整参数
nnTrControl=trainControl(method = "repeatedcv",number = 3,repeats=5,verboseIter = TRUE, returnData = FALSE, returnResamp = "all", classProbs = TRUE, …Run Code Online (Sandbox Code Playgroud) 我试图做import segmentation_models as sm,但我收到一个错误,说efficientnet没有找到。所以我做了pip install efficientnet并再次尝试。我现在得到了ModuleNotFoundError: no module named efficientnet.tfkeras,即使安装了 Keras,因为我可以from keras.models import *使用 Keras 或其他任何东西
我怎样才能摆脱这个错误?
我正在开发一个可以在另一台计算机(第一台)上运行的程序,并试图让它在我的新计算机(第三台)上运行。当我转到build并键入时ccmake ..,出现此错误:
CMake Error at build/share/cmake/hdf5/hdf5-targets.cmake:67 (message):
The imported target "hdf5" references the file
"/home/myname/Desktop/MyProject/build/lib/libhdf5.a"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/home/myname/Desktop/MyProject/build/share/cmake/hdf5/h
df5-targets.cmake"
but not all the files it references.
Call Stack (most recent call first):
build/share/cmake/hdf5/hdf5-config.cmake:70 (INCLUDE)
build/share/cmake/hdf5/FindHDF5.cmake:85 (INCLUDE)
src/Thing/CMakeLists.txt:66 (find_package)
Run Code Online (Sandbox Code Playgroud)
即使我随后使用 sudo …
我有L:
Var1 Freq
2 1103 6
6 1107 10
10 1112 7
21 1125 6
24 1129 10
31 1137 5
Run Code Online (Sandbox Code Playgroud)
并且pct:
head(pct)
[1] 0.806 0.706 0.781 0.800 0.655 0.844
Run Code Online (Sandbox Code Playgroud)
pct 最初是数字,而不是因素:
str(pct)
num [1:68] 0.806 0.706 0.781 0.8 0.655 0.844
Run Code Online (Sandbox Code Playgroud)
但是,一旦我结合L,并pct连同
pct_by <- as.data.frame(cbind(as.vector(L$Var1), pct))
Run Code Online (Sandbox Code Playgroud)
我看到这个新的数据帧pct_by包含pct因子,如下所示:
str(pct_by
'data.frame': 68 obs. of 2 variables:
$ V1: Factor w/ 68 levels "1103","1107",..: 1 2 3 4 5 6 7 …Run Code Online (Sandbox Code Playgroud) 我知道original_image * filter = blur_image,*卷积在哪里。因此,filter = ifft(fft(blur)/fft(original))
我有一个原始图像、已知的滤镜和已知的模糊图像。我尝试了以下代码。我只想比较使用 fft 和 ifft 计算的滤波器,并将其与已知的滤波器进行比较。我在Matlab中尝试过:
orig = imread("orig.png")
blur = imread("blur.png")
fftorig = fft(orig)
fftblur = fft(blur)
div = fftblur/fftorig
conv = ifft(div)
Run Code Online (Sandbox Code Playgroud)
结果没有意义。我看到div包含很多NaN值,并且fftblur和fftorig都包含很多 0 值。我需要对此做些什么吗?比如使用fftshift?
编辑:为了使这一点更容易理解,我现在使用以下图像: http: //matlabgeeks.com/tips-tutorials/how-to-blur-an-image-with-a-fourier-transform-in- matlab-第一部分/
我决定使用以下链接计算origimage和的内核:blurimageunpad
kernelc = real(ifft2(fft2(origimage)./fft2(blurimageunpad));
imagesc(kernelc)
colormap gray
Run Code Online (Sandbox Code Playgroud)
结果如下:
https://i.stack.imgur.com/kJavg.jpg
这显然与该链接顶部提到的高斯模糊不匹配
我有
std::vector<double>x={1,2,NAN,3, NAN, 4}
Run Code Online (Sandbox Code Playgroud)
当我尝试x.erase(remove(x.begin(), x.end(), NAN), x.end(),我仍然看到NAN作为
for (auto i:x)
std::cout<<i<<" ";
Run Code Online (Sandbox Code Playgroud)
给
1 2 -nan(ind) 3 -nan(ind) 4
Run Code Online (Sandbox Code Playgroud)
如何删除NAN,所以输出如下?
1 2 3 4
Run Code Online (Sandbox Code Playgroud)
编辑:x是双精度的向量,而不是整数
如果我有张量v,w我知道你们可以一起乘他们
a = Multiply()([v, w])
Run Code Online (Sandbox Code Playgroud)
但是,如果我想乘v或w标量怎么办?
假设我有一个大矩阵A:
A = rand(10000,10000);
Run Code Online (Sandbox Code Playgroud)
以下串行代码耗时约0.5秒
tic
for i=1:5
r=9999*rand(1);
disp(A(round(r)+1, round(r)+1))
end
toc
Run Code Online (Sandbox Code Playgroud)
而使用parfor的以下代码耗时约47秒
tic
parfor i=1:5
r=9999*rand(1);
disp(A(round(r)+1, round(r)+1))
end
toc
Run Code Online (Sandbox Code Playgroud)
如何加快parfor代码的速度?
编辑:如果不是使用disp,我尝试使用以下代码计算总和
sum=0;
tic
for i=1:5000
r=9999*rand(1);
sum=sum+(A(round(r)+1, round(r)+1));
end
toc
Run Code Online (Sandbox Code Playgroud)
这需要0.025秒
但是parfor需要42.5秒:
tic
parfor i=1:5000
r=9999*rand(1);
sum=sum+(A(round(r)+1, round(r)+1));
end
toc
Run Code Online (Sandbox Code Playgroud) 我有一张原始图片:
我然后阅读它,创建一个PSF,并在Matlab中模糊它:
lenawords1=imread('lenawords.bmp');
%create PSF
sigma=6;
PSFgauss=fspecial('gaussian', 8*sigma+1, sigma);
%blur it
lenablur1=imfilter(lenawords1, PSFgauss, 'conv');
lenablurgray1=mat2gray(lenablur1);
PSFgaussgray = mat2gray(PSFgauss);
Run Code Online (Sandbox Code Playgroud)
我保存了模糊的图像:
imwrite(lenablurgray1, 'lenablur.bmp');
Run Code Online (Sandbox Code Playgroud)
当我在其中显示一些值时,我得到了
disp(lenablurgray1(91:93, 71:75))
0.5556 0.5778 0.6000 0.6222 0.6444
0.6000 0.6444 0.6667 0.6889 0.6889
0.6444 0.6889 0.7111 0.7333 0.7333
Run Code Online (Sandbox Code Playgroud)
然后,我在OpenCV中打开该模糊图像,并在相同的索引处显示其值:
Mat img = imread("lenablur.bmp");
for (int r = 91; r < 94; r++) {
for (int c = 71; c < 76; c++) {
cout << img.at<double>(r, c) << " ";
}
cout << endl;
}
cout << endl;
Run Code Online (Sandbox Code Playgroud)
我得到的结果与上面的值不匹配: …