<jupyter_start><jupyter_text>testデータ読み込み<jupyter_code>voice = pd.read_pickle("../../voice/train/VCC2SF1/10002.pkl")
image = cv2.imread("../../image/000001.jpg")<jupyter_output><empty_output><jupyter_text>ノーマライズ  音声min = 0, max = 1 に変換<jupyter_code>def norm_voice(array):
    min = array.min()
    array -= min 
    
    max = array.max()
    array /= max
    
    return array
# test
voice = norm_voice(voice)<jupyter_output><empty_output><jupyter_text>入力値のuttr_lenが4の倍数じゃないとバグるので最終を切る<jupyter_code>voice = voice[:, :voice.shape[1]-voice.shape[1]%4]<jupyter_output><empty_output><jupyter_text>画像<jupyter_code>def norm_image(array):
    return array/255
image = norm_image(image)<jupyter_output><empty_output><jupyter_text>学習テスト<jupyter_code>import cmvc.models.model as cmvc
import torch
from torch import optim
device = "cpu"
net = cmvc.Net()<jupyter_output><empty_output><jupyter_text>"""入力1: バッチサイズ2: channel3: mccs_size(画像における縦)4: uttr_len(画像における横)"""<jupyter_code>x = torch.tensor([[voice], [voice]], dtype=torch.float32)
y = torch.tensor([image.T, image.T], dtype=torch.float32)
x.shape
y.shape
optimizer = optim.Adam(net.parameters(), lr=0.001)
net.train()

x = x.to(device) 
y = y.to(device)
net.zero_grad()
#print(net.test(x, y))
loss = net.loss(x, y)
print(loss)
loss.backward()
optimizer.step()<jupyter_output>tensor(5.7689, grad_fn=<SumBackward0>) tensor(699.7460, grad_fn=<SumBackward0>)
tensor(0.0118, grad_fn=<SumBackward0>) tensor(16.0012, grad_fn=<SumBackward0>)
tensor(1.3289, grad_fn=<MulBackward0>) tensor(1.3530e-05, grad_fn=<MulBackward0>) tensor(0.4314, grad_fn=<MseLossBackward>) tensor(0.1289, grad_fn=<MseLossBackward>)
tensor(0.1290, grad_fn=<AddBackward0>)
tensor(2.0182, grad_fn=<AddBackward0>)
{'fraction_non_alphanumeric': 0.16666666666666666, 'fraction_numerical': 0.056910569105691054, 'mean_word_length': 7.165876777251185, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '586762', 'license': 'MIT', 'n_tokens_mistral': 816, 'n_tokens_neox': 778, 'n_words': 92, 'path': 'cmvc/learning/Untitled.ipynb', 'repo_name': 'kjun1/CMVC', 'size': '1722'}