张量板升级后出现问题
我试图使用张量板,但是对数缩放器功能在视觉上无法正常工作。我曾尝试升级tensorboard,但随后又说了一些有关tensorflow版本过旧的问题。因此,我也对其进行了更新。由于东西不再起作用,我将两者都降级到1.12.0,相同的错误。 即使没有在我的代码中使用tensorboard,也会发生这种情况
from random import uniform, randint
from keras.models import load_model
import numpy as np
import matplotlib.pyplot as plt
train = True
time_steps = 8
units = 80
batches = 2000
inputs = 1
class Sine_wave():
def __init__(self):
self.xmin = 0
self.xmax = 6.25
self.space = 0.1
self.num_points = (self.xmax-self.xmin)/self.space
def generate_data(self, num_of_batches, steps, return_x_points = False):
if return_x_points == False:
X_data = []
Y_data = []
for i in range(num_of_batches):
start = uniform(self.xmin, self.xmax - (steps * self.space))
x_points = np.linspace(start, start + steps * self.space, steps)
y_values = np.sin(x_points)
Target = np.sin(start + ((steps+1) * self.space))
X_data.append(y_values)
Y_data.append(Target)
return np.array(X_data).reshape(num_of_batches, steps, inputs), np.array(Y_data)
wave = Sine_wave()
try:
model = load_model('Sine_pred_model.h5')
except:
from keras.optimizers import Adam
from keras.models import Sequential
from keras.layers import Dense, Dropout, LSTM, BatchNormalization
model = Sequential()
model.add(LSTM(units, input_shape = (time_steps, inputs), activation = 'tanh'))
model.add(Dense(50, activation = 'tanh'))
model.add(Dense(1, activation = 'tanh'))
model.compile(optimizer = 'adam', loss = 'mse')
if train:
# from keras.callbacks import TensorBoard
X_data, Y_data = wave.generate_data(batches, time_steps)
# tensorboard = TensorBoard(log_dir="logs/{}_timesteps-{}_units-Sine_pred_model".format(time_steps, units))
model.fit(X_data, Y_data, batch_size=32, epochs=30)#, callbacks=[tensorboard])
model.save('Sine_pred_model.h5')
full_input = []
x_full = np.linspace(wave.xmin, wave.xmax, wave.num_points)
y_full = []
for i in range(len(x_full)-time_steps):
for j in range(time_steps):
full_input.append(np.sin(x_full[i+(j)]))
y_full.append(np.sin(x_full[i+time_steps]))
x_full = x_full[time_steps:]
full_input = np.array(full_input)
full_input = np.reshape(full_input,(len(x_full), time_steps, 1))
plt.plot(x_full, y_full,'r', label='True sine wave')
plt.plot(x_full, model.predict(full_input), label='Full prediction')
predictions
start_example = randint(0,len(x_full)-time_steps)
test_input = y_full[start_example:start_example+time_steps]
test_input_xs = x_full[start_example:start_example+time_steps]
x_target = x_full[start_example+time_steps]
y_target = y_full[start_example+time_steps]
prediction = model.predict(np.reshape(test_input,(1, time_steps, 1)))
plt.plot(x_target, y_target, 'ro', alpha = 0.6, markersize = 10, label = 'Target')
plt.plot(test_input_xs, test_input, 'bo', alpha = 0.5, markersize = 10, label = 'Inputs for model')
plt.plot(x_target, prediction, 'ko', markersize = 5, label = 'Target prediction')
plt.legend()
plt.show()
这是在不使用张量板的情况下发生的。 所以我只是无法从tensorflow后端加载东西。 我被搞砸了
Using TensorFlow backend.
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/anaconda3/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _clock_gettime
Referenced from: /anaconda3/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /anaconda3/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/ramses/Documents/Python/Tensorflow/sine_pred.py", line 2, in <module>
from keras.models import load_model
File "/anaconda3/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/anaconda3/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
from . import conv_utils
File "/anaconda3/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module>
from .. import backend as K
File "/anaconda3/lib/python3.6/site-packages/keras/backend/__init__.py", line 89, in <module>
from .tensorflow_backend import *
File "/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/anaconda3/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: _clock_gettime
Referenced from: /anaconda3/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
in /anaconda3/lib/python3.6/site-packages/tensorflow/python/../libtensorflow_framework.so
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
[Finished in 4.9s with exit code 1]
[shell_cmd: python -u "/Users/ramses/Documents/Python/Tensorflow/sine_pred.py"]
[dir: /Users/ramses/Documents/Python/Tensorflow]
[path: /usr/bin:/bin:/usr/sbin:/sbin]