最近只能记得七秒内的东西,七秒外的东西要在此记录一下!
大文件存储mat
当要存储的mat
文件过大时:
1
| save(path , ‘X_all’ ,’-v7.3’ )
|
python
大文件mat
读取
对于-v7.3
存储的mat
文件一般这么读
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import h5py dict_data = h5py.File(X_all.mat)
print(dict_data.keys())
print(dict_data.values())
data = dict_data['X_all'] print(data.shape)
data_t = np.transpose(data)
np.save('X_all.npy', data_t)
matrix = np.load(X_all.npy')
|
非-v7.3
存储的mat
文件这么读就行,这里直接存成了tensor
了。
1 2 3 4 5 6 7 8
| h=r'D:\a\薛事成同步文件\我的坚果云\波场反演+NN\2D_file\energy_file\FT_Signal_0.mat'
mat_dict = scio.loadmat(path)
data_name_1 = 'FT_Signal_A_real'
FT_Signal_A_real = torch.tensor(mat_dict[data_name_1])
|
清GPU
内存
1 2
| import torch torch.cuda.empty_cache()
|
大文件txt
的matlab读取
1 2 3 4 5 6 7
| file=fullfile('F:\Xue\result_pic\Untitle_119_3\log.txt');
f=fopen(file);
dt=textscan(f,repmat('%f',1,9));
fclose(f)
|
MATLAB
滑动平均法
MATLAB
设置图例的位置
1 2 3 4 5
| h = legend('真实缺陷','生成缺陷形状'); pos = get(h,'Position'); pos(1) = pos(1)+0.053; pos(2) = pos(2)+0.1; set(h,'Position',pos)
|
MATLAB
保存图片
1
| saveas(gcf,[path,'.png'])
|
MATLAB
设置图中小网格
1 2 3 4 5
| set(gca,'XMinorGrid','on') set(gca,'YMinorGrid','on') set(gca,'Gridalpha',0.2,'MinorGridalpha',0.1,'MinorGridLineStyle','-') set(gcf,'unit','centimeters','position',[10,5,10,6.6]) xlabel('Training iteration', 'Fontname', 'Times New Roman');
|
MATLAB
设置添加噪声的信号比
1
| x_noise = awgn(x,snr,'measured')
|
首先计算输入x
信号的功率,按照snr
添加相应功率的高斯白噪声。
MATLAB
绘制灰度图并保存
1 2 3 4
| figure imshow(A); imwrite(A,[path,'_true.png'])
|
MATLAB
设置傅里叶变换方向
MATLAB
去掉x或y轴刻度
1 2 3
| set(gca,’xtick’,[]) set(gca,’ytick’,[]) set(gca,’xtick’,[],’ytick’,[])
|