run training and (optionally) evaluation

train_eval(tripout, pbg, evind = 3, do_eval = FALSE)

Arguments

tripout

list resulting from `triples_to_hdf5`

pbg

torchbiggraph reference

evind

numeric(1) index in edge_paths to use for evaluation

do_eval

logical(1) if TRUE an evaluation is performed

Note

when a full set of train/validate/test paths are provided, then evind should be set to 3

Examples

example(triples_to_hdf5)  # creates tt with tt$config
#> 
#> trp__5> tfis = fb15k_folder()
#> 
#> trp__5> edp = gsub(".txt$", "partitioned", tfis)
#> 
#> trp__5> pbg = reticulate::import("torchbiggraph")
#> 
#> trp__5> palib = reticulate::import("pathlib")
#> 
#> trp__5> ent = make_entity_schema(pbgref=pbg)
#> 
#> trp__5> entities=reticulate::dict(all=ent)
#> 
#> trp__5> rs = BiocPBG::make_rel_schema(pbgref=pbg)
#> 
#> trp__5> cs = setup_config_schema( pbgref = pbg, entities = entities,
#> trp__5+    relations = list(rs), entity_path = paste0(tempdir(), "/uconf"), edge_paths = edp,
#> trp__5+    checkpoint_path = paste0(tempdir(), "/uconf/chk"))
#> 
#> trp__5> tt = triples_to_hdf5( cs, tfis, pbgref = pbg, paref = palib )
pyatt = import("attr")
tt2 = list()
tor = reticulate::import("torch")
ngpu = 0L
if (tor$cuda$is_available()) ngpu=1L
tt2$config = pyatt$evolve(tt$config, num_epochs=4L, num_uniform_negs=1000L,
   num_gpus=ngpu)
train_eval(tt2, pbg, do_eval=TRUE)