Skip to content

fix: validate dataset of Imdb do not load bug & add: custom Imdb path #1165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/TensorFlowNET.Keras/Datasets/Imdb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Imdb
/// <param name="oov_char"></param>
/// <param name="index_from"></param>
/// <returns></returns>
public DatasetPass load_data(string path = "imdb.npz",
public DatasetPass load_data(string? path = "imdb.npz",
int num_words = -1,
int skip_top = 0,
int maxlen = -1,
Expand All @@ -42,7 +42,7 @@ public DatasetPass load_data(string path = "imdb.npz",
{
if (maxlen == -1) throw new InvalidArgumentError("maxlen must be assigned.");

var dst = Download();
var dst = path ?? Download();

var lines = File.ReadAllLines(Path.Combine(dst, "imdb_train.txt"));
var x_train_string = new string[lines.Length];
Expand All @@ -55,7 +55,7 @@ public DatasetPass load_data(string path = "imdb.npz",

var x_train = keras.preprocessing.sequence.pad_sequences(PraseData(x_train_string), maxlen: maxlen);

File.ReadAllLines(Path.Combine(dst, "imdb_test.txt"));
lines = File.ReadAllLines(Path.Combine(dst, "imdb_test.txt"));
var x_test_string = new string[lines.Length];
var y_test = np.zeros(new int[] { lines.Length }, np.int64);
for (int i = 0; i < lines.Length; i++)
Expand Down