發表文章

目前顯示的是 11月, 2018的文章

Keras TimeSeries - Regression with negative values

圖片
up vote 0 down vote favorite I am trying to make regression tasks for time series, my data is like the below, i make window size of 10, and input feature as below, and target is the 5th column. as you see it has data of 70, 110, -100, 540,-130, 50 My model as below: model = Sequential(( Conv1D(filters=filters, kernel_size=kernel_size, activation='relu', input_shape=(window_size, nb_series)), MaxPooling1D(), Conv1D(filters=filters, kernel_size=kernel_size, activation='relu'), MaxPooling1D(), Flatten(), Dense(nb_outputs, activation='linear'), )) model.compile(loss='mse', optimizer='adam', metrics=['mae']) My Input features as below: 0.00000000,0.42857143,0.57142857,0.00000000,70.00000000,1.00061741,1.00002238,22.40000000,24.85000000,30.75000000,8.10000000,1.00015876,1.00294701,0.99736059,-44.57995000,1.00166700,0.99966561,-0.00003286,0.00030157,1.00252034,49.18000000,40.96386000,19.74918000,-62.22000000 0.00000000,0.09090

Why Z has to be 2-dimensional for 3d plotting in matplotlib

圖片
up vote 1 down vote favorite I am trying to plot 3d Surface plots using code from this site using matplotlib: X,Y and Z are obtained as below: from math import pi from numpy import cos, meshgrid alpha = 0.7 phi_ext = 2 * pi * 0.5 def flux_qubit_potential(phi_m, phi_p): return 2 + alpha - 2 * cos(phi_p)*cos(phi_m) - alpha * cos(phi_ext - 2*phi_p) phi_m = linspace(0, 2*pi, 100) phi_p = linspace(0, 2*pi, 100) X,Y = meshgrid(phi_p, phi_m) Z = flux_qubit_potential(X, Y).T And 3d plotting is done with following code: from mpl_toolkits.mplot3d.axes3d import Axes3D fig = plt.figure(figsize=(14,6)) # `ax` is a 3D-aware axis instance, because of the projection='3d' keyword argument to add_subplot ax = fig.add_subplot(1, 2, 1, projection='3d') p = ax.plot_surface(X, Y, Z, rstride=4, cstride=4, linewidth=0) # surface_plot with color grading and color bar ax = fig.add_subplot(1, 2, 2, projection='3d') p = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.c