|
- import torch
- from torch import nn, einsum
- import torch.nn.functional as F
- from sklearn.metrics import mean_squared_error
- from torch.utils.data import Dataset, DataLoader
- import random
- import numpy as np
- from einops import rearrange, repeat
- from einops.layers.torch import Rearrange
- from torch.nn import Flatten
- from tqdm import tqdm
-
-
- class DoubleConvDS(nn.Module):
- """(convolution => [BN] => ReLU) * 2"""
-
- def __init__(self, in_channels, out_channels, mid_channels=None, kernels_per_layer=1):
- super().__init__()
- if not mid_channels:
- mid_channels = out_channels
- self.double_conv = nn.Sequential(
- DepthwiseSeparableConv(in_channels, mid_channels, kernel_size=3, kernels_per_layer=kernels_per_layer, padding=1),
- nn.BatchNorm2d(mid_channels),
- nn.ReLU(inplace=True),
- DepthwiseSeparableConv(mid_channels, out_channels, kernel_size=3, kernels_per_layer=kernels_per_layer, padding=1),
- nn.BatchNorm2d(out_channels),
- nn.ReLU(inplace=True)
- )
-
- def forward(self, x):
- return self.double_conv(x)
-
-
- class DoubleConv(nn.Sequential):
- def __init__(self, in_channels, out_channels, mid_channels=None):
- if mid_channels is None:
- mid_channels = out_channels
- super(DoubleConv, self).__init__(
- nn.Conv2d(in_channels, mid_channels, kernel_size=3, padding=1, bias=False),
- nn.BatchNorm2d(mid_channels),
- nn.ReLU(inplace=True),
- nn.Conv2d(mid_channels, out_channels, kernel_size=3, padding=1, bias=False),
- nn.BatchNorm2d(out_channels),
- nn.ReLU(inplace=True)
- )
-
- class Down(nn.Sequential):
- def __init__(self, in_channels, out_channels):
- super(Down, self).__init__(
- nn.MaxPool2d(2, stride=2),
- DoubleConvDS(in_channels, out_channels)
- )
-
- class Up(nn.Module):
- def __init__(self, in_channels, out_channels, bilinear=True):
- super(Up, self).__init__()
- if bilinear:
- self.up = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True)
- self.conv = DoubleConvDS(in_channels, out_channels, in_channels // 2)
- else:
- self.up = nn.ConvTranspose2d(in_channels, in_channels // 2, kernel_size=2, stride=2)
- self.conv = DoubleConvDS(in_channels, out_channels)
-
- def forward(self, x1: torch.Tensor, x2: torch.Tensor) -> torch.Tensor:
- x1 = self.up(x1)
- # [N, C, H, W]
- diff_y = x2.size()[2] - x1.size()[2]
- diff_x = x2.size()[3] - x1.size()[3]
-
- # padding_left, padding_right, padding_top, padding_bottom
- x1 = F.pad(x1, [diff_x // 2, diff_x - diff_x // 2,
- diff_y // 2, diff_y - diff_y // 2])
-
- x = torch.cat([x2, x1], dim=1)
- x = self.conv(x)
- return x
-
- class OutConv(nn.Sequential):
- def __init__(self, in_channels, num_classes):
- super(OutConv, self).__init__(
- nn.Conv2d(in_channels, num_classes, kernel_size=1)
- )
-
- class ChannelAttention(nn.Module):
- def __init__(self, input_channels, reduction_ratio=16):
- super(ChannelAttention, self).__init__()
- self.input_channels = input_channels
- self.avg_pool = nn.AdaptiveAvgPool2d(1)
- self.max_pool = nn.AdaptiveMaxPool2d(1)
- # https://github.com/luuuyi/CBAM.PyTorch/blob/master/model/resnet_cbam.py
- # uses Convolutions instead of Linear
- self.MLP = nn.Sequential(
- Flatten(),
- nn.Linear(input_channels, input_channels // reduction_ratio),
- nn.ReLU(),
- nn.Linear(input_channels // reduction_ratio, input_channels)
- )
-
- def forward(self, x):
- # Take the input and apply average and max pooling
- avg_values = self.avg_pool(x)
- max_values = self.max_pool(x)
- out = self.MLP(avg_values) + self.MLP(max_values)
- scale = x * torch.sigmoid(out).unsqueeze(2).unsqueeze(3).expand_as(x)
- return scale
-
-
- class SpatialAttention(nn.Module):
- def __init__(self, kernel_size=7):
- super(SpatialAttention, self).__init__()
- assert kernel_size in (3, 7), 'kernel size must be 3 or 7'
- padding = 3 if kernel_size == 7 else 1
- self.conv = nn.Conv2d(2, 1, kernel_size=kernel_size, padding=padding, bias=False)
- self.bn = nn.BatchNorm2d(1)
-
- def forward(self, x):
- avg_out = torch.mean(x, dim=1, keepdim=True)
- max_out, _ = torch.max(x, dim=1, keepdim=True)
- out = torch.cat([avg_out, max_out], dim=1)
- out = self.conv(out)
- out = self.bn(out)
- scale = x * torch.sigmoid(out)
- return scale
-
-
- class CBAM(nn.Module):
- def __init__(self, input_channels, reduction_ratio=16, kernel_size=7):
- super(CBAM, self).__init__()
- self.channel_att = ChannelAttention(input_channels, reduction_ratio=reduction_ratio)
- self.spatial_att = SpatialAttention(kernel_size=kernel_size)
-
- def forward(self, x):
- out = self.channel_att(x)
- out = self.spatial_att(out)
- return out
-
- #深度可分离卷积
- class DepthwiseSeparableConv(nn.Module):
- def __init__(self, in_channels, output_channels, kernel_size, padding=0, kernels_per_layer=1):
- super(DepthwiseSeparableConv, self).__init__()
- # In Tensorflow DepthwiseConv2D has depth_multiplier instead of kernels_per_layer
- self.depthwise = nn.Conv2d(in_channels, in_channels * kernels_per_layer, kernel_size=kernel_size,
- padding=padding,
- groups=in_channels)
- self.pointwise = nn.Conv2d(in_channels * kernels_per_layer, output_channels, kernel_size=1)
-
- def forward(self, x):
- x = self.depthwise(x)
- x = self.pointwise(x)
- return x
-
-
- class SmaAt_UNet(nn.Module):
- def __init__(self, n_channels = 175, n_classes = 69, kernels_per_layer=2, bilinear=True, reduction_ratio=16):
- super(SmaAt_UNet, self).__init__()
- self.n_channels = n_channels
- self.n_classes = n_classes
- kernels_per_layer = kernels_per_layer
- self.bilinear = bilinear
- reduction_ratio = reduction_ratio
-
- self.inc = DoubleConvDS(self.n_channels, 64)
- self.cbam1 = CBAM(64, reduction_ratio=reduction_ratio)
- self.down1 = Down(64, 128)
- self.cbam2 = CBAM(128, reduction_ratio=reduction_ratio)
- self.down2 = Down(128, 256)
- self.cbam3 = CBAM(256, reduction_ratio=reduction_ratio)
- self.down3 = Down(256, 512)
- self.cbam4 = CBAM(512, reduction_ratio=reduction_ratio)
- factor = 2 if self.bilinear else 1
- self.down4 = Down(512, 1024 // factor)
- self.cbam5 = CBAM(1024 // factor, reduction_ratio=reduction_ratio)
- self.up1 = Up(1024, 512 // factor, self.bilinear)
- self.up2 = Up(512, 256 // factor, self.bilinear)
- self.up3 = Up(256, 128 // factor, self.bilinear)
- self.up4 = Up(128, 64, self.bilinear)
-
- self.outc = OutConv(64, self.n_classes)
-
- def forward(self, x):
- b, c, t1, h, w = x.size()
- x = x.reshape(b, t1 * c, h, w)
- x1 = self.inc(x)
- x1Att = self.cbam1(x1)
- x2 = self.down1(x1)
- x2Att = self.cbam2(x2)
- x3 = self.down2(x2)
- x3Att = self.cbam3(x3)
- x4 = self.down3(x3)
- x4Att = self.cbam4(x4)
- x5 = self.down4(x4)
- x5Att = self.cbam5(x5)
- x = self.up1(x5Att, x4Att)
- x = self.up2(x, x3Att)
- x = self.up3(x, x2Att)
- x = self.up4(x, x1Att)
- logits = self.outc(x)
- logits = logits.reshape(b, 69, h, w)
- return logits
-
-
- # 判断t是否是元组,如果是,直接返回t;如果不是,则将t复制为元组(t, t)再返回
- # 用来处理当给出的图像尺寸或块尺寸是int类型(如224)时,直接返回为同值元组(如(224, 224))
- def pair(t):
- return t if isinstance(t, tuple) else (t, t)
-
-
- # PreNorm
- class PreNorm(nn.Module):
- def __init__(self, dim, fn):
- super().__init__()
- self.norm = nn.LayerNorm(dim)
- self.fn = fn
- def forward(self, x, **kwargs):
- return self.fn(self.norm(x), **kwargs)
-
-
-
- # Feedforward
-
- class FeedForward(nn.Module):
- def __init__(self, dim, hidden_dim, dropout=0.):
- super().__init__()
- self.net = nn.Sequential(
- nn.Linear(dim, hidden_dim),
- nn.GELU(),
- nn.Dropout(dropout),
- nn.Linear(hidden_dim, dim),
- nn.Dropout(dropout)
- )
- def forward(self, x):
- return self.net(x)
-
-
- #attention
-
- class Attention(nn.Module):
- def __init__(self, dim, heads=8, dim_head=64, dropout=0.):
- super().__init__()
- inner_dim = dim_head * heads
- project_out = not (heads == 1 and dim_head == dim)
-
- self.heads = heads
- self.scale = dim_head ** -0.5
-
- self.attend = nn.Softmax(dim=-1)
- self.to_qkv = nn.Linear(dim, inner_dim * 3, bias=False)
-
- self.to_out = nn.Sequential(
- nn.Linear(inner_dim, dim),
- nn.Dropout(dropout),
- ) if project_out else nn.Identity()
-
- def forward(self, x):
- b, n, _, h = *x.shape, self.heads
- qkv = self.to_qkv(x).chunk(3, dim=-1) # (b, n(65), dim*3) ---> 3 * (b, n, dim)
- q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), qkv) # q, k, v (b, h, n, dim_head(64))
-
- dots = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
-
- attn = self.attend(dots)
-
- out = einsum('b h i j, b h j d -> b h i d', attn, v)
- out = rearrange(out, 'b h n d -> b n (h d)')
- return self.to_out(out)
-
-
- # Transformet
-
- class Transformer(nn.Module):
- def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout=0.):
- super().__init__()
- self.layers = nn.ModuleList([])
- for _ in range(depth):
- self.layers.append(nn.ModuleList([
- PreNorm(dim, Attention(dim, heads=heads, dim_head=dim_head, dropout=dropout)),
- PreNorm(dim, FeedForward(dim, mlp_dim, dropout=dropout))
- ]))
-
- def forward(self, x):
- for attn, ff in self.layers:
- x = attn(x) + x
- x = ff(x) + x
- return x
-
-
- #VIT
- class ViT(nn.Module):
- def __init__(self, *, image_size, patch_size, num_classes, dim, depth, heads, mlp_dim, pool='cls', channels=3, dim_head=64, dropout=0., emb_dropout=0.):
- super().__init__()
- image_height, image_width = pair(image_size) # 8 8
- patch_height, patch_width = pair(patch_size) # 32 32
-
- assert image_height % patch_height ==0 and image_width % patch_width == 0
-
- num_patches = (image_height // patch_height) * (image_width // patch_width)
-
- patch_dim = channels * patch_height * patch_width
- assert pool in {'cls', 'mean'}
-
- # self.to_patch_embedding = nn.Sequential(
- # Rearrange('b c (h p1) (w p2) -> b (h w) (p1 p2 c)', p1=patch_height, p2=patch_width),
- # nn.Linear(patch_dim, dim)
- # )
-
- self.pos_embedding = nn.Parameter(torch.randn(1, num_patches+1, dim))
- self.cls_token = nn.Parameter(torch.randn(1, 1, dim)) # nn.Parameter()定义可学习参数
- self.dropout = nn.Dropout(emb_dropout)
-
- self.transformer = Transformer(dim, depth, heads, dim_head, mlp_dim, dropout)
-
- self.pool = pool
- self.to_latent = nn.Identity()
-
- self.mlp_head = nn.Sequential(
- nn.LayerNorm(dim),
- nn.Linear(dim, num_classes)
- )
- self.lst = nn.LayerNorm(dim)
-
- self.unet = SmaAt_UNet()
-
- def forward(self, x):
- x = self.unet(x)
- # print(x.shape)
- b, c, h, w = x.size()
- x = x.reshape(b, c, h*w)
- # print(x.shape)
- # x = self.to_patch_embedding(img) # b c (h p1) (w p2) -> b (h w) (p1 p2 c) -> b (h w) dim ##(16,64,3072) ---> (16,64,1024)
- b, n, _ = x.shape # b表示batchSize, n表示每个块的空间分辨率, _表示一个块内有多少个值 #batch=16 n=64 _=1024
-
- cls_tokens = repeat(self.cls_token, '() n d -> b n d', b=b) # self.cls_token: (1, 1, dim) -> cls_tokens: (batchSize, 1, dim)
- # print('cls_tokens.shape:{}'.format(cls_tokens.shape)) #([16, 1, 1024])
- x = torch.cat((cls_tokens, x), dim=1) # 将cls_token拼接到patch token中去 (b, 65, dim)
- # print('x1.shape:{}'.format(x.shape)) #torch.Size([16, 65, 1024])
- x += self.pos_embedding[:, :(n+1)] # 加位置嵌入(直接加) (b, 65, dim)
- # print('x2.shape:{}'.format(x.shape)) #torch.Size([16, 65, 1024])
- x = self.dropout(x)
- # print('x3.shape:{}'.format(x.shape)) #torch.Size([16, 65, 1024])
-
- x = self.transformer(x) # (b, 65, dim)
- # print('x4.shape:{}'.format(x.shape)) #torch.Size([16, 65, 1024])
-
- # x = x.mean(dim=1) if self.pool == 'mean' else x[:, 0] # (b, dim)
- # print('x.shape:{}'.format(x.shape)) #torch.Size([16, 65, 1024])
-
- x = self.to_latent(x) # Identity (b, dim)
- # print(x.shape)
- # x = self.lst(x)
- # print(x)
- # return self.mlp_head(x) # (b, num_classes)
- return x
-
-
-
-
-
-
- def setup_seed(seed):
- torch.manual_seed(seed)
- torch.cuda.manual_seed_all(seed)
- np.random.seed(seed)
- random.seed(seed)
- torch.backends.cudnn.deterministic = True
-
- for ii in range(1,6):
- for epoch111 in range(100,600,100):
- # 设置随机数种子
- setup_seed(ii)
-
- data = np.load('/dataset/7day_for_Nday_data_openi_09_17_atlantic_area_last.npz')
- print(data.files) # ['hycom_temp', 'slfh', 'sshf', 'ssr', 'str', 'mld', 'analysis_temp', 'u', 'v', 'T_d', 'u_d', 'v_d', 'xx', 'yy']
-
- hycom_temp = data['hycom_temp'][:] # (3281, 7, 7, 41, 201)
- slfh = data['slfh'][:] # (3281, 7, 41, 201)
- sshf = data['sshf'][:] # (3281, 7, 41, 201)
- ssr = data['ssr'][:] # (3281, 7, 41, 201)
- str = data['str'][:] # (3281, 7, 41, 201)
- mld = data['mld'][:] # (3281, 7, 41, 201)
- analysis_temp = data['analysis_temp'][:] # (3281, 7, 7, 41, 201)
- u = data['u'][:] # (3281, 7, 7, 41, 201)
- v = data['v'][:] # (3281, 7, 7, 41, 201)
- T_d = data['T_d'][:] # (3281, 7, 41, 201)
- u_d = data['u_d'][:] # (3281, 7, 41, 201)
- v_d = data['v_d'][:] # (3281, 7, 41, 201)
- xx = data['xx'][:] # (3281, 7, 41, 201)
- yy = data['yy'][:] # (3281, 7, 41, 201)
-
-
- analysis_temp = analysis_temp.transpose(0, 2, 1, 3, 4)
-
- print(analysis_temp.shape) #(3275, 7, 10, 41, 81)
-
- print(hycom_temp.shape) # (3281, 7, 7, 41, 81)
-
-
- train_size = 1952 # 前60%
- valid_size = 2624 # 中间20% 作为验证 剩下的20%的作为测试
-
- Q_net = (slfh + sshf + ssr + str)/86400
-
- # print(Q_net)
- hycom_temp = hycom_temp.transpose(0, 2, 1, 3, 4)
- hycom_temp = hycom_temp.reshape(-1,7,7,41,81)
- hycom_temp = torch.Tensor(hycom_temp)
- hycom_temp_train = hycom_temp[0:train_size,:,:,:,:]
- hycom_temp_valid = hycom_temp[train_size:valid_size,:,:,:,:]
- hycom_temp_test = hycom_temp[valid_size:,:,:,:,:]
-
-
- # slfh = slfh.reshape(-1,1,1,7,41,201)
- # slfh = torch.Tensor(slfh)
- # slfh_train = slfh[0:train_size,:,:,:,:]
- # slfh_valid = slfh[train_size:valid_size,:,:,:,:]
- # slfh_test = slfh[valid_size:,:,:,:,:]
- #
- # sshf = sshf.reshape(-1,1,1,7,41,201)
- # sshf = torch.Tensor(sshf)
- # sshf_train = sshf[0:train_size,:,:,:,:]
- # sshf_valid = sshf[train_size:valid_size,:,:,:,:]
- # sshf_test = sshf[valid_size:,:,:,:,:]
- #
- #
- # ssr = ssr.reshape(-1,1,1,7,41,201)
- # ssr = torch.Tensor(ssr)
- # ssr_train = ssr[0:train_size,:,:,:,:]
- # ssr_valid = ssr[train_size:valid_size,:,:,:,:]
- # ssr_test = ssr[valid_size:,:,:,:,:]
- #
- #
- # str = str.reshape(-1,1,1,7,41,201)
- # str = torch.Tensor(str)
- # str_train = str[0:train_size,:,:,:,:]
- # str_valid = str[train_size:valid_size,:,:,:,:]
- # str_test = str[valid_size:,:,:,:,:]
-
- Q_net = Q_net.reshape(-1,1,7,41,81)
- Q_net = torch.Tensor(Q_net)
- Q_net_train = Q_net[0:train_size,:,:,:,:]
- Q_net_valid = Q_net[train_size:valid_size,:,:,:,:]
- Q_net_test = Q_net[valid_size:,:,:,:,:]
-
-
- mld = mld.reshape(-1,1,7,41,81)
- mld = torch.Tensor(mld)
- mld_train = mld[0:train_size,:,:,:,:]
- mld_valid = mld[train_size:valid_size,:,:,:,:]
- mld_test = mld[valid_size:,:,:,:,:]
-
-
- analysis_temp = analysis_temp.reshape(-1,7,10,41,81)
- analysis_temp = torch.Tensor(analysis_temp)
- # analysis_temp_train = analysis_temp[0:train_size,:,:,:,:]
- # analysis_temp_valid = analysis_temp[train_size:valid_size,:,:,:,:]
- # analysis_temp_test = analysis_temp[valid_size:,:,:,:,:]
-
- u = u.transpose(0, 2, 1, 3, 4)
- u = u.reshape(-1,7,7,41,81)
- u = torch.Tensor(u)
- u_train = u[0:train_size,:,:,:,:]
- u_valid = u[train_size:valid_size,:,:,:,:]
- u_test = u[valid_size:,:,:,:,:]
-
- v = v.transpose(0, 2, 1, 3, 4)
- v = v.reshape(-1,7,7,41,81)
- v = torch.Tensor(v)
- v_train = v[0:train_size,:,:,:,:]
- v_valid = v[train_size:valid_size,:,:,:,:]
- v_test = v[valid_size:,:,:,:,:]
-
-
- T_d = T_d.reshape(-1,1,7,41,81)
- T_d = torch.Tensor(T_d)
- T_d_train = T_d[0:train_size,:,:,:,:]
- T_d_valid = T_d[train_size:valid_size,:,:,:,:]
- T_d_test = T_d[valid_size:,:,:,:,:]
-
-
- u_d = u_d.reshape(-1,1,7,41,81)
- u_d = torch.Tensor(u_d)
- u_d_train = u_d[0:train_size,:,:,:,:]
- u_d_valid = u_d[train_size:valid_size,:,:,:,:]
- u_d_test = u_d[valid_size:,:,:,:,:]
-
-
- v_d = v_d.reshape(-1,1,7,41,81)
- v_d = torch.Tensor(v_d)
- v_d_train = v_d[0:train_size,:,:,:,:]
- v_d_valid = v_d[train_size:valid_size,:,:,:,:]
- v_d_test = v_d[valid_size:,:,:,:,:]
-
-
- xx = xx.reshape(-1,1,7,41,81)
- xx = torch.Tensor(xx)
- xx_train = xx[0:train_size,:,:,:,:]
- xx_valid = xx[train_size:valid_size,:,:,:,:]
- xx_test = xx[valid_size:,:,:,:,:]
-
-
- yy = yy.reshape(-1,1,7,41,81)
- yy = torch.Tensor(yy)
- yy_train = yy[0:train_size,:,:,:,:]
- yy_valid = yy[train_size:valid_size,:,:,:,:]
- yy_test = yy[valid_size:,:,:,:,:]
-
- print('hycom_temp_train.shape:{}'.format(hycom_temp_train.shape))
- print('Q_net_train.shape:{}'.format(Q_net_train.shape))
- print('mld_train.shape:{}'.format(mld_train.shape))
- print('u_train.shape:{}'.format(u_train.shape))
- print('v_train.shape:{}'.format(v_train.shape))
- print('T_d_train.shape:{}'.format(T_d_train.shape))
- print('v_d_train.shape:{}'.format(v_d_train.shape))
-
-
- train_data = torch.cat((hycom_temp_train, Q_net_train, mld_train, u_train, v_train, T_d_train, v_d_train), dim=1) # train_data.shape:torch.Size([1952, 25, 7, 41, 81]) # 数据 第一维时间 第二维深度和变量 第三维7dat seq 4 5lat lon
-
-
- print('train_data.shape:{}'.format(train_data.shape))
-
- valid_data = torch.cat((hycom_temp_valid, Q_net_valid, mld_valid, u_valid, v_valid, T_d_valid, v_d_valid), dim=1) # valid_data.shape:torch.Size([672, 7, 32, 41, 81])
- print('valid_data.shape:{}'.format(valid_data.shape)) #([326, 3, 12, 15])
-
- test_data = torch.cat((hycom_temp_test, Q_net_test, mld_test, u_test, v_test, T_d_test, v_d_test), dim=1) #
- print('test_data.shape:{}'.format(test_data.shape)) #([326, 3, 12, 15])
-
- train_label = analysis_temp[7:train_size + 7,:,:,:] # train_label.shape:torch.Size([1952, 7, 7, 41, 81])
-
- valid_label = analysis_temp[train_size + 7:valid_size + 7,:,:,:] # valid_label.shape:torch.Size([672, 7, 7, 41, 81])
-
-
- test_label = analysis_temp[valid_size + 7: 3646,:,:,:] # test_label.shape:torch.Size([650, 7, 7, 41, 81])
-
-
- print('test_label.shape:{}'.format(test_label.shape)) # test_label.shape:(63, 1, 6, 27)
-
- train_label = torch.Tensor(train_label)
- valid_label = torch.Tensor(valid_label)
- test_label = torch.Tensor(test_label)
- print('train_label.shape:{}'.format(train_label.shape)) #train_label.shape:torch.Size([224, 1, 6, 27])
- test_label11 = test_label
- valid_label11 = valid_label
-
- #构建数据管道
- class MyDataset(Dataset):
- def __init__(self, data, label):
- self.data = torch.Tensor(data)
- self.label = torch.Tensor(label)
-
- def __len__(self):
- return len(self.label)
-
- def __getitem__(self, idx):
- return self.data[idx], self.label[idx]
-
-
- batch_size1 = 32
- batch_size2 = 32
- batch_size3 = 3000
- # trainset = MyDataset(input_data, sst)
- # trainset = MyDataset(train_data,train_label)
- # trainloader = DataLoader(trainset, batch_size=batch_size, shuffle=True)
- # batch_size = 1826
- trainset = MyDataset(train_data, train_label)
- trainloader = DataLoader(trainset, batch_size=batch_size1, shuffle=True, drop_last=False,pin_memory=True, num_workers=0)
-
- validset = MyDataset(valid_data, valid_label)
- validloader = DataLoader(validset, batch_size=batch_size2, shuffle=True, drop_last=False,pin_memory=True, num_workers=0)
-
- testset = MyDataset(test_data, test_label)
- testloader = DataLoader(testset, batch_size=batch_size3, shuffle=False, drop_last=False,pin_memory=True, num_workers=0)
-
- # print('Qnet_train.shape:{}'.format(sst1_train.shape))
-
- model_weights1 = '/vit_unet_camb_wm_epo{}_lr1e-3_lay3_e{}_black_ahead_1_day_model_weights.pth'.format(epoch111,ii)
-
- print('-----------------------train_black_att_3dcnn_convlstm--------------------------')
- # 输入特征数
- input_dim = 1from torch import nn
- from sklearn.preprocessing import MinMaxScaler
- from sklearn.metrics import mean_squared_error
- import random
- import torch.nn.functional as F
- import numpy as np
- import torch
- from tqdm import tqdm
- from torch.utils.data import Dataset, DataLoader
- import multiprocessing
- import torch.multiprocessing as multiprocess
- mm = MinMaxScaler()
-
-
- class ConvNet(nn.Module):
- def __init__(self, input_dim, input_dim1, hidden_dim, kernel_size1, padding1, kernel_size2, padding2, kernel_size3,
- padding3):
- super(ConvNet, self).__init__()
- self.input_dim = input_dim
- self.input_dim1 = input_dim1
-
- self.hidden_dim = hidden_dim
- self.kernel_size1 = kernel_size1
- self.padding1 = padding1
-
- self.kernel_size2 = kernel_size2
- self.kernel_size3 = kernel_size3
- self.padding2 = padding2
- self.padding3 = padding3
- self.gelu = nn.ReLU()
- # stage1
- self.conv1 = nn.Sequential(nn.Conv2d(in_channels=self.input_dim,
- out_channels=32,
- kernel_size=kernel_size1,
- padding=self.padding1,
- ))
- self.conv2 = nn.Sequential(nn.Conv2d(in_channels=32,
- out_channels=64,
- kernel_size=kernel_size2,
- padding=self.padding2,
- ))
- self.conv3 = nn.Sequential(nn.Conv2d(in_channels=64,
- out_channels=1,
- kernel_size=kernel_size3,
- padding=self.padding3,
- ))
- # self.conv4 = nn.Sequential(nn.Conv2d(in_channels=64,
- # out_channels=1,
- # kernel_size=kernel_size,
- # padding=self.padding,
- # ))
- # stage2
- # self.conv11 = nn.Sequential(nn.Conv3d(in_channels=self.input_dim1,
- # out_channels=16,
- # kernel_size=kernel_size1,
- # padding=self.padding1,
- # ),torch.nn.BatchNorm3d(16))
- # self.conv22 = nn.Sequential(nn.Conv3d(in_channels=16,
- # out_channels=32,
- # kernel_size=kernel_size2,
- # padding=self.padding2,
- # ),torch.nn.BatchNorm3d(32))
- # self.conv33 = nn.Sequential(nn.Conv3d(in_channels=32,
- # out_channels=10,
- # kernel_size=kernel_size3,
- # padding=self.padding3,
- # ),torch.nn.BatchNorm3d(10))
- # self.fc = nn.Linear
-
- # 前馈网络过程
- def forward(self, x): # x 为(batch, channel, h, w)
-
- out = self.conv1(x) # x 为(batch, channel, h, w)
- # out = self.gelu(out)
- out = self.conv2(out)
- # out = self.gelu(out)
- out = self.conv3(out)
- # out = self.gelu(out)
- # print('out.shape:{}'.format(out.shape))
- # out1 = out.permute(0,2,1,3,4)
- # out1 = self.conv11(out1)
- # out1 = self.gelu(out1)
- # out1 = self.conv22(out1)
- # out1 = self.gelu(out1)
- # out1 = self.conv33(out1)
- # out1 = self.gelu(out1)
- # out11 = out1.permute(0,2,1,3,4)
- # out = self.conv4(out)
- return out
-
- # data = np.load(r'/dataset/7day_for_Nday_data_09_17_atlantic_openi_ICDM_area_last1.npz')
- # data = np.load(r'/dataset/7day_for_Nday_data_09_17_atlantic_openi_ICDM_area_last1.npz')
- for iii in range(1,6):
- data = np.load(r'/dataset/7day_for_Nday_data_09_17_atlantic_openi_ICDM_area_last.npz')
- print(data.files) #['hycom_temp', 'slfh', 'sshf', 'ssr', 'str', 'mld', 'u', 'v', 'T_d', 'u_d', 'v_d', 'xx', 'yy', 'analysis_temp', 'dT_dt', 'dT_dx', 'dT_dy']
- # data = np.load(r'/dataset/7day_for_Nday_data_openi_09_17_atlantic_area_last.npz')
- # data = np.load(r'/dataset/7day_for_Nday_data_09_17_atlantic_openi_ICDM_area_last11.npz')
- # print(data.files) # ['hycom_temp', 'slfh', 'sshf', 'ssr', 'str', 'mld', 'analysis_temp', 'u', 'v', 'T_d', 'u_d', 'v_d', 'xx', 'yy']
-
- hycom_temp = data['hycom_temp'][:100, :, :, :40, :80] # (3281, 7, 7, 41, 201)
- print('hycom_temp.shape:{}'.format(hycom_temp.shape))
- # slfh = data['slfh'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # sshf = data['sshf'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # ssr = data['ssr'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # str = data['str'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # mld = data['mld'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # analysis_temp = data['analysis_temp'][:100,:,:,:40,:80] # (3281, 7, 7, 41, 201)
- # u = data['u'][:100, :, :, :40, :80] # (3281, 7, 7, 41, 201)
- # v = data['v'][:100, :, :, :40, :80] # (3281, 7, 7, 41, 201)
- # T_d = data['T_d'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # u_d = data['u_d'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # v_d = data['v_d'][:100, :, :40, :80] # (3281, 7, 41, 201)
- # # xx = data['xx'][:100, :, :, :] # (3281, 7, 41, 201)
- # # yy = data['yy'][:100, :, :, :] # (3281, 7, 41, 201)
- # dT_dt = data['dT_dt'][:100,:,:,:40,:80]
- # dT_dx = data['dT_dx'][:100,:,:,:40,:80]
- # dT_dy = data['dT_dy'][:100,:,:,:40,:80]
- # print('analysis_temp.shape:{}'.format(analysis_temp.shape)) # hycom_temp.shape:(100, 7, 7, 41, 81) batch, deep , time , lat, lon
- # print('T_d.shape:{}'.format(T_d.shape)) # hycom_temp.shape:(100, 7, 7, 41, 81) batch, deep , time , lat, lon
- # print('xx.shape:{}'.format(xx.shape)) # hycom_temp.shape:(100, 7, 7, 41, 81) batch, deep , time , lat, lon
-
- # dT_dt_1 = (hycom_temp[:,:,6,:,:] - hycom_temp[:,:,0,:,:]) / 6
- # dT_dt_2 = (hycom_temp[:,:,6,:,:] - hycom_temp[:,:,1,:,:]) / 5
- # dT_dt_3 = (hycom_temp[:,:,6,:,:] - hycom_temp[:,:,2,:,:]) / 4
- # dT_dt_4 = (hycom_temp[:,:,6,:,:] - hycom_temp[:,:,3,:,:]) / 3
- # dT_dt_5 = (hycom_temp[:,:,6,:,:] - hycom_temp[:,:,4,:,:]) / 2
- # dT_dt_6 = (hycom_temp[:,:,6,:,:] - hycom_temp[:,:,5,:,:]) / 1
-
- # dT_dt_1 = dT_dt_1.reshape(-1,7,1,41,81)
- # dT_dt_2 = dT_dt_2.reshape(-1,7,1,41,81)
- # dT_dt_3 = dT_dt_3.reshape(-1,7,1,41,81)
- # dT_dt_4 = dT_dt_4.reshape(-1,7,1,41,81)
- # dT_dt_5 = dT_dt_5.reshape(-1,7,1,41,81)
- # dT_dt_6 = dT_dt_6.reshape(-1,7,1,41,81)
-
- # dT_dt = np.concatenate((dT_dt_1, dT_dt_2, dT_dt_3, dT_dt_4, dT_dt_5, dT_dt_6), axis = 2) # dT_dt.shape:(100, 7, 6, 41, 81)
-
- # # print('dT_dt.shape:{}'.format(dT_dt.shape))
- # # # hycom_temp.shape:(100, 7, 7, 41, 81) time deep time lat lon
- # # # print('xx.shape:{}'.format(xx.shape)) #xx.shape:(100, 7, 41, 81)
- # xx = xx.reshape(-1,1,7,41,81)
- # xx = xx.repeat(7, axis = 1)
- # # print('xx.shape:{}'.format(xx.shape))
-
- # yy = yy.reshape(-1,1,7,41,81)
- # yy = yy.repeat(7, axis = 1)
-
- # # # hycom_temp.shape:(100, 7, 7, 41, 81) time deep time lat lon
- # list = []
- # for i in range(40):
- # xx_i = xx[:,:,:,i,:]
- # xx_j = xx[:,:,:,i+1,:]
- # T_i = hycom_temp[:,:,:,i,:]
- # T_j = hycom_temp[:,:,:,i+1,:]
- # dT_dx = (T_j - T_i) / (xx_j - xx_i)
- # list.append(dT_dx)
- # # print(dT_dx.shape)
- # a = np.array(list)
- # # print(a.shape) # (40, 100, 7, 7, 81)
-
- # dT_dx = a.transpose(1,2,3,0,4)
- # print(dT_dx.shape) # (100, 7, 7, 40, 81)
-
-
- # list1 = []
- # for j in range(80):
- # yy_i = yy[:,:,:,:,j]
- # yy_j = yy[:,:,:,:,j+1]
- # T_i = hycom_temp[:,:,:,:,j]
- # T_j = hycom_temp[:,:,:,:,j+1]
- # dT_dy = (T_j - T_i) / (yy_j - yy_i)
- # list1.append(dT_dy)
- # # print(dT_dy.shape)
- # b = np.array(list1)
- # # print(b.shape) # (80, 100, 7, 7, 41)
-
- # dT_dy = b.transpose(1,2,3,4,0)
- # print(dT_dy.shape) # (100, 7, 7, 41, 80)
-
-
- # dT_dt = dT_dt[:,:,:,:40,:80]
- # dT_dx = dT_dx[:,:,:,:40,:80]
- # dT_dy = dT_dy[:,:,:,:40,:80]
-
-
- # hycom_temp = hycom_temp[:,:,:,:40,:80]
- # slfh = data['slfh'][:, :, :40, :80] # (3281, 7, 41, 201)
- # sshf = data['sshf'][:, :, :40, :80] # (3281, 7, 41, 201)
- # ssr = data['ssr'][:, :, :40, :80] # (3281, 7, 41, 201)
- # str = data['str'][:, :, :40, :80] # (3281, 7, 41, 201)
- # mld = data['mld'][:, :, :40, :80] # (3281, 7, 41, 201)
- # analysis_temp = data['analysis_temp'][:1000,:,:,:40,:80] # (3281, 7, 7, 41, 201)
- # u = data['u'][:1000, :, :, :40, :80] # (3281, 7, 7, 41, 201)
- # v = data['v'][:1000, :, :, :40, :80] # (3281, 7, 7, 41, 201)
- # T_d = data['T_d'][:1000, :, :40, :80] # (3281, 7, 41, 201)
- # u_d = data['u_d'][:1000, :, :40, :80] # (3281, 7, 41, 201)
- # v_d = data['v_d'][:1000, :, :40, :80] # (3281, 7, 41, 201)
- # xx = data['xx'][:1000, :, :, :] # (3281, 7, 41, 201)
- # yy = data['yy'][:1000, :, :, :] # (3281, 7, 41, 201)
- # #
- #
- # dT_dt = dT_dt[:1000, :, :40, :80] # (3281, 7, 41, 201) # 过去7天预测未来一天 T7 - T6; T7 - T5; T7 - T4; T7 - T3; T7 - T2; T7 - T1
- #
- # dT_dx = dT_dx[:1000, :, :40, :80] # (3281, 7, 41, 201) # 过去7天预测未来一天 T7 - T6; T7 - T5; T7 - T4; T7 - T3; T7 - T2; T7 - T1
- # dT_dy = dT_dy[:1000, :, :40, :80] # (3281, 7, 41, 201)
-
-
- # analysis_temp = data['analysis_temp'][:1000, :, :, :40, :80] # (3281, 10, 7, 41, 201)
- analysis_temp = analysis_temp.transpose(0,2,1,3,4)
- # print(analysis_temp.shape)
- # print('hycom_temp.shape:{}'.format(hycom_temp.shape)) # hycom_temp.shape:(3281, 7, 7, 41, 81)
- #
- train_size = 64 # 前60%
- valid_size = 96 # 中间20% 作为验证 剩下的20%的作为测试
-
- # Q_net = slfh + sshf + ssr + str
- # print(Q_net)
- hycom_temp = hycom_temp[:,:,:,:40,:80]
- hycom_temp = torch.Tensor(hycom_temp)
- hycom_temp = hycom_temp.permute(0, 2, 1, 3, 4)
- hycom_temp = hycom_temp.reshape(-1, 7, 7, 40, 80)
- hycom_temp = torch.Tensor(hycom_temp)
- hycom_temp_train = hycom_temp[0:train_size, :, :, :, :]
- hycom_temp_valid = hycom_temp[train_size:valid_size, :, :, :, :]
- #hycom_temp_test = hycom_temp[valid_size:, :, :, :, :]
-
- # Q_net = Q_net.reshape(-1, 1, 7, 40, 80)
- # Q_net = torch.Tensor(Q_net)
- # Q_net_train = Q_net[0:train_size, :, :, :, :]
- # Q_net_valid = Q_net[train_size:valid_size, :, :, :, :]
- # #Q_net_test = Q_net[valid_size:, :, :, :, :]
- # # print('Q_net.shape:{}'.format(Q_net.shape)) # hycom_temp.shape:(3281, 7, 7, 41, 81)
-
- # mld = mld.reshape(-1, 1, 7, 40, 80)
- # mld = torch.Tensor(mld)
- # mld_train = mld[0:train_size, :, :, :, :]
-
- # mld_valid = mld[train_size:valid_size, :, :, :, :]
- # #mld_test = mld[valid_size:, :, :, :, :]
-
- # analysis_temp = analysis_temp[:,:,:,:40,:80]
- # analysis_temp = torch.Tensor(analysis_temp)
- # # analysis_temp = analysis_temp.permute(0,2,1,3,4)
- # # print('analysis_temp.shape:{}'.format(analysis_temp.shape)) # hycom_temp.shape:(3281, 7, 7, 41, 81)
-
- # analysis_temp = analysis_temp.reshape(-1, 7, 10, 40, 80)
- # analysis_temp = torch.Tensor(analysis_temp)
- # print('analysis_temp.shape:{}'.format(analysis_temp.shape)) # hycom_temp.shape:(3281, 7, 7, 41, 81)
-
- # u = torch.Tensor(u)
- # u = u.permute(0, 2, 1, 3, 4)
- # u = u.reshape(-1, 7, 7, 40, 80)
- # u = torch.Tensor(u)
- # u_train = u[0:train_size, :, :, :, :]
- # u_valid = u[train_size:valid_size, :, :, :, :]
- # #u_3test = u[valid_size:, :, :, :, :]
-
- # v = torch.Tensor(v)
- # v = v.permute(0, 2, 1, 3, 4)
- # v = v.reshape(-1, 7, 7, 40, 80)
- # v = torch.Tensor(v)
- # v_train = v[0:train_size, :, :, :, :]
- # v_valid = v[train_size:valid_size, :, :, :, :]
- # #v_test = v[valid_size:, :, :, :, :]
-
- # T_d = T_d.reshape(-1, 1, 7, 40, 80)
- # T_d = torch.Tensor(T_d)
- # T_d_train = T_d[0:train_size, :, :, :, :]
- # T_d_valid = T_d[train_size:valid_size, :, :, :, :]
- # #T_d_test = T_d[valid_size:, :, :, :, :]
-
- # u_d = u_d.reshape(-1, 1, 7, 40, 80)
- # u_d = torch.Tensor(u_d)
- # u_d_train = u_d[0:train_size, :, :, :, :]
- # u_d_valid = u_d[train_size:valid_size, :, :, :, :]
- # #u_d_test = u_d[valid_size:, :, :, :, :]
-
- # v_d = v_d.reshape(-1, 1, 7, 40, 80)
- # v_d = torch.Tensor(v_d)
- # v_d_train = v_d[0:train_size, :, :, :, :]
- # v_d_valid = v_d[train_size:valid_size, :, :, :, :]
- # #v_d_test = v_d[valid_size:, :, :, :, :]
-
- # # xx = xx.reshape(-1, 7, 7, 40, 80)
- # # xx = torch.Tensor(xx)
- # # xx_train = xx[0:train_size, :, :, :, :]
- # # xx_valid = xx[train_size:valid_size, :, :, :, :]
- # # xx_test = xx[valid_size:, :, :, :, :]
- # #
- # # yy = yy.reshape(-1, 7, 7, 40, 80)
- # # yy = torch.Tensor(yy)
- # #
- # # yy_train = yy[0:train_size, :, :, :, :]
- # # yy_valid = yy[train_size:valid_size, :, :, :, :]
- # # yy_test = yy[valid_size:, :, :, :, :]
-
- # dT_dt0 = torch.zeros(100,7,1,40,80)
- # dT_dt0 = np.array(dT_dt0)
- # dT_dt = np.concatenate((dT_dt, dT_dt0), axis=2)
- # # print('dT_dt.shape:{}'.format(dT_dt.shape))
- # dT_dt = dT_dt[:, :, :, :40, :80]
- # dT_dt = torch.Tensor(dT_dt)
- # dT_dt_train = dT_dt[0:train_size, :, :, :, :]
- # dT_dt_valid = dT_dt[train_size:valid_size, :, :, :, :]
- # #dT_dt_test = dT_dt[valid_size:, :, :, :, :]
-
- # dT_dx = dT_dx[:, :, :, :40, :80]
- # dT_dx = torch.Tensor(dT_dx)
- # dT_dx_train = dT_dx[0:train_size, :, :, :, :]
- # dT_dx_valid = dT_dx[train_size:valid_size, :, :, :, :]
- # #dT_dx_test = dT_dx[valid_size:, :, :, :, :]
-
- # dT_dy = dT_dy[:, :, :, :40, :80]
- # dT_dy = torch.Tensor(dT_dy)
- # dT_dy_train = dT_dy[0:train_size, :, :, :, :]
- # dT_dy_valid = dT_dy[train_size:valid_size, :, :, :, :]
- # #dT_dy_test = dT_dy[valid_size:, :, :, :, :]
-
- # train_data = torch.cat((hycom_temp_train, Q_net_train, mld_train, u_train, v_train, T_d_train, v_d_train, dT_dt_train, dT_dx_train, dT_dy_train),dim=1) # train_data.shape:torch.Size([1952, 7, 32, 41, 81]) # 数据 第一维时间 第二维深度和变量 第三维7dat seq 4 5lat lon
- train_data = hycom_temp_train
- # # print('train_data.shape:{}'.format(train_data.shape))
- valid_data = hycom_temp_valid
- # valid_data = torch.cat((hycom_temp_valid, Q_net_valid, mld_valid, u_valid, v_valid, T_d_valid, v_d_valid, dT_dt_valid, dT_dx_valid, dT_dy_valid), dim=1) # valid_data.shape:torch.Size([672, 7, 32, 41, 81])
- # # print('valid_data.shape:{}'.format(valid_data.shape)) # ([326, 3, 12, 15])
-
- # test_data = torch.cat((hycom_temp_test, Q_net_test, mld_test, u_test, v_test, T_d_test, v_d_test, dT_dt_test, dT_dx_test, dT_dy_test),dim=1) #
- # # print('test_data.shape:{}'.format(test_data.shape)) # ([326, 3, 12, 15])
-
- train_label = analysis_temp[7:train_size + 7, :, :,:] # train_label.shape:torch.Size([1952, 7, 7, 41, 81]) # 需要注意的是,不同与之前的实验,这次的label也经过了7day_for_Nday的过程,所以 只需要改变label nday_for_Nday的n,即可做到n天的预测
- train_label = train_label[:,0,0,:,:]
- valid_label = analysis_temp[train_size + 7:valid_size + 7, :, :, :] # valid_label.shape:torch.Size([672, 7, 7, 41, 81])
- valid_label = valid_label[:,0,0,:,:]
- # test_label = analysis_temp[valid_size + 7: 3646, :, :, :] # test_label.shape:torch.Size([650, 7, 7, 41, 81])
-
- # # print('train_label.shape:{}'.format(train_label.shape)) # test_label.shape:(63, 1, 6, 27)
-
- train_label = torch.Tensor(train_label)
- valid_label = torch.Tensor(valid_label)
- # test_label = torch.Tensor(test_label)
- # # print('valid_label.shape:{}'.format(valid_label.shape)) #train_label.shape:torch.Size([224, 1, 6, 27])
- # test_label11 = test_label
- valid_label11 = valid_label
- valid_label0 = valid_label
- import threading
- class MyDataset(Dataset):
- def __init__(self, data, label):
- self.data = torch.Tensor(data)
- self.label = torch.Tensor(label)
-
- def __len__(self):
- return len(self.label)
-
- def __getitem__(self, idx):
- return self.data[idx], self.label[idx]
-
-
- batch_size1 = 32
- batch_size2 = 32
- batch_size3 = 3000
- # import memory_profiler
- # @profile
- # def train(trainset, trainloader):
- # #code for training
- # print(1)
- # if __name__ == "__main__":
- trainset = MyDataset(train_data, train_label)
- trainloader = DataLoader(trainset, batch_size=batch_size1, shuffle=True, drop_last=False, pin_memory=True,num_workers=threading.active_count())
- def get_dataloader_generator(trainloader):
- while True:
- for data, label in trainloader:
- yield data, label
- validset = MyDataset(valid_data, valid_label)
- validloader = DataLoader(validset, batch_size=batch_size2, shuffle=True, drop_last=False, pin_memory=True,num_workers=threading.active_count())
- def get_dataloader_generator(validloader):
- while True:
- for data, label in validloader:
- yield data, label
- # testset = MyDataset(test_data, test_label)
- # testloader = DataLoader(testset, batch_size=batch_size3, shuffle=False, drop_last=False, pin_memory=True, num_workers=threading.active_count())
- # def get_dataloader_generator(testloader):
- # while True:
- # for data, label in testloader:
- # yield data, label
- model = ConvNet(input_dim=1, input_dim1=7, hidden_dim=1, kernel_size1=(1, 3,), padding1=(0, 1),
- kernel_size2=(1, 3), padding2=(0, 1), kernel_size3=(1, 3), padding3=(0, 1)).cuda()
- criterion = torch.nn.MSELoss()
- # 定义优化器
- optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
-
- # epochs = 2
- train_losses, valid_losses = [], []
- # best_loss = 2
- best_score = float('inf')
- best_score2 = float('inf')
-
- preds = np.zeros((32, 7, 40, 80))
- # preds = np.expand_dims(preds, axis=1)#preds.reshape(100,1,12,15)
-
- sores = []
-
-
- def rmse(y_true, y_preds):
- return np.sqrt(mean_squared_error(y_pred=y_preds, y_true=y_true))
-
-
- class mse_origin(nn.Module):
- def __init__(self):
- super(mse_origin, self).__init__()
-
- def forward(self, x, y):
- loss = (x - y) ** 2
- loss = torch.mean(loss)
- return loss
-
-
- class My_loss_mse(nn.Module):
- def __init__(self):
- super(My_loss_mse, self).__init__()
-
- def forward(self, inputs, targets, activate='sigmoid', beta=.2, gamma=1):
- loss = F.l1_loss(inputs, targets, reduction='none')
- loss *= (torch.tanh(beta * torch.abs(inputs - targets))) ** gamma if activate == 'tanh' else \
- (2 * torch.sigmoid(beta * torch.abs(inputs - targets)) - 1) ** gamma
-
- loss = torch.mean(loss)
- return loss
-
- for epoch111 in range(1000,10000,10):
- def setup_seed(seed):
- torch.manual_seed(seed)
- torch.cuda.manual_seed_all(seed)
- np.random.seed(seed)
- random.seed(seed)
- torch.backends.cudnn.deterministic = True
-
- # 设置随机数种子
- setup_seed(iii)
-
- model_weights1 = '/model/cnn_f(2)_pINN__epo{}_lay1_e{}_black_ahead_8_day_model_weights.pth'.format(epoch111,iii)
-
-
- pred_val = np.zeros((672, 1, 40, 80))
- for epoch in range(epoch111):
- print('Epoch: {}/{}'.format(epoch + 1, epoch111))
- # print(var_y)
- # 模型训练
- model.train()
- losses = 0
- for data, label in tqdm(trainloader):
- data = data.cuda()
- data1 = data[:, :, :, :, :] # 7个深度的 SST 和 XX 和 YY
- # print('data.shape:{}'.format(data.shape)) #data.shape:torch.Size([32, 9, 3, 6, 27])
- label = label.cuda()
- certrion = nn.MSELoss()
- optimizer.zero_grad()
-
- T_m = data[:, 0:7, :, :, :].reshape(-1, 7, 7, 40, 80)
- Q = data[:, 7:8, :, :, :].reshape(-1, 1, 7, 40, 80)
- h_m = data[:, 8:9, :, :, :].reshape(-1, 1, 7, 40, 80)
- u = data[:, 9:16, :, :, :].reshape(-1, 7, 7, 40, 80)
- v = data[:, 16:23, :, :, :].reshape(-1, 7, 7, 40, 80)
- T_d = data[:, 23:24, :, :, :].reshape(-1, 1, 7, 40, 80)
- w_e = data[:, 24:25, :, :, :].reshape(-1, 1, 7, 40, 80)
- dT_dt = data[:, 25:32, :, :, :].reshape(-1, 7, 7, 40, 80)
- dT_dx = data[:, 32:39, :, :, :].reshape(-1, 7, 7, 40, 80)
- dT_dy = data[:, 39:, :, :, :].reshape(-1, 7, 7, 40, 80)
- # print('T_m.shape:{}'.format(T_m.shape))
- # print('dT_dy.shape:{}'.format(dT_dy.shape))
-
- # 表面数据 ----过去七天 注意第七个深度的dT_dt 为0
- T_m_d1 = T_m[:, 0, :, :, :]
- u_d1 = u[:, 0, :, :, :]
- v_d1 = v[:, 0, :, :, :]
- dT_dt_d1 = dT_dt[:, 0, :, :, :]
- dT_dx_d1 = dT_dx[:, 0, :, :, :]
- dT_dy_d1 = dT_dy[:, 0, :, :, :]
-
- # # 表面数据 ----第一天 到7天
- # list1 = [] # 存dT_1 ... dT_6 与计算的loss
- # for j in range(7): # 7个深度
- # for i in range(7):
- # T_m_dj_i = T_m[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # u_dj_i = u[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # v_dj_i = v[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # # dT_dt_dj_i = dT_dt[:, j, i, :, :].reshape(-1, 1, 40, 80) # 过去七天也不可知dT_dt7
- # dT_dx_dj_i = dT_dx[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_dj_i = dT_dy[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # Q_i = Q[:, :, i, :, :].reshape(-1, 1, 40, 80)
- # h_m_i = h_m[:, :, i, :, :].reshape(-1, 1, 40, 80)
- # T_d_i = T_d[:, :, i, :, :].reshape(-1, 1, 40, 80)
- # w_e_i = w_e[:, :, i, :, :].reshape(-1, 1, 40, 80)
-
- # data_j_i = u_dj_i * (dT_dx_dj_i)
- # # print('data{}.shape:{}'.format(i, datai.shape)) # data0.shape:torch.Size([32, 1, 40, 80])
- # out_j_i = model(data_j_i)
- # # print('out{}.shape:{}'.format(i, outi.shape)) # data0.shape:torch.Size([32, 1, 40, 80])
-
- # dT_dti = Q_i / (1025 * 4000 * h_m_i) + v_dj_i * (dT_dy_dj_i) + out_j_i + w_e_i * ((T_m_dj_i - T_d_i) / h_m_i)
- # # print(dT_dti.shape)
- # list1.append(dT_dti)
-
- #深度0,天数1
- T_m_d0_1 = T_m[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- u_d0_1 = u[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- v_d0_1 = v[:, 0, 0, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_1 = dT_dx[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_1 = dT_dy[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- data_0_1 = u_d0_1 * (dT_dx_d0_1)
- out_0_1 = model(data_0_1)
-
- dT_dt_0_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d0_1 * (dT_dy_d0_1) + out_0_1 + w_e_1 * ((T_m_d0_1 - T_d_1) / h_m_1)
-
-
- #深度0,天数2
- T_m_d0_2 = T_m[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- u_d0_2 = u[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- v_d0_2 = v[:, 0, 1, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_2 = dT_dx[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_2 = dT_dy[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- data_0_2 = u_d0_2 * (dT_dx_d0_2)
- out_0_2 = model(data_0_2)
-
- dT_dt_0_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d0_2 * (dT_dy_d0_2) + out_0_2 + w_e_2 * ((T_m_d0_2 - T_d_2) / h_m_2)
-
-
- #深度0,天数3
- T_m_d0_3 = T_m[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- u_d0_3 = u[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- v_d0_3 = v[:, 0, 2, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_3 = dT_dx[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_3 = dT_dy[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- data_0_3 = u_d0_3 * (dT_dx_d0_3)
- out_0_3 = model(data_0_3)
-
- dT_dt_0_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d0_3 * (dT_dy_d0_3) + out_0_3 + w_e_3 * ((T_m_d0_3 - T_d_3) / h_m_3)
-
-
- #深度0,天数4
- T_m_d0_4 = T_m[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- u_d0_4 = u[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- v_d0_4 = v[:, 0, 3, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_4 = dT_dx[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_4 = dT_dy[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- data_0_4 = u_d0_4 * (dT_dx_d0_4)
- out_0_4 = model(data_0_4)
-
- dT_dt_0_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d0_4 * (dT_dy_d0_4) + out_0_4 + w_e_4 * ((T_m_d0_4 - T_d_4) / h_m_4)
-
-
- #深度0,天数5
- T_m_d0_5 = T_m[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- u_d0_5 = u[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- v_d0_5 = v[:, 0, 4, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_5 = dT_dx[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_5 = dT_dy[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- data_0_5 = u_d0_5 * (dT_dx_d0_5)
- out_0_5 = model(data_0_5)
-
- dT_dt_0_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d0_5 * (dT_dy_d0_5) + out_0_5 + w_e_5 * ((T_m_d0_5 - T_d_5) / h_m_5)
-
-
- #深度0,天数6
- T_m_d0_6 = T_m[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- u_d0_6 = u[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- v_d0_6 = v[:, 0, 5, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_6 = dT_dx[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_6 = dT_dy[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- data_0_6 = u_d0_6 * (dT_dx_d0_6)
- out_0_6 = model(data_0_6)
-
- dT_dt_0_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d0_6 * (dT_dy_d0_6) + out_0_6 + w_e_6 * ((T_m_d0_6 - T_d_6) / h_m_6)
-
-
- #深度0,天数7
- T_m_d0_7 = T_m[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- u_d0_7 = u[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- v_d0_7 = v[:, 0, 6, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_7 = dT_dx[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_7 = dT_dy[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- data_0_7 = u_d0_7 * (dT_dx_d0_7)
- out_0_7 = model(data_0_7)
-
- dT_dt_0_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d0_7 * (dT_dy_d0_7) + out_0_7 + w_e_7 * ((T_m_d0_7 - T_d_7) / h_m_7)
-
-
- # #深度1,天数1
- # T_m_d1_1 = T_m[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d1_1 = u[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d1_1 = v[:, 1, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_1 = dT_dx[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_1 = dT_dy[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_1 = u_d1_1 * (dT_dx_d1_1)
- # out_1_1 = model(data_1_1)
-
- # dT_dt_1_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d1_1 * (dT_dy_d1_1) + out_1_1 + w_e_1 * ((T_m_d1_1 - T_d_1) / h_m_1)
-
-
- # #深度1,天数2
- # T_m_d1_2 = T_m[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d1_2 = u[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d1_2 = v[:, 1, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_2 = dT_dx[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_2 = dT_dy[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_2 = u_d1_2 * (dT_dx_d1_2)
- # out_1_2 = model(data_1_2)
-
- # dT_dt_1_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d1_2 * (dT_dy_d1_2) + out_1_2 + w_e_2 * ((T_m_d1_2 - T_d_2) / h_m_2)
-
-
- # #深度1,天数3
- # T_m_d1_3 = T_m[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d1_3 = u[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d1_3 = v[:, 1, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_3 = dT_dx[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_3 = dT_dy[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_3 = u_d1_3 * (dT_dx_d1_3)
- # out_1_3 = model(data_1_3)
-
- # dT_dt_1_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d1_3 * (dT_dy_d1_3) + out_1_3 + w_e_3 * ((T_m_d1_3 - T_d_3) / h_m_3)
-
-
- # #深度1,天数4
- # T_m_d1_4 = T_m[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d1_4 = u[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d1_4 = v[:, 1, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_4 = dT_dx[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_4 = dT_dy[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_4 = u_d1_4 * (dT_dx_d1_4)
- # out_1_4 = model(data_1_4)
-
- # dT_dt_1_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d1_4 * (dT_dy_d1_4) + out_1_4 + w_e_4 * ((T_m_d1_4 - T_d_4) / h_m_4)
-
-
- # #深度1,天数5
- # T_m_d1_5 = T_m[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d1_5 = u[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d1_5 = v[:, 1, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_5 = dT_dx[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_5 = dT_dy[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_5 = u_d1_5 * (dT_dx_d1_5)
- # out_1_5 = model(data_1_5)
-
- # dT_dt_1_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d1_5 * (dT_dy_d1_5) + out_1_5 + w_e_5 * ((T_m_d1_5 - T_d_5) / h_m_5)
-
-
- # #深度1,天数6
- # T_m_d1_6 = T_m[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d1_6 = u[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d1_6 = v[:, 1, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_6 = dT_dx[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_6 = dT_dy[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_6 = u_d1_6 * (dT_dx_d1_6)
- # out_1_6 = model(data_1_6)
-
- # dT_dt_1_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d1_6 * (dT_dy_d1_6) + out_1_6 + w_e_6 * ((T_m_d1_6 - T_d_6) / h_m_6)
-
-
- # #深度1,天数7
- # T_m_d1_7 = T_m[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d1_7 = u[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d1_7 = v[:, 1, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_7 = dT_dx[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_7 = dT_dy[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_7 = u_d1_7 * (dT_dx_d1_7)
- # out_1_7 = model(data_1_7)
-
- # dT_dt_1_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d1_7 * (dT_dy_d1_7) + out_1_7 + w_e_7 * ((T_m_d1_7 - T_d_7) / h_m_7)
-
-
- # #深度2,天数1
- # T_m_d2_1 = T_m[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d2_1 = u[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d2_1 = v[:, 2, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_1 = dT_dx[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_1 = dT_dy[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_1 = u_d2_1 * (dT_dx_d2_1)
- # out_2_1 = model(data_2_1)
-
- # dT_dt_2_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d2_1 * (dT_dy_d2_1) + out_2_1 + w_e_1 * ((T_m_d2_1 - T_d_1) / h_m_1)
-
-
- # #深度2,天数2
- # T_m_d2_2 = T_m[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d2_2 = u[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d2_2 = v[:, 2, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_2 = dT_dx[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_2 = dT_dy[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_2 = u_d2_2 * (dT_dx_d2_2)
- # out_2_2 = model(data_2_2)
-
- # dT_dt_2_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d2_2 * (dT_dy_d2_2) + out_2_2 + w_e_2 * ((T_m_d2_2 - T_d_2) / h_m_2)
-
-
- # #深度2,天数3
- # T_m_d2_3 = T_m[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d2_3 = u[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d2_3 = v[:, 2, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_3 = dT_dx[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_3 = dT_dy[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_3 = u_d2_3 * (dT_dx_d2_3)
- # out_2_3 = model(data_2_3)
-
- # dT_dt_2_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d2_3 * (dT_dy_d2_3) + out_2_3 + w_e_3 * ((T_m_d2_3 - T_d_3) / h_m_3)
-
-
- # #深度2,天数4
- # T_m_d2_4 = T_m[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d2_4 = u[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d2_4 = v[:, 2, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_4 = dT_dx[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_4 = dT_dy[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_4 = u_d2_4 * (dT_dx_d2_4)
- # out_2_4 = model(data_2_4)
-
- # dT_dt_2_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d2_4 * (dT_dy_d2_4) + out_2_4 + w_e_4 * ((T_m_d2_4 - T_d_4) / h_m_4)
-
-
- # #深度2,天数5
- # T_m_d2_5 = T_m[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d2_5 = u[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d2_5 = v[:, 2, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_5 = dT_dx[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_5 = dT_dy[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_5 = u_d2_5 * (dT_dx_d2_5)
- # out_2_5 = model(data_2_5)
-
- # dT_dt_2_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d2_5 * (dT_dy_d2_5) + out_2_5 + w_e_5 * ((T_m_d2_5 - T_d_5) / h_m_5)
-
-
- # #深度2,天数6
- # T_m_d2_6 = T_m[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d2_6 = u[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d2_6 = v[:, 2, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_6 = dT_dx[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_6 = dT_dy[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_6 = u_d2_6 * (dT_dx_d2_6)
- # out_2_6 = model(data_2_6)
-
- # dT_dt_2_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d2_6 * (dT_dy_d2_6) + out_2_6 + w_e_6 * ((T_m_d2_6 - T_d_6) / h_m_6)
-
-
- # #深度2,天数7
- # T_m_d2_7 = T_m[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d2_7 = u[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d2_7 = v[:, 2, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_7 = dT_dx[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_7 = dT_dy[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_7 = u_d2_7 * (dT_dx_d2_7)
- # out_2_7 = model(data_2_7)
-
- # dT_dt_2_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d2_7 * (dT_dy_d2_7) + out_2_7 + w_e_7 * ((T_m_d2_7 - T_d_7) / h_m_7)
-
-
-
- # #深度3,天数1
- # T_m_d3_1 = T_m[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d3_1 = u[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d3_1 = v[:, 3, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_1 = dT_dx[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_1 = dT_dy[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_1 = u_d3_1 * (dT_dx_d3_1)
- # out_3_1 = model(data_3_1)
-
- # dT_dt_3_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d3_1 * (dT_dy_d3_1) + out_3_1 + w_e_1 * ((T_m_d3_1 - T_d_1) / h_m_1)
-
-
- # #深度3,天数2
- # T_m_d3_2 = T_m[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d3_2 = u[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d3_2 = v[:, 3, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_2 = dT_dx[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_2 = dT_dy[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_2 = u_d3_2 * (dT_dx_d3_2)
- # out_3_2 = model(data_3_2)
-
- # dT_dt_3_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d3_2 * (dT_dy_d3_2) + out_3_2 + w_e_2 * ((T_m_d3_2 - T_d_2) / h_m_2)
-
-
- # #深度3,天数3
- # T_m_d3_3 = T_m[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d3_3 = u[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d3_3 = v[:, 3, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_3 = dT_dx[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_3 = dT_dy[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_3 = u_d3_3 * (dT_dx_d3_3)
- # out_3_3 = model(data_3_3)
-
- # dT_dt_3_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d3_3 * (dT_dy_d3_3) + out_3_3 + w_e_3 * ((T_m_d3_3 - T_d_3) / h_m_3)
-
-
- # #深度3,天数4
- # T_m_d3_4 = T_m[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d3_4 = u[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d3_4 = v[:, 3, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_4 = dT_dx[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_4 = dT_dy[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_4 = u_d3_4 * (dT_dx_d3_4)
- # out_3_4 = model(data_3_4)
-
- # dT_dt_3_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d3_4 * (dT_dy_d3_4) + out_3_4 + w_e_4 * ((T_m_d3_4 - T_d_4) / h_m_4)
-
-
- # #深度3,天数5
- # T_m_d3_5 = T_m[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d3_5 = u[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d3_5 = v[:, 3, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_5 = dT_dx[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_5 = dT_dy[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_5 = u_d3_5 * (dT_dx_d3_5)
- # out_3_5 = model(data_3_5)
-
- # dT_dt_3_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d3_5 * (dT_dy_d3_5) + out_3_5 + w_e_5 * ((T_m_d3_5 - T_d_5) / h_m_5)
-
-
- # #深度3,天数6
- # T_m_d3_6 = T_m[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d3_6 = u[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d3_6 = v[:, 3, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_6 = dT_dx[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_6 = dT_dy[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_6 = u_d3_6 * (dT_dx_d3_6)
- # out_3_6 = model(data_3_6)
-
- # dT_dt_3_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d3_6 * (dT_dy_d3_6) + out_3_6 + w_e_6 * ((T_m_d3_6 - T_d_6) / h_m_6)
-
-
- # #深度3,天数7
- # T_m_d3_7 = T_m[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d3_7 = u[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d3_7 = v[:, 3, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_7 = dT_dx[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_7 = dT_dy[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_7 = u_d3_7 * (dT_dx_d3_7)
- # out_3_7 = model(data_3_7)
-
- # dT_dt_3_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d3_7 * (dT_dy_d3_7) + out_3_7 + w_e_7 * ((T_m_d3_7 - T_d_7) / h_m_7)
-
-
- # #深度4,天数1
- # T_m_d4_1 = T_m[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d4_1 = u[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d4_1 = v[:, 4, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_1 = dT_dx[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_1 = dT_dy[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_1 = u_d4_1 * (dT_dx_d4_1)
- # out_4_1 = model(data_4_1)
-
- # dT_dt_4_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d4_1 * (dT_dy_d4_1) + out_4_1 + w_e_1 * ((T_m_d4_1 - T_d_1) / h_m_1)
-
-
- # #深度4,天数2
- # T_m_d4_2 = T_m[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d4_2 = u[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d4_2 = v[:, 4, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_2 = dT_dx[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_2 = dT_dy[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_2 = u_d4_2 * (dT_dx_d4_2)
- # out_4_2 = model(data_4_2)
-
- # dT_dt_4_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d4_2 * (dT_dy_d4_2) + out_4_2 + w_e_2 * ((T_m_d4_2 - T_d_2) / h_m_2)
-
-
- # #深度4,天数3
- # T_m_d4_3 = T_m[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d4_3 = u[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d4_3 = v[:, 4, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_3 = dT_dx[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_3 = dT_dy[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_3 = u_d4_3 * (dT_dx_d4_3)
- # out_4_3 = model(data_4_3)
-
- # dT_dt_4_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d4_3 * (dT_dy_d4_3) + out_4_3 + w_e_3 * ((T_m_d4_3 - T_d_3) / h_m_3)
-
-
- # #深度4,天数4
- # T_m_d4_4 = T_m[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d4_4 = u[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d4_4 = v[:, 4, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_4 = dT_dx[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_4 = dT_dy[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_4 = u_d4_4 * (dT_dx_d4_4)
- # out_4_4 = model(data_4_4)
-
- # dT_dt_4_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d4_4 * (dT_dy_d4_4) + out_4_4 + w_e_4 * ((T_m_d4_4 - T_d_4) / h_m_4)
-
-
- # #深度4,天数5
- # T_m_d4_5 = T_m[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d4_5 = u[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d4_5 = v[:, 4, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_5 = dT_dx[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_5 = dT_dy[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_5 = u_d4_5 * (dT_dx_d4_5)
- # out_4_5 = model(data_4_5)
-
- # dT_dt_4_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d4_5 * (dT_dy_d4_5) + out_4_5 + w_e_5 * ((T_m_d4_5 - T_d_5) / h_m_5)
-
-
- # #深度4,天数6
- # T_m_d4_6 = T_m[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d4_6 = u[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d4_6 = v[:, 4, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_6 = dT_dx[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_6 = dT_dy[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_6 = u_d4_6 * (dT_dx_d4_6)
- # out_4_6 = model(data_4_6)
-
- # dT_dt_4_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d4_6 * (dT_dy_d4_6) + out_4_6 + w_e_6 * ((T_m_d4_6 - T_d_6) / h_m_6)
-
-
- # #深度4,天数7
- # T_m_d4_7 = T_m[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d4_7 = u[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d4_7 = v[:, 4, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_7 = dT_dx[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_7 = dT_dy[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_7 = u_d4_7 * (dT_dx_d4_7)
- # out_4_7 = model(data_4_7)
-
- # dT_dt_4_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d4_7 * (dT_dy_d4_7) + out_4_7 + w_e_7 * ((T_m_d4_7 - T_d_7) / h_m_7)
-
-
- # #深度5,天数1
- # T_m_d5_1 = T_m[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d5_1 = u[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d5_1 = v[:, 5, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_1 = dT_dx[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_1 = dT_dy[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_1 = u_d5_1 * (dT_dx_d5_1)
- # out_5_1 = model(data_5_1)
-
- # dT_dt_5_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d5_1 * (dT_dy_d5_1) + out_5_1 + w_e_1 * ((T_m_d5_1 - T_d_1) / h_m_1)
-
-
- # #深度5,天数2
- # T_m_d5_2 = T_m[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d5_2 = u[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d5_2 = v[:, 5, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_2 = dT_dx[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_2 = dT_dy[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_2 = u_d5_2 * (dT_dx_d5_2)
- # out_5_2 = model(data_5_2)
-
- # dT_dt_5_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d5_2 * (dT_dy_d5_2) + out_5_2 + w_e_2 * ((T_m_d5_2 - T_d_2) / h_m_2)
-
-
- # #深度5,天数3
- # T_m_d5_3 = T_m[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d5_3 = u[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d5_3 = v[:, 5, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_3 = dT_dx[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_3 = dT_dy[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_3 = u_d5_3 * (dT_dx_d5_3)
- # out_5_3 = model(data_5_3)
-
- # dT_dt_5_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d5_3 * (dT_dy_d5_3) + out_5_3 + w_e_3 * ((T_m_d5_3 - T_d_3) / h_m_3)
-
-
- # #深度5,天数4
- # T_m_d5_4 = T_m[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d5_4 = u[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d5_4 = v[:, 5, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_4 = dT_dx[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_4 = dT_dy[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_4 = u_d5_4 * (dT_dx_d5_4)
- # out_5_4 = model(data_5_4)
-
- # dT_dt_5_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d5_4 * (dT_dy_d5_4) + out_5_4 + w_e_4 * ((T_m_d5_4 - T_d_4) / h_m_4)
-
-
- # #深度5,天数5
- # T_m_d5_5 = T_m[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d5_5 = u[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d5_5 = v[:, 5, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_5 = dT_dx[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_5 = dT_dy[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_5 = u_d5_5 * (dT_dx_d5_5)
- # out_5_5 = model(data_5_5)
-
- # dT_dt_5_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d5_5 * (dT_dy_d5_5) + out_5_5 + w_e_5 * ((T_m_d5_5 - T_d_5) / h_m_5)
-
-
- # #深度5,天数6
- # T_m_d5_6 = T_m[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d5_6 = u[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d5_6 = v[:, 5, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_6 = dT_dx[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_6 = dT_dy[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_6 = u_d5_6 * (dT_dx_d5_6)
- # out_5_6 = model(data_5_6)
-
- # dT_dt_5_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d5_6 * (dT_dy_d5_6) + out_5_6 + w_e_6 * ((T_m_d5_6 - T_d_6) / h_m_6)
-
-
- # #深度5,天数7
- # T_m_d5_7 = T_m[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d5_7 = u[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d5_7 = v[:, 5, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_7 = dT_dx[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_7 = dT_dy[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_7 = u_d5_7 * (dT_dx_d5_7)
- # out_5_7 = model(data_5_7)
-
- # dT_dt_5_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d5_7 * (dT_dy_d5_7) + out_5_7 + w_e_7 * ((T_m_d5_7 - T_d_7) / h_m_7)
-
-
- # #深度6,天数1
- # T_m_d6_1 = T_m[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d6_1 = u[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d6_1 = v[:, 6, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_1 = dT_dx[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_1 = dT_dy[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_1 = u_d6_1 * (dT_dx_d6_1)
- # out_6_1 = model(data_6_1)
-
- # dT_dt_6_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d6_1 * (dT_dy_d6_1) + out_6_1 + w_e_1 * ((T_m_d6_1 - T_d_1) / h_m_1)
-
-
- # #深度6,天数2
- # T_m_d6_2 = T_m[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d6_2 = u[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d6_2 = v[:, 6, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_2 = dT_dx[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_2 = dT_dy[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_2 = u_d6_2 * (dT_dx_d6_2)
- # out_6_2 = model(data_6_2)
-
- # dT_dt_6_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d6_2 * (dT_dy_d6_2) + out_6_2 + w_e_2 * ((T_m_d6_2 - T_d_2) / h_m_2)
-
-
- # #深度6,天数3
- # T_m_d6_3 = T_m[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d6_3 = u[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d6_3 = v[:, 6, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_3 = dT_dx[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_3 = dT_dy[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_3 = u_d6_3 * (dT_dx_d6_3)
- # out_6_3 = model(data_6_3)
-
- # dT_dt_6_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d6_3 * (dT_dy_d6_3) + out_6_3 + w_e_3 * ((T_m_d6_3 - T_d_3) / h_m_3)
-
-
- # #深度6,天数4
- # T_m_d6_4 = T_m[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d6_4 = u[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d6_4 = v[:, 6, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_4 = dT_dx[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_4 = dT_dy[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_4 = u_d6_4 * (dT_dx_d6_4)
- # out_6_4 = model(data_6_4)
-
- # dT_dt_6_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d6_4 * (dT_dy_d6_4) + out_6_4 + w_e_4 * ((T_m_d6_4 - T_d_4) / h_m_4)
-
-
- # #深度6,天数5
- # T_m_d6_5 = T_m[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d6_5 = u[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d6_5 = v[:, 6, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_5 = dT_dx[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_5 = dT_dy[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_5 = u_d6_5 * (dT_dx_d6_5)
- # out_6_5 = model(data_6_5)
-
- # dT_dt_6_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d6_5 * (dT_dy_d6_5) + out_6_5 + w_e_5 * ((T_m_d6_5 - T_d_5) / h_m_5)
-
-
- # #深度6,天数6
- # T_m_d6_6 = T_m[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d6_6 = u[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d6_6 = v[:, 6, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_6 = dT_dx[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_6 = dT_dy[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_6 = u_d6_6 * (dT_dx_d6_6)
- # out_6_6 = model(data_6_6)
-
- # dT_dt_6_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d6_6 * (dT_dy_d6_6) + out_6_6 + w_e_6 * ((T_m_d6_6 - T_d_6) / h_m_6)
-
-
- # #深度6,天数7
- # T_m_d6_7 = T_m[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d6_7 = u[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d6_7 = v[:, 6, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_7 = dT_dx[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_7 = dT_dy[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_7 = u_d6_7 * (dT_dx_d6_7)
- # out_6_7 = model(data_6_7)
-
- # dT_dt_6_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d6_7 * (dT_dy_d6_7) + out_6_7 + w_e_7 * ((T_m_d6_7 - T_d_7) / h_m_7)
-
-
- # # #表面
- # # dT_dt_0_1 = list1[0]; dT_dt_0_2 = list1[1]; dT_dt_0_3 = list1[2]; dT_dt_0_4 = list1[3]; dT_dt_0_5 = list1[4]; dT_dt_0_6 = list1[5]; dT_dt_0_7 = list1[6]
-
- # # #layer1
- # # dT_dt_1_1 = list1[7]; dT_dt_1_2 = list1[8]; dT_dt_1_3 = list1[9]; dT_dt_1_4 = list1[10]; dT_dt_1_5 = list1[11]; dT_dt_1_6 = list1[12]; dT_dt_1_7 = list1[13]
-
- # # # layer2
- # # dT_dt_2_1 = list1[14]; dT_dt_2_2 = list1[15]; dT_dt_2_3 = list1[16]; dT_dt_2_4 = list1[17]; dT_dt_2_5 = list1[18]; dT_dt_2_6 = list1[19]; dT_dt_2_7 = list1[20]
-
- # # # layer3
- # # dT_dt_3_1 = list1[21]; dT_dt_3_2 = list1[22]; dT_dt_3_3 = list1[23]; dT_dt_3_4 = list1[24]; dT_dt_3_5 = list1[25]; dT_dt_3_6 = list1[26]; dT_dt_3_7 = list1[27]
-
- # # # layer4
- # # dT_dt_4_1 = list1[28]; dT_dt_4_2 = list1[29]; dT_dt_4_3 = list1[30]; dT_dt_4_4 = list1[31]; dT_dt_4_5 = list1[32]; dT_dt_4_6 = list1[33]; dT_dt_4_7 = list1[34]
-
- # # # layer5
- # # dT_dt_5_1 = list1[35]; dT_dt_5_2 = list1[36]; dT_dt_5_3 = list1[37]; dT_dt_5_4 = list1[38]; dT_dt_5_5 = list1[39]; dT_dt_5_6 = list1[40]; dT_dt_5_7 = list1[41]
-
- # # # layer5
- # # dT_dt_6_1 = list1[42]; dT_dt_6_2 = list1[43]; dT_dt_6_3 = list1[44]; dT_dt_6_4 = list1[45]; dT_dt_6_5 = list1[46]; dT_dt_6_6 = list1[47]; dT_dt_6_7 = list1[48]
-
-
- alpha = 0.1
- beta = 0.9
- T_8_0 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_0_1 + beta * dT_dt_0_2) + beta * dT_dt_0_3) + beta * dT_dt_0_4) + beta * dT_dt_0_5) + beta * dT_dt_0_6) + beta * dT_dt_0_7 + T_m[:, 0, 6, :, :].reshape(-1,1,40,80)
- # T_8_1 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_1_1 + beta * dT_dt_1_2) + beta * dT_dt_1_3) + beta * dT_dt_1_4) + beta * dT_dt_1_5) + beta * dT_dt_1_6) + beta * dT_dt_1_7 + T_m[:, 1, 6, :, :].reshape(-1,1,40,80)
- # T_8_2 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_2_1 + beta * dT_dt_2_2) + beta * dT_dt_2_3) + beta * dT_dt_2_4) + beta * dT_dt_2_5) + beta * dT_dt_2_6) + beta * dT_dt_2_7 + T_m[:, 2, 6, :, :].reshape(-1,1,40,80)
- # T_8_3 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_3_1 + beta * dT_dt_3_2) + beta * dT_dt_3_3) + beta * dT_dt_3_4) + beta * dT_dt_3_5) + beta * dT_dt_3_6) + beta * dT_dt_3_7 + T_m[:, 3, 6, :, :].reshape(-1,1,40,80)
- # T_8_4 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_4_1 + beta * dT_dt_4_2) + beta * dT_dt_4_3) + beta * dT_dt_4_4) + beta * dT_dt_4_5) + beta * dT_dt_4_6) + beta * dT_dt_4_7 + T_m[:, 4, 6, :, :].reshape(-1,1,40,80)
- # T_8_5 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_5_1 + beta * dT_dt_5_2) + beta * dT_dt_5_3) + beta * dT_dt_5_4) + beta * dT_dt_5_5) + beta * dT_dt_5_6) + beta * dT_dt_5_7 + T_m[:, 5, 6, :, :].reshape(-1,1,40,80)
- # T_8_6 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_6_1 + beta * dT_dt_6_2) + beta * dT_dt_6_3) + beta * dT_dt_6_4) + beta * dT_dt_6_5) + beta * dT_dt_6_6) + beta * dT_dt_6_7 + T_m[:, 6, 6, :, :].reshape(-1,1,40,80)
-
- # T_8_all = torch.cat((T_8_0,T_8_1,T_8_2,T_8_3,T_8_4,T_8_4,T_8_6), dim=1)
- # print('T_8_all.shape:{}'.format(T_8_all.shape)) # T_8_0.shape:torch.Size([32, 1, 40, 80])
- print('T_8_0.shape:{}'.format(T_8_0.shape))
- print('label.shape:{}'.format(label.shape))
- label_8 = label
- # print('label.shape:{}'.format(label.shape)) # label.shape:torch.Size([32, 7, 10, 40, 80])
- label_8 = label_8.reshape(-1,1,40,80)
- loss = criterion(T_8_0, label_8)
-
- losses += loss
- #print(loss)
- # 反向传播
- loss.backward()
- optimizer.step()
-
- train_loss = losses / len(trainloader)
- train_losses.append(train_loss)
-
- print('Training Loss: {:.10f}'.format(train_loss))
-
- #Validation
-
- model.eval()
- losses = 0
-
- for d, data in tqdm(enumerate(validloader)):
- data, label = data
- data = data.cuda()
- label = label.cuda()
- optimizer.zero_grad()
-
- T_m = data[:, 0:7, :, :, :].reshape(-1, 7, 7, 40, 80)
- Q = data[:, 7:8, :, :, :].reshape(-1, 1, 7, 40, 80)
- h_m = data[:, 8:9, :, :, :].reshape(-1, 1, 7, 40, 80)
- u = data[:, 9:16, :, :, :].reshape(-1, 7, 7, 40, 80)
- v = data[:, 16:23, :, :, :].reshape(-1, 7, 7, 40, 80)
- T_d = data[:, 23:24, :, :, :].reshape(-1, 1, 7, 40, 80)
- w_e = data[:, 24:25, :, :, :].reshape(-1, 1, 7, 40, 80)
- dT_dt = data[:, 25:32, :, :, :].reshape(-1, 7, 7, 40, 80)
- dT_dx = data[:, 32:39, :, :, :].reshape(-1, 7, 7, 40, 80)
- dT_dy = data[:, 39:, :, :, :].reshape(-1, 7, 7, 40, 80)
- # print('data_test.shape:{}'.format(data.shape)) # T_8_0_test.shape:torch.Size([29, 1, 40, 80])
-
- # 表面数据 ----第一天 到7天
- # list1 = [] # 存dT_1 ... dT_6 与计算的loss
- # for j in range(7): # 7个深度
- # for i in range(7):
- # T_m_dj_i = T_m[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # u_dj_i = u[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # v_dj_i = v[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # # dT_dt_dj_i = dT_dt[:, j, i, :, :].reshape(-1, 1, 40, 80) # 过去七天也不可知dT_dt7
- # dT_dx_dj_i = dT_dx[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_dj_i = dT_dy[:, j, i, :, :].reshape(-1, 1, 40, 80)
- # Q_i = Q[:, :, i, :, :].reshape(-1, 1, 40, 80)
- # h_m_i = h_m[:, :, i, :, :].reshape(-1, 1, 40, 80)
- # T_d_i = T_d[:, :, i, :, :].reshape(-1, 1, 40, 80)
- # w_e_i = w_e[:, :, i, :, :].reshape(-1, 1, 40, 80)
-
- # data_j_i = u_dj_i * (dT_dx_dj_i)
-
- # out_j_i = model(data_j_i)
-
- # dT_dti = Q_i / (1025 * 4000 * h_m_i) + v_dj_i * (dT_dy_dj_i) + out_j_i + w_e_i * ((T_m_dj_i - T_d_i) / h_m_i)
- # # print(dT_dti.shape)
- # list1.append(dT_dti)
-
-
- #深度0,天数1
- T_m_d0_1 = T_m[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- u_d0_1 = u[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- v_d0_1 = v[:, 0, 0, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_1 = dT_dx[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_1 = dT_dy[:, 0, 0, :, :].reshape(-1, 1, 40, 80)
- Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- data_0_1 = u_d0_1 * (dT_dx_d0_1)
- out_0_1 = model(data_0_1)
-
- dT_dt_0_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d0_1 * (dT_dy_d0_1) + out_0_1 + w_e_1 * ((T_m_d0_1 - T_d_1) / h_m_1)
-
-
- #深度0,天数2
- T_m_d0_2 = T_m[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- u_d0_2 = u[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- v_d0_2 = v[:, 0, 1, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_2 = dT_dx[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_2 = dT_dy[:, 0, 1, :, :].reshape(-1, 1, 40, 80)
- Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- data_0_2 = u_d0_2 * (dT_dx_d0_2)
- out_0_2 = model(data_0_2)
-
- dT_dt_0_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d0_2 * (dT_dy_d0_2) + out_0_2 + w_e_2 * ((T_m_d0_2 - T_d_2) / h_m_2)
-
-
- #深度0,天数3
- T_m_d0_3 = T_m[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- u_d0_3 = u[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- v_d0_3 = v[:, 0, 2, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_3 = dT_dx[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_3 = dT_dy[:, 0, 2, :, :].reshape(-1, 1, 40, 80)
- Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- data_0_3 = u_d0_3 * (dT_dx_d0_3)
- out_0_3 = model(data_0_3)
-
- dT_dt_0_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d0_3 * (dT_dy_d0_3) + out_0_3 + w_e_3 * ((T_m_d0_3 - T_d_3) / h_m_3)
-
-
- #深度0,天数4
- T_m_d0_4 = T_m[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- u_d0_4 = u[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- v_d0_4 = v[:, 0, 3, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_4 = dT_dx[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_4 = dT_dy[:, 0, 3, :, :].reshape(-1, 1, 40, 80)
- Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- data_0_4 = u_d0_4 * (dT_dx_d0_4)
- out_0_4 = model(data_0_4)
-
- dT_dt_0_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d0_4 * (dT_dy_d0_4) + out_0_4 + w_e_4 * ((T_m_d0_4 - T_d_4) / h_m_4)
-
-
- #深度0,天数5
- T_m_d0_5 = T_m[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- u_d0_5 = u[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- v_d0_5 = v[:, 0, 4, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_5 = dT_dx[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_5 = dT_dy[:, 0, 4, :, :].reshape(-1, 1, 40, 80)
- Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- data_0_5 = u_d0_5 * (dT_dx_d0_5)
- out_0_5 = model(data_0_5)
-
- dT_dt_0_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d0_5 * (dT_dy_d0_5) + out_0_5 + w_e_5 * ((T_m_d0_5 - T_d_5) / h_m_5)
-
-
- #深度0,天数6
- T_m_d0_6 = T_m[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- u_d0_6 = u[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- v_d0_6 = v[:, 0, 5, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_6 = dT_dx[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_6 = dT_dy[:, 0, 5, :, :].reshape(-1, 1, 40, 80)
- Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- data_0_6 = u_d0_6 * (dT_dx_d0_6)
- out_0_6 = model(data_0_6)
-
- dT_dt_0_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d0_6 * (dT_dy_d0_6) + out_0_6 + w_e_6 * ((T_m_d0_6 - T_d_6) / h_m_6)
-
-
- #深度0,天数7
- T_m_d0_7 = T_m[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- u_d0_7 = u[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- v_d0_7 = v[:, 0, 6, :, :].reshape(-1, 1, 40, 80);
- dT_dx_d0_7 = dT_dx[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- dT_dy_d0_7 = dT_dy[:, 0, 6, :, :].reshape(-1, 1, 40, 80)
- Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- data_0_7 = u_d0_7 * (dT_dx_d0_7)
- out_0_7 = model(data_0_7)
-
- dT_dt_0_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d0_7 * (dT_dy_d0_7) + out_0_7 + w_e_7 * ((T_m_d0_7 - T_d_7) / h_m_7)
-
-
- # #深度1,天数1
- # T_m_d1_1 = T_m[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d1_1 = u[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d1_1 = v[:, 1, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_1 = dT_dx[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_1 = dT_dy[:, 1, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_1 = u_d1_1 * (dT_dx_d1_1)
- # out_1_1 = model(data_1_1)
-
- # dT_dt_1_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d1_1 * (dT_dy_d1_1) + out_1_1 + w_e_1 * ((T_m_d1_1 - T_d_1) / h_m_1)
-
-
- # #深度1,天数2
- # T_m_d1_2 = T_m[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d1_2 = u[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d1_2 = v[:, 1, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_2 = dT_dx[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_2 = dT_dy[:, 1, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_2 = u_d1_2 * (dT_dx_d1_2)
- # out_1_2 = model(data_1_2)
-
- # dT_dt_1_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d1_2 * (dT_dy_d1_2) + out_1_2 + w_e_2 * ((T_m_d1_2 - T_d_2) / h_m_2)
-
-
- # #深度1,天数3
- # T_m_d1_3 = T_m[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d1_3 = u[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d1_3 = v[:, 1, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_3 = dT_dx[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_3 = dT_dy[:, 1, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_3 = u_d1_3 * (dT_dx_d1_3)
- # out_1_3 = model(data_1_3)
-
- # dT_dt_1_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d1_3 * (dT_dy_d1_3) + out_1_3 + w_e_3 * ((T_m_d1_3 - T_d_3) / h_m_3)
-
-
- # #深度1,天数4
- # T_m_d1_4 = T_m[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d1_4 = u[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d1_4 = v[:, 1, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_4 = dT_dx[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_4 = dT_dy[:, 1, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_4 = u_d1_4 * (dT_dx_d1_4)
- # out_1_4 = model(data_1_4)
-
- # dT_dt_1_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d1_4 * (dT_dy_d1_4) + out_1_4 + w_e_4 * ((T_m_d1_4 - T_d_4) / h_m_4)
-
-
- # #深度1,天数5
- # T_m_d1_5 = T_m[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d1_5 = u[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d1_5 = v[:, 1, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_5 = dT_dx[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_5 = dT_dy[:, 1, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_5 = u_d1_5 * (dT_dx_d1_5)
- # out_1_5 = model(data_1_5)
-
- # dT_dt_1_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d1_5 * (dT_dy_d1_5) + out_1_5 + w_e_5 * ((T_m_d1_5 - T_d_5) / h_m_5)
-
-
- # #深度1,天数6
- # T_m_d1_6 = T_m[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d1_6 = u[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d1_6 = v[:, 1, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_6 = dT_dx[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_6 = dT_dy[:, 1, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_6 = u_d1_6 * (dT_dx_d1_6)
- # out_1_6 = model(data_1_6)
-
- # dT_dt_1_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d1_6 * (dT_dy_d1_6) + out_1_6 + w_e_6 * ((T_m_d1_6 - T_d_6) / h_m_6)
-
-
- # #深度1,天数7
- # T_m_d1_7 = T_m[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d1_7 = u[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d1_7 = v[:, 1, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d1_7 = dT_dx[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d1_7 = dT_dy[:, 1, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_1_7 = u_d1_7 * (dT_dx_d1_7)
- # out_1_7 = model(data_1_7)
-
- # dT_dt_1_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d1_7 * (dT_dy_d1_7) + out_1_7 + w_e_7 * ((T_m_d1_7 - T_d_7) / h_m_7)
-
-
- # #深度2,天数1
- # T_m_d2_1 = T_m[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d2_1 = u[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d2_1 = v[:, 2, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_1 = dT_dx[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_1 = dT_dy[:, 2, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_1 = u_d2_1 * (dT_dx_d2_1)
- # out_2_1 = model(data_2_1)
-
- # dT_dt_2_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d2_1 * (dT_dy_d2_1) + out_2_1 + w_e_1 * ((T_m_d2_1 - T_d_1) / h_m_1)
-
-
- # #深度2,天数2
- # T_m_d2_2 = T_m[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d2_2 = u[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d2_2 = v[:, 2, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_2 = dT_dx[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_2 = dT_dy[:, 2, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_2 = u_d2_2 * (dT_dx_d2_2)
- # out_2_2 = model(data_2_2)
-
- # dT_dt_2_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d2_2 * (dT_dy_d2_2) + out_2_2 + w_e_2 * ((T_m_d2_2 - T_d_2) / h_m_2)
-
-
- # #深度2,天数3
- # T_m_d2_3 = T_m[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d2_3 = u[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d2_3 = v[:, 2, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_3 = dT_dx[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_3 = dT_dy[:, 2, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_3 = u_d2_3 * (dT_dx_d2_3)
- # out_2_3 = model(data_2_3)
-
- # dT_dt_2_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d2_3 * (dT_dy_d2_3) + out_2_3 + w_e_3 * ((T_m_d2_3 - T_d_3) / h_m_3)
-
-
- # #深度2,天数4
- # T_m_d2_4 = T_m[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d2_4 = u[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d2_4 = v[:, 2, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_4 = dT_dx[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_4 = dT_dy[:, 2, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_4 = u_d2_4 * (dT_dx_d2_4)
- # out_2_4 = model(data_2_4)
-
- # dT_dt_2_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d2_4 * (dT_dy_d2_4) + out_2_4 + w_e_4 * ((T_m_d2_4 - T_d_4) / h_m_4)
-
-
- # #深度2,天数5
- # T_m_d2_5 = T_m[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d2_5 = u[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d2_5 = v[:, 2, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_5 = dT_dx[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_5 = dT_dy[:, 2, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_5 = u_d2_5 * (dT_dx_d2_5)
- # out_2_5 = model(data_2_5)
-
- # dT_dt_2_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d2_5 * (dT_dy_d2_5) + out_2_5 + w_e_5 * ((T_m_d2_5 - T_d_5) / h_m_5)
-
-
- # #深度2,天数6
- # T_m_d2_6 = T_m[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d2_6 = u[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d2_6 = v[:, 2, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_6 = dT_dx[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_6 = dT_dy[:, 2, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_6 = u_d2_6 * (dT_dx_d2_6)
- # out_2_6 = model(data_2_6)
-
- # dT_dt_2_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d2_6 * (dT_dy_d2_6) + out_2_6 + w_e_6 * ((T_m_d2_6 - T_d_6) / h_m_6)
-
-
- # #深度2,天数7
- # T_m_d2_7 = T_m[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d2_7 = u[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d2_7 = v[:, 2, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d2_7 = dT_dx[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d2_7 = dT_dy[:, 2, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_2_7 = u_d2_7 * (dT_dx_d2_7)
- # out_2_7 = model(data_2_7)
-
- # dT_dt_2_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d2_7 * (dT_dy_d2_7) + out_2_7 + w_e_7 * ((T_m_d2_7 - T_d_7) / h_m_7)
-
-
-
- # #深度3,天数1
- # T_m_d3_1 = T_m[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d3_1 = u[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d3_1 = v[:, 3, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_1 = dT_dx[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_1 = dT_dy[:, 3, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_1 = u_d3_1 * (dT_dx_d3_1)
- # out_3_1 = model(data_3_1)
-
- # dT_dt_3_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d3_1 * (dT_dy_d3_1) + out_3_1 + w_e_1 * ((T_m_d3_1 - T_d_1) / h_m_1)
-
-
- # #深度3,天数2
- # T_m_d3_2 = T_m[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d3_2 = u[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d3_2 = v[:, 3, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_2 = dT_dx[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_2 = dT_dy[:, 3, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_2 = u_d3_2 * (dT_dx_d3_2)
- # out_3_2 = model(data_3_2)
-
- # dT_dt_3_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d3_2 * (dT_dy_d3_2) + out_3_2 + w_e_2 * ((T_m_d3_2 - T_d_2) / h_m_2)
-
-
- # #深度3,天数3
- # T_m_d3_3 = T_m[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d3_3 = u[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d3_3 = v[:, 3, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_3 = dT_dx[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_3 = dT_dy[:, 3, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_3 = u_d3_3 * (dT_dx_d3_3)
- # out_3_3 = model(data_3_3)
-
- # dT_dt_3_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d3_3 * (dT_dy_d3_3) + out_3_3 + w_e_3 * ((T_m_d3_3 - T_d_3) / h_m_3)
-
-
- # #深度3,天数4
- # T_m_d3_4 = T_m[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d3_4 = u[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d3_4 = v[:, 3, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_4 = dT_dx[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_4 = dT_dy[:, 3, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_4 = u_d3_4 * (dT_dx_d3_4)
- # out_3_4 = model(data_3_4)
-
- # dT_dt_3_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d3_4 * (dT_dy_d3_4) + out_3_4 + w_e_4 * ((T_m_d3_4 - T_d_4) / h_m_4)
-
-
- # #深度3,天数5
- # T_m_d3_5 = T_m[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d3_5 = u[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d3_5 = v[:, 3, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_5 = dT_dx[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_5 = dT_dy[:, 3, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_5 = u_d3_5 * (dT_dx_d3_5)
- # out_3_5 = model(data_3_5)
-
- # dT_dt_3_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d3_5 * (dT_dy_d3_5) + out_3_5 + w_e_5 * ((T_m_d3_5 - T_d_5) / h_m_5)
-
-
- # #深度3,天数6
- # T_m_d3_6 = T_m[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d3_6 = u[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d3_6 = v[:, 3, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_6 = dT_dx[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_6 = dT_dy[:, 3, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_6 = u_d3_6 * (dT_dx_d3_6)
- # out_3_6 = model(data_3_6)
-
- # dT_dt_3_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d3_6 * (dT_dy_d3_6) + out_3_6 + w_e_6 * ((T_m_d3_6 - T_d_6) / h_m_6)
-
-
- # #深度3,天数7
- # T_m_d3_7 = T_m[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d3_7 = u[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d3_7 = v[:, 3, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d3_7 = dT_dx[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d3_7 = dT_dy[:, 3, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_3_7 = u_d3_7 * (dT_dx_d3_7)
- # out_3_7 = model(data_3_7)
-
- # dT_dt_3_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d3_7 * (dT_dy_d3_7) + out_3_7 + w_e_7 * ((T_m_d3_7 - T_d_7) / h_m_7)
-
-
- # #深度4,天数1
- # T_m_d4_1 = T_m[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d4_1 = u[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d4_1 = v[:, 4, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_1 = dT_dx[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_1 = dT_dy[:, 4, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_1 = u_d4_1 * (dT_dx_d4_1)
- # out_4_1 = model(data_4_1)
-
- # dT_dt_4_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d4_1 * (dT_dy_d4_1) + out_4_1 + w_e_1 * ((T_m_d4_1 - T_d_1) / h_m_1)
-
-
- # #深度4,天数2
- # T_m_d4_2 = T_m[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d4_2 = u[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d4_2 = v[:, 4, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_2 = dT_dx[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_2 = dT_dy[:, 4, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_2 = u_d4_2 * (dT_dx_d4_2)
- # out_4_2 = model(data_4_2)
-
- # dT_dt_4_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d4_2 * (dT_dy_d4_2) + out_4_2 + w_e_2 * ((T_m_d4_2 - T_d_2) / h_m_2)
-
-
- # #深度4,天数3
- # T_m_d4_3 = T_m[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d4_3 = u[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d4_3 = v[:, 4, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_3 = dT_dx[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_3 = dT_dy[:, 4, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_3 = u_d4_3 * (dT_dx_d4_3)
- # out_4_3 = model(data_4_3)
-
- # dT_dt_4_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d4_3 * (dT_dy_d4_3) + out_4_3 + w_e_3 * ((T_m_d4_3 - T_d_3) / h_m_3)
-
-
- # #深度4,天数4
- # T_m_d4_4 = T_m[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d4_4 = u[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d4_4 = v[:, 4, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_4 = dT_dx[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_4 = dT_dy[:, 4, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_4 = u_d4_4 * (dT_dx_d4_4)
- # out_4_4 = model(data_4_4)
-
- # dT_dt_4_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d4_4 * (dT_dy_d4_4) + out_4_4 + w_e_4 * ((T_m_d4_4 - T_d_4) / h_m_4)
-
-
- # #深度4,天数5
- # T_m_d4_5 = T_m[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d4_5 = u[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d4_5 = v[:, 4, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_5 = dT_dx[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_5 = dT_dy[:, 4, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_5 = u_d4_5 * (dT_dx_d4_5)
- # out_4_5 = model(data_4_5)
-
- # dT_dt_4_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d4_5 * (dT_dy_d4_5) + out_4_5 + w_e_5 * ((T_m_d4_5 - T_d_5) / h_m_5)
-
-
- # #深度4,天数6
- # T_m_d4_6 = T_m[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d4_6 = u[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d4_6 = v[:, 4, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_6 = dT_dx[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_6 = dT_dy[:, 4, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_6 = u_d4_6 * (dT_dx_d4_6)
- # out_4_6 = model(data_4_6)
-
- # dT_dt_4_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d4_6 * (dT_dy_d4_6) + out_4_6 + w_e_6 * ((T_m_d4_6 - T_d_6) / h_m_6)
-
-
- # #深度4,天数7
- # T_m_d4_7 = T_m[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d4_7 = u[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d4_7 = v[:, 4, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d4_7 = dT_dx[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d4_7 = dT_dy[:, 4, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_4_7 = u_d4_7 * (dT_dx_d4_7)
- # out_4_7 = model(data_4_7)
-
- # dT_dt_4_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d4_7 * (dT_dy_d4_7) + out_4_7 + w_e_7 * ((T_m_d4_7 - T_d_7) / h_m_7)
-
-
- # #深度5,天数1
- # T_m_d5_1 = T_m[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d5_1 = u[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d5_1 = v[:, 5, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_1 = dT_dx[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_1 = dT_dy[:, 5, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_1 = u_d5_1 * (dT_dx_d5_1)
- # out_5_1 = model(data_5_1)
-
- # dT_dt_5_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d5_1 * (dT_dy_d5_1) + out_5_1 + w_e_1 * ((T_m_d5_1 - T_d_1) / h_m_1)
-
-
-
-
- # # #深度5,天数2
- # T_m_d5_2 = T_m[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d5_2 = u[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d5_2 = v[:, 5, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_2 = dT_dx[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_2 = dT_dy[:, 5, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_2 = u_d5_2 * (dT_dx_d5_2)
- # out_5_2 = model(data_5_2)
-
- # dT_dt_5_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d5_2 * (dT_dy_d5_2) + out_5_2 + w_e_2 * ((T_m_d5_2 - T_d_2) / h_m_2)
-
-
- # #深度5,天数3
- # T_m_d5_3 = T_m[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d5_3 = u[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d5_3 = v[:, 5, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_3 = dT_dx[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_3 = dT_dy[:, 5, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_3 = u_d5_3 * (dT_dx_d5_3)
- # out_5_3 = model(data_5_3)
-
- # dT_dt_5_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d5_3 * (dT_dy_d5_3) + out_5_3 + w_e_3 * ((T_m_d5_3 - T_d_3) / h_m_3)
-
-
- # #深度5,天数4
- # T_m_d5_4 = T_m[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d5_4 = u[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d5_4 = v[:, 5, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_4 = dT_dx[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_4 = dT_dy[:, 5, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_4 = u_d5_4 * (dT_dx_d5_4)
- # out_5_4 = model(data_5_4)
-
- # dT_dt_5_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d5_4 * (dT_dy_d5_4) + out_5_4 + w_e_4 * ((T_m_d5_4 - T_d_4) / h_m_4)
-
-
- # #深度5,天数5
- # T_m_d5_5 = T_m[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d5_5 = u[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d5_5 = v[:, 5, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_5 = dT_dx[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_5 = dT_dy[:, 5, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_5 = u_d5_5 * (dT_dx_d5_5)
- # out_5_5 = model(data_5_5)
-
- # dT_dt_5_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d5_5 * (dT_dy_d5_5) + out_5_5 + w_e_5 * ((T_m_d5_5 - T_d_5) / h_m_5)
-
-
- # #深度5,天数6
- # T_m_d5_6 = T_m[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d5_6 = u[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d5_6 = v[:, 5, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_6 = dT_dx[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_6 = dT_dy[:, 5, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_6 = u_d5_6 * (dT_dx_d5_6)
- # out_5_6 = model(data_5_6)
-
- # dT_dt_5_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d5_6 * (dT_dy_d5_6) + out_5_6 + w_e_6 * ((T_m_d5_6 - T_d_6) / h_m_6)
-
-
- # #深度5,天数7
- # T_m_d5_7 = T_m[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d5_7 = u[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d5_7 = v[:, 5, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d5_7 = dT_dx[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d5_7 = dT_dy[:, 5, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_5_7 = u_d5_7 * (dT_dx_d5_7)
- # out_5_7 = model(data_5_7)
-
- # dT_dt_5_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d5_7 * (dT_dy_d5_7) + out_5_7 + w_e_7 * ((T_m_d5_7 - T_d_7) / h_m_7)
-
-
- # #深度6,天数1
- # T_m_d6_1 = T_m[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # u_d6_1 = u[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # v_d6_1 = v[:, 6, 0, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_1 = dT_dx[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_1 = dT_dy[:, 6, 0, :, :].reshape(-1, 1, 40, 80)
- # Q_1 = Q[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # h_m_1 = h_m[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # T_d_1 = T_d[:, :, 0, :, :].reshape(-1, 1, 40, 80)
- # w_e_1 = w_e[:, :, 0, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_1 = u_d6_1 * (dT_dx_d6_1)
- # out_6_1 = model(data_6_1)
-
- # dT_dt_6_1 = Q_1 / (1025 * 4000 * h_m_1) + v_d6_1 * (dT_dy_d6_1) + out_6_1 + w_e_1 * ((T_m_d6_1 - T_d_1) / h_m_1)
-
-
- # #深度6,天数2
- # T_m_d6_2 = T_m[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # u_d6_2 = u[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # v_d6_2 = v[:, 6, 1, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_2 = dT_dx[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_2 = dT_dy[:, 6, 1, :, :].reshape(-1, 1, 40, 80)
- # Q_2 = Q[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # h_m_2 = h_m[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # T_d_2 = T_d[:, :, 1, :, :].reshape(-1, 1, 40, 80)
- # w_e_2 = w_e[:, :, 1, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_2 = u_d6_2 * (dT_dx_d6_2)
- # out_6_2 = model(data_6_2)
-
- # dT_dt_6_2 = Q_2 / (1025 * 4000 * h_m_2) + v_d6_2 * (dT_dy_d6_2) + out_6_2 + w_e_2 * ((T_m_d6_2 - T_d_2) / h_m_2)
-
-
- # #深度6,天数3
- # T_m_d6_3 = T_m[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # u_d6_3 = u[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # v_d6_3 = v[:, 6, 2, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_3 = dT_dx[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_3 = dT_dy[:, 6, 2, :, :].reshape(-1, 1, 40, 80)
- # Q_3 = Q[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # h_m_3 = h_m[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # T_d_3 = T_d[:, :, 2, :, :].reshape(-1, 1, 40, 80)
- # w_e_3 = w_e[:, :, 2, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_3 = u_d6_3 * (dT_dx_d6_3)
- # out_6_3 = model(data_6_3)
-
- # dT_dt_6_3 = Q_3 / (1025 * 4000 * h_m_3) + v_d6_3 * (dT_dy_d6_3) + out_6_3 + w_e_3 * ((T_m_d6_3 - T_d_3) / h_m_3)
-
-
- # #深度6,天数4
- # T_m_d6_4 = T_m[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # u_d6_4 = u[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # v_d6_4 = v[:, 6, 3, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_4 = dT_dx[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_4 = dT_dy[:, 6, 3, :, :].reshape(-1, 1, 40, 80)
- # Q_4 = Q[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # h_m_4 = h_m[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # T_d_4 = T_d[:, :, 3, :, :].reshape(-1, 1, 40, 80)
- # w_e_4 = w_e[:, :, 3, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_4 = u_d6_4 * (dT_dx_d6_4)
- # out_6_4 = model(data_6_4)
-
- # dT_dt_6_4 = Q_4 / (1025 * 4000 * h_m_4) + v_d6_4 * (dT_dy_d6_4) + out_6_4 + w_e_4 * ((T_m_d6_4 - T_d_4) / h_m_4)
-
-
- # #深度6,天数5
- # T_m_d6_5 = T_m[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # u_d6_5 = u[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # v_d6_5 = v[:, 6, 4, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_5 = dT_dx[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_5 = dT_dy[:, 6, 4, :, :].reshape(-1, 1, 40, 80)
- # Q_5 = Q[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # h_m_5 = h_m[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # T_d_5 = T_d[:, :, 4, :, :].reshape(-1, 1, 40, 80)
- # w_e_5 = w_e[:, :, 4, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_5 = u_d6_5 * (dT_dx_d6_5)
- # out_6_5 = model(data_6_5)
-
- # dT_dt_6_5 = Q_5 / (1025 * 4000 * h_m_5) + v_d6_5 * (dT_dy_d6_5) + out_6_5 + w_e_5 * ((T_m_d6_5 - T_d_5) / h_m_5)
-
-
- # #深度6,天数6
- # T_m_d6_6 = T_m[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # u_d6_6 = u[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # v_d6_6 = v[:, 6, 5, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_6 = dT_dx[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_6 = dT_dy[:, 6, 5, :, :].reshape(-1, 1, 40, 80)
- # Q_6 = Q[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # h_m_6 = h_m[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # T_d_6 = T_d[:, :, 5, :, :].reshape(-1, 1, 40, 80)
- # w_e_6 = w_e[:, :, 5, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_6 = u_d6_6 * (dT_dx_d6_6)
- # out_6_6 = model(data_6_6)
-
- # dT_dt_6_6 = Q_6 / (1025 * 4000 * h_m_6) + v_d6_6 * (dT_dy_d6_6) + out_6_6 + w_e_6 * ((T_m_d6_6 - T_d_6) / h_m_6)
-
-
- # #深度6,天数7
- # T_m_d6_7 = T_m[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # u_d6_7 = u[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # v_d6_7 = v[:, 6, 6, :, :].reshape(-1, 1, 40, 80);
- # dT_dx_d6_7 = dT_dx[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # dT_dy_d6_7 = dT_dy[:, 6, 6, :, :].reshape(-1, 1, 40, 80)
- # Q_7 = Q[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # h_m_7 = h_m[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # T_d_7 = T_d[:, :, 6, :, :].reshape(-1, 1, 40, 80)
- # w_e_7 = w_e[:, :, 6, :, :].reshape(-1, 1, 40, 80)
-
- # data_6_7 = u_d6_7 * (dT_dx_d6_7)
- # out_6_7 = model(data_6_7)
-
- # dT_dt_6_7 = Q_7 / (1025 * 4000 * h_m_7) + v_d6_7 * (dT_dy_d6_7) + out_6_7 + w_e_7 * ((T_m_d6_7 - T_d_7) / h_m_7)
-
-
- # # 表面
- # dT_dt_0_1 = list1[0]; dT_dt_0_2 = list1[1]; dT_dt_0_3 = list1[2]; dT_dt_0_4 = list1[3]; dT_dt_0_5 = list1[4]; dT_dt_0_6 = list1[5]; dT_dt_0_7 = list1[6]
-
- # # layer1
- # dT_dt_1_1 = list1[7]; dT_dt_1_2 = list1[8]; dT_dt_1_3 = list1[9]; dT_dt_1_4 = list1[10]; dT_dt_1_5 = list1[11]; dT_dt_1_6 = list1[12]; dT_dt_1_7 = list1[13]
-
- # # layer2
- # dT_dt_2_1 = list1[14]; dT_dt_2_2 = list1[15]; dT_dt_2_3 = list1[16]; dT_dt_2_4 = list1[17]; dT_dt_2_5 = list1[18]; dT_dt_2_6 = list1[19]; dT_dt_2_7 = list1[20]
-
- # # layer3
- # dT_dt_3_1 = list1[21]; dT_dt_3_2 = list1[22]; dT_dt_3_3 = list1[23]; dT_dt_3_4 = list1[24]; dT_dt_3_5 = list1[25]; dT_dt_3_6 = list1[26]; dT_dt_3_7 = list1[27]
-
- # # layer4
- # dT_dt_4_1 = list1[28]; dT_dt_4_2 = list1[29]; dT_dt_4_3 = list1[30]; dT_dt_4_4 = list1[31]; dT_dt_4_5 = list1[32]; dT_dt_4_6 = list1[33]; dT_dt_4_7 = list1[34]
-
- # # layer5
- # dT_dt_5_1 = list1[35]; dT_dt_5_2 = list1[36]; dT_dt_5_3 = list1[37]; dT_dt_5_4 = list1[38]; dT_dt_5_5 = list1[39]; dT_dt_5_6 = list1[40]; dT_dt_5_7 = list1[41]
-
- # # layer5
- # dT_dt_6_1 = list1[42]; T_dt_6_2 = list1[43]; dT_dt_6_3 = list1[44]; dT_dt_6_4 = list1[45]; dT_dt_6_5 = list1[46]; dT_dt_6_6 = list1[47]; dT_dt_6_7 = list1[48]
-
- alpha = 0.1
- beta = 0.9
- T_8_0 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_0_1 + beta * dT_dt_0_2) + beta * dT_dt_0_3) + beta * dT_dt_0_4) + beta * dT_dt_0_5) + beta * dT_dt_0_6) + beta * dT_dt_0_7 + T_m[:, 0,6,:,:].reshape( -1, 1, 40, 80)
- # print('T_8_0_test.shape:{}'.format(T_8_0.shape)) # T_8_0_test.shape:torch.Size([29, 1, 40, 80])
-
- # T_8_1 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_1_1 + beta * dT_dt_1_2) + beta * dT_dt_1_3) + beta * dT_dt_1_4) + beta * dT_dt_1_5) + beta * dT_dt_1_6) + beta * dT_dt_1_7 + T_m[:,1,6,:,:].reshape(-1, 1, 40, 80)
- # T_8_2 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_2_1 + beta * dT_dt_2_2) + beta * dT_dt_2_3) + beta * dT_dt_2_4) + beta * dT_dt_2_5) + beta * dT_dt_2_6) + beta * dT_dt_2_7 + T_m[:,2,6,:,:].reshape(-1, 1, 40, 80)
- # T_8_3 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_3_1 + beta * dT_dt_3_2) + beta * dT_dt_3_3) + beta * dT_dt_3_4) + beta * dT_dt_3_5) + beta * dT_dt_3_6) + beta * dT_dt_3_7 + T_m[:,3,6,:,:].reshape(-1, 1, 40, 80)
- # T_8_4 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_4_1 + beta * dT_dt_4_2) + beta * dT_dt_4_3) + beta * dT_dt_4_4) + beta * dT_dt_4_5) + beta * dT_dt_4_6) + beta * dT_dt_4_7 + T_m[:,4,6,:,:].reshape(-1, 1, 40, 80)
- # T_8_5 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_5_1 + beta * dT_dt_5_2) + beta * dT_dt_5_3) + beta * dT_dt_5_4) + beta * dT_dt_5_5) + beta * dT_dt_5_6) + beta * dT_dt_5_7 + T_m[:,5,6,:,:].reshape(-1, 1, 40, 80)
- # T_8_6 = alpha * (alpha * (alpha * (alpha * (alpha * (alpha * dT_dt_6_1 + beta * dT_dt_6_2) + beta * dT_dt_6_3) + beta * dT_dt_6_4) + beta * dT_dt_6_5) + beta * dT_dt_6_6) + beta * dT_dt_6_7 + T_m[:,6,6,:,:].reshape(-1, 1, 40, 80)
-
- # T_8_all = torch.cat((T_8_0, T_8_1, T_8_2, T_8_3, T_8_4, T_8_4, T_8_6), dim=1)
- # print('T_8_all.shape:{}'.format(T_8_all.shape)) # T_8_0.shape:torch.Size([32, 1, 40, 80])
-
- label_8 = label
- # print('label_valid.shape:{}'.format(label.shape)) # label.shape:torch.Size([32, 7, 10, 40, 80])
-
- loss = criterion(T_8_0, label_8)
- losses += float(loss)
- T_8_0 = T_8_0.detach().cpu().numpy()
-
- pred_val[d * batch_size2:(d + 1) * batch_size2] = np.array(T_8_0)
-
- valid_loss = losses / len(validloader)
- valid_losses.append(valid_loss)
- print('valid_label.shape:{}'.format(valid_label0.shape))
- print('pred_val.shape:{}'.format(pred_val.shape))
- valid_label = valid_label0.reshape(-1, 1)
- T_8_all = pred_val.reshape(-1,1)
-
- s = rmse(valid_label, T_8_all)
- sores.append(s)
- print('Score:{:.3f}'.format(s))
-
- if valid_loss < best_score2: # 求s的最小值 ---》最大值反过来 inf符号也要反过来
- best_score2 = valid_loss
- checkpoint = {'best_score': valid_loss,
- 'state_dict': model.state_dict()}
- torch.save(checkpoint, model_weights1) # if valid_loss < best_loss:
- best_loss = valid_loss
- torch.save(model.state_dict(),
- '/model/cnn_PINN_f(2)_e{}_layer3_ahead_8_day_e{}.pt'.format(epoch111,iii))
- # print(s)
- # print(s)
- print(sores)
- print(best_score)
- print(s)
-
- # 隐藏层节点数
- hidden_dim = (64,64,64)
- # 卷积核大小
- kernel_size = (3, 3)
-
- model = ViT(
- image_size = 288,
- patch_size = 32,
- num_classes = 1000,
- dim = 3321,
- depth = 8, #1
- heads = 8, #2
- mlp_dim = 2048,
- dropout = 0.1,
- emb_dropout = 0.1
- )
- # model = model.cuda()
- # out = model(a) #torch.Size([1826, 12, 15])
- # print(out.shape)
- criterion = nn.MSELoss()
- # 定义优化器
- optimizer = torch.optim.Adam(model.parameters(), lr=1e-3)
-
- epochs = 1000
- train_losses, valid_losses = [], []
- # best_loss = 2
- best_score = float('inf')
- best_score1 = float('inf')
- preds = np.zeros((1952,1,6,27))
- # preds = np.expand_dims(preds, axis=1)#preds.reshape(100,1,12,15)
- # preds = np.zeros((18000,1))
- print(preds.shape)
- sores = []
- def rmse(y_true, y_preds):
- return np.sqrt(mean_squared_error(y_pred = y_preds, y_true = y_true))
-
- for epoch in range(epochs):
- print('Epoch: {}/{}'.format(epoch + 1, epochs))
- # print(var_y)
- #模型训练
- model.train()
- losses = 0
- for data, label in tqdm(trainloader):
- data = data
- label = label
- label = label.reshape(-1,1,6,27)
- data = data.reshape(-1, 3, 7, 6, 27)
- optimizer.zero_grad()
- # print('data.shape:{}'.format(data.shape)) #torch.Size([160, 5, 1, 12, 15])
- out = model(data)
- print('out.shape:{}'.format(out.shape)) #out.shape:torch.Size([32, 2, 12, 15])
- print('label.shape:{}'.format(label.shape)) # out.shape:torch.Size([32, 2, 12, 15])
- loss = criterion(out, label)
- # losses +=loss.cpu().detach().numpy
- losses += loss
- # 反向传播
- loss.backward()
- optimizer.step()
- train_loss = losses / len(trainloader)
- train_losses.append(train_loss)
- print('Training Loss: {:.3f}'.format(train_loss))
-
- # # 模型验证
- # model.eval()
- losses = 0
-
- with torch.no_grad():
- for i, data in tqdm(enumerate(validloader)):
- # print('i:{}'.format(i))
- data, labels = data
- data = data
- label = label
- optimizer.zero_grad()
- data = data.reshape(-1, 7, 7, 6, 27)
- pred = model(data)
-
- # print('pred_shape:{}'.format(pred.shape)) #torch.Size([2, 1, 12, 15])
- loss = criterion(pred, label)
- losses += loss
- pred = pred.reshape(-1,1,6,27)
- preds[i * batch_size2:(i + 1) * batch_size2] = pred.cpu()
- # print(preds.shape)
- # preds[i * batch_size2:(i + 1) * batch_size2] = np.array(tmp)
- valid_loss = losses / len(validloader)
- valid_losses.append(valid_loss)
- print('Validation Loss: {:.3f}'.format(valid_loss))
-
- valid_label1 = valid_label.reshape(-1,1)
- preds1 = preds.reshape(-1,1)
- # print('valid_label1.shape:{}'.format(valid_label1.shape))#(18000,1)
- # print('preds.shape:{}0'.format(preds.shape)) #(360,1)
- s = rmse(valid_label1,preds1)
- sores.append(s)
- print('Score: {:.3f}'.format(s))
- # 保存最佳模型权重
- # if s < best_score: #求s的最小值 ---》最大值反过来 inf符号也要反过来
- # best_score = s
- # checkpoint = {'best_score': s,
- # 'state_dict': model.state_dict()}
- # torch.save(checkpoint, model_weights) # if valid_loss < best_loss:
- # best_loss = valid_loss
- # torch.save(model.state_dict(), './model_epo300_5e-4__hidden64_lay3e2_14day.pt')
- if valid_loss < best_score1: # 求s的最小值 ---》最大值反过来 inf符号也要反过来
- best_score1 = valid_loss
- checkpoint = {'best_score': valid_loss,
- 'state_dict': model.state_dict()}
- torch.save(checkpoint, model_weights1) # if valid_loss < best_loss:
- best_loss = valid_loss
- torch.save(model.state_dict(),
- '/vit_unet_camb_ds_wm_model_epo{}_lr1e-3_layer3_ahead_10_day_e{}.pt'.format(epoch111,ii))
-
- print(sores)
- print('best_score1:{}'.format(best_score1))
- print('s:{}'.format(s))
- print(valid_losses)
-
- print('valid_losses.:{}'.format(valid_losses))
|