Thanks a lot for the reply. Yet, the generator still does not replicate like the example here. So, here is my updated code:
loss_D(x, y, dscr) = sum(Flux.Losses.logitbinarycrossentropy(dscr(x), y))
function trainDiscriminator!(dscr,gen,train_size)
real = generate_real_data(train_size)
fake = gen(rand(5,train_size))
X = hcat(real,fake)
Y = vcat(ones(train_size),zeros(train_size))
data = Flux.Data.DataLoader(X, Y', batchsize=128,shuffle=true);
for d in data
gs = gradient(Flux.params(dscr)) do
l = loss_D(d...,dscr)
end
Flux.update!(opt, Flux.params(dscr), gs)
end
end
loss_G(z,gen,dscr) = sum(Flux.Losses.logitbinarycrossentropy(dscr(gen(z)),1))
function trainGenerator!(gen,dscr,train_size)
noise = rand(5,train_size)
data = Flux.Data.DataLoader(noise, batchsize=128,shuffle=true);
for d in data
gs = gradient(Flux.params(gen)) do
l = loss_G(d,gen,dscr)
end
Flux.update!(opt, Flux.params(gen), gs)
end
fake_generated = gen(rand(5,train_size))
end