Comments (5)
Since you are already in control of the training loop, you can directly log the required values for tensorboard as shown in this gist.
The relevant parts are summarized below.
Define the logging function
def write_log(callback, names, logs, batch_no):
for name, value in zip(names, logs):
summary = tf.Summary()
summary_value = summary.value.add()
summary_value.simple_value = value
summary_value.tag = name
callback.writer.add_summary(summary, batch_no)
callback.writer.flush()
Setup the callback
log_path = './logs'
callback = TensorBoard(log_path)
callback.set_model(model)
Call the log function after training
d_loss = discriminator.train_on_batch...
g_loss = combined.train_on_batch...
write_log(callback, ['g_loss'], [g_loss], batch_no)
write_log(callback, ['d_loss'], [d_loss], batch_no)
from keras-gan.
Got this error
g_loss is adding properly but causing problem with d_loss
d_loss_real = self.discriminator.train_on_batch(imgs, np.ones((half_batch, 1)))
d_loss_fake = self.discriminator.train_on_batch(gen_imgs, np.zeros((half_batch, 1)))
d_loss = 0.5 * np.add(d_loss_real, d_loss_fake)
TypeError: only size-1 arrays can be converted to Python scalars
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:/Research/Generative_adversarial_networks/dcgan/keras_degan.py", line 196, in <module>
dcgan.train(callback, epochs=4000, batch_size=32, save_interval=200)
File "D:/Research/Generative_adversarial_networks/dcgan/keras_degan.py", line 163, in train
write_log(callback, ['d_loss'], [d_loss], epoch)
File "D:/Research/Generative_adversarial_networks/dcgan/keras_degan.py", line 22, in write_log
summary_value.simple_value = value
File "C:\Users\bikas\Anaconda3\lib\site-packages\numpy\core\arrayprint.py", line 1379, in array_repr
if type(arr) is not ndarray:
SystemError: <class 'type'> returned a result with an error set
from keras-gan.
@ShuvenduBikash from the error message it seems that the loss contains multiple values (did you specify metrics in the model.compile function?).
You can change the call to the log function to write_log(callback, ['d_loss'], [d_loss[0]], batch_no)
if you only want to log the loss.
You should also be able to log the loss and other metrics by changing it to write_log(callback, ['d_loss', 'other_metric_name', ...], d_loss, batch_no)
from keras-gan.
@GerrieCrafford Thanks. I got the problem
Could you please give me some reference to learn details about this in details. I don't quite like the tensorflow's own website.
from keras-gan.
@ShuvenduBikash Glad I could help.
Unfortunately, I don't know of a reference other than TensorFlow's website (or maybe Keras' website).
from keras-gan.
Related Issues (20)
- when training CGAN, raise AttributeError: 'list' object has no attribute 'keys' in the following code HOT 5
- About pix2pix cannot be executed
- [Pix2Pix] Use fit_generator to speed up training process
- Why d_loss = 0.5 * np.add(d_loss_real, d_loss_fake) ? HOT 7
- cGAN: Using Multi label with different number of classes
- DCGAN can only generate noise images HOT 5
- (WGAN_GP)BatchNormalization in critic
- Adversarial Autoencoder training procedure does not correspond to procedure described in paper
- SRGAN - Generated image got PINK overlay all the time ? How to solve this ? HOT 1
- StarGAN & StyleGAN any chance ?
- Cannot import 'Adam' for keras optimizers while testing acgan HOT 1
- ACGAN: Difference multiplication and concatenation of embedding and noise
- pix2pix download dataset
- ImportError: cannot import name 'DataLoader' from 'data_loader'
- Where can I find and download some pre-trained model?
- Project dependencies may have API risk issues
- SRGAN dataset is not available
- when training SGAN for cifar10 and mnist dataset, raised the "AttributeError: 'list' object has no attribute 'keys' "in the following code lones
- cGAN with multi-labels of multi-classes HOT 1
- Keras GAN
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-gan.