Reputation: 83
callbacks=[TensorBoard(log_dir='/Users/lyj/Programs/KiseliuGit/DeepLearning/tmp/autoencoder')])
File "/Library/Python/2.7/site-packages/keras/callbacks.py", line 457, in __init__
raise Exception('TensorBoard callback only works '
Exception: TensorBoard callback only works with the TensorFlow backend.
Why? I absolutely followed the steps, here's my program:
#coding:utf-8
from keras.layers import Input, Dense, Convolution2D, MaxPooling2D, UpSampling2D
from keras.models import Model
from keras.datasets import mnist
import numpy as np
from keras.callbacks import TensorBoard
input_img = Input(shape=(1, 28, 28))
x = Convolution2D(16, 3, 3, activation='relu', border_mode='same')(input_img)
x = MaxPooling2D((2, 2), border_mode='same')(x)
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
x = MaxPooling2D((2, 2), border_mode='same')(x)
x = Convolution2D(8 ,3, 3, activation='relu', border_mode='same')(x)
encoded = MaxPooling2D((2,2), border_mode='same')(x)
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(encoded)
x = UpSampling2D((2,2))(x)
x = Convolution2D(8, 3, 3, activation='relu', border_mode='same')(x)
x = UpSampling2D((2,2))(x)
x = Convolution2D(16, 3, 3, activation='relu')(x)
x = UpSampling2D((2,2))(x)
decoded = Convolution2D(1, 3, 3, activation='sigmoid', border_mode='same')(x)
autoencoder = Model(input_img, decoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')
(x_train, _), (x_test, _) = mnist.load_data()
x_train = x_train.astype('float32') / 255.
x_test = x_test.astype('float32') / 255.
x_train = np.reshape(x_train, (len(x_train), 1, 28, 28))
x_test = np.reshape(x_test, (len(x_test), 1, 28, 28))
autoencoder.fit(x_train, x_test, nb_epoch=50, batch_size=128, shuffle=True,validation_data=(x_test, x_test),
callbacks=[TensorBoard(log_dir='/Users/kiseliu/DeepLearning/tmp/autoencoder')])
And I inputed the command "tensorboard --logdir=/Users/kiseliu/DeepLearning/tmp/autoencoder"in cmd tools before I run this program.
Upvotes: 1
Views: 383
Reputation: 2851
Change your backend keras from theano to tnesorflow from .keras.json file
Upvotes: 2