<jupyter_start><jupyter_text>Tutorial: Human Motion Generative Model Using Variational AutoencoderVariational recurrent neural network (VRNN) extracts human motion features we use an autoencoder, and to represent the extracted features as a probability density function in a latent space we use a variational autoencoder. Motion generator is modeled as a map from a latent variable sampled in the latent space to a motion capture data.[original image link](http://www.ijmo.org/vol8/616-GV015.pdf)<jupyter_code>import os
os.chdir("../../../../genmotion/")
os.listdir(os.getcwd())
import torch
from algorithm.vrnn.params import HDM05Params

opt = HDM05Params().get_params()
print("opt:",opt)
from dataset.hdm05.hdm05_data_utils import HDM05Dataset

data_path = "E:/researches/GenMotion/dataset/HDM05/HDM_01-01_amc"
dataset = HDM05Dataset(data_path, opt)
from algorithm.vrnn.models import VRNN

model = VRNN(opt)
# set up model device
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
# define the path your want to save the model
# save_path = os.path.join(genmotion.__path__, "../pretrained")
save_path = os.path.join(os.getcwd(), "pretrained")       
print(save_path) 
opt["model_save_path"] = save_path       
from algorithm.vrnn.trainer import HDM05Trainer

trainer = HDM05Trainer(dataset, model, opt, device)

print("training dataset size: ", len(trainer.train_dataset))
print("evaluation dataset size: ", len(trainer.test_dataset))   
trainer.train(epochs=1)
import genmotion
save_path = os.path.join(genmotion.__path__[0], "pretrained/best.pth")
# save_path = os.path.join(os.getcwd(), "/../pretrained")
print(save_path)
# set up model device
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
from algorithm.vrnn.sampler import HDM05Sampler
sampler = HDM05Sampler(save_path, opt, device)
input_motion = dataset[0]
sampled_motion = sampler.sample(input_motion)
torch.FloatTensor(sampled_motion).shape<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11538461538461539, 'fraction_numerical': 0.017982017982017984, 'mean_word_length': 5.883161512027492, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '665970', 'license': 'MIT', 'n_tokens_mistral': 680, 'n_tokens_neox': 640, 'n_words': 168, 'path': 'backup/vrnn.ipynb', 'repo_name': 'yizhouzhao/GenMotion', 'size': '2002'}