Skip to content

Commit

Permalink
Adding New Tests, Documentation and Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FBerding committed Jul 27, 2023
1 parent 3e8b9f8 commit 6625bf8
Show file tree
Hide file tree
Showing 54 changed files with 824 additions and 395 deletions.
12 changes: 6 additions & 6 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Trial
materials
test_model
tests/testthat/test_data/language_models
test/testthat/test_data/tmp
test/testthat/tmp
test/testthat/tmp_full_models
test/testthat/test_data/bert/checkpoints
test/testthat/test_data/longformer/checkpoints
test/testthat/test_data/roberta/checkpoints
tests/testthat/test_data/tmp
tests/testthat/tmp
tests/testthat/tmp_full_models
tests/testthat/test_data/bert/checkpoints
tests/testthat/test_data/longformer/checkpoints
tests/testthat/test_data/roberta/checkpoints
.h5
.git
.gitignore
Expand Down
12 changes: 6 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ language_models
.Rhistory
*.h5
tests/testthat/test_data/language_models/
test/testthat/test_data/tmp/
test/testthat/tmp/
test/testthat/tmp_full_models/
test/testthat/test_data/bert/
test/testthat/test_data/roberta/
test/testthat/test_data/longformer/
tests/testthat/test_data/tmp/
tests/testthat/tmp/
tests/testthat/tmp_full_models/
tests/testthat/test_data/bert/
tests/testthat/test_data/roberta/
tests/testthat/test_data/longformer/
cran-comments.md
22 changes: 9 additions & 13 deletions R/saving_and_loading.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ load_ai_model<-function(model_dir){

loaded_model<-get(x=name_interface)

if(methods::is(model,"TextEmbeddingClassifierNeuralNet")){
loaded_model$load_model(model_dir)
} else if (methods::is(model,"TextEmbeddingModel")){
if(methods::is(loaded_model,"TextEmbeddingClassifierNeuralNet")){
loaded_model$load_model(model_dir)
} else if (methods::is(loaded_model,"TextEmbeddingModel")){
if(loaded_model$basic_components$method%in%c("glove_cluster","lda")==FALSE){
loaded_model$load_model(model_dir)
}
}

return(loaded_model)

} else {
stop("There is no file r_interface.rda in the selected directory")
}
Expand All @@ -37,7 +37,7 @@ load_ai_model<-function(model_dir){
#'@param model_dir Path to the directory where the should model is stored.
#'@param save_format Format for saving the model. \code{"tf"} for SavedModel
#'or \code{"h5"} for HDF5. Only relevant if the model is of class \link{TextEmbeddingClassifierNeuralNet}.
#'It is recommended to use \code{"tf}.
#'It is recommended to use \code{"tf"}.
#'
#'@family Saving and Loading
#'
Expand All @@ -57,16 +57,12 @@ save_ai_model<-function(model,model_dir,save_format="tf"){
if(methods::is(model,"TextEmbeddingClassifierNeuralNet")){
model$save_model(dir_path = final_model_dir_path,save_format=save_format)
} else {
model$save_model(model_dir = final_model_dir_path)
if(model$basic_components$method%in%c("glove_cluster","lda")==FALSE){
model$save_model(model_dir = final_model_dir_path)
}
}



} else {
stop("Function supports only objects of class TextEmbeddingClassifierNeuralNet or
TextEmbeddingModel")
}

methods::is(model,"TextEmbeddingModel")

}
4 changes: 2 additions & 2 deletions R/te_classifier_neuralnet_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ TextEmbeddingClassifierNeuralNet<-R6::R6Class(
private$model_info$model_date=date()

private$r_package_versions$aifeducation<-packageVersion("aifeducation")
private$r_package_versions$keras<-packageVersion("keras")
#private$r_package_versions$keras<-packageVersion("keras")
private$r_package_versions$smotefamily<-packageVersion("smotefamily")
private$r_package_versions$bundle<-packageVersion("bundle")
#private$r_package_versions$bundle<-packageVersion("bundle")

private$py_package_versions$tensorflow<-tf$version$VERSION
private$py_package_versions$numpy<-np$version$short_version
Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ reference:
- contents:
- has_concept("Installation and Configuration")

- title: Saving and Loading
- contents:
- has_concept("Saving and Loading")

- title: Preparation
- contents:
- has_concept("Preparation")
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/aifeducation.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6625bf8

Please sign in to comment.