有什么方法可以在 neo4j 中创建超图吗?或者有其他数据库工具可以解决这个问题吗?
mean_sqr = tf.reduce_mean(tf.pow(y_ - y, 2))
optimizer = tf.train.AdamOptimizer(LEARNING_RATE)
gradients, variables = zip(*optimizer.compute_gradients(mean_sqr))
opt = optimizer.apply_gradients(list(zip(gradients, variables)))
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
for j in range(TRAINING_EPOCHS):
sess.run(opt, feed_dict={x: batch_xs, y_: batch_xs})
Run Code Online (Sandbox Code Playgroud)
我不太清楚compute_gradients会返回什么?它是否为batch_xs分配的给定x值返回sum(dy / dx),并更新apply_gradients函数中的梯度,例如:
theta < -theta -LEARNING_RATE * 1 / m * gradients?
还是已经返回给定批次中每个x值求和的梯度平均值,例如sum(dy / dx)* 1 / m,m定义为batch_size?
在此链接中,给出了两个概率分布之间的总变异距离。
我尝试用python计算它。我有两个数据集,首先我根据直方图计算了它们的概率分布函数。然后我尝试获得两个分布之间的最大差异。但它返回给我的值非常小。看来我在这方面做错了。你能帮忙修复一下吗?
import scipy.stats as st
#original data has shape of [45222,1] and it is numpy array
#synthetic data has shape of [45222,1] and it is numpy array
summation = 0
minOriginal = min(original)
minGenerated = min(synthetic)
maxOriginal = max(original)
maxGenerated = max(synthetic)
minHist = min(minOriginal, minGenerated)
maxHist = max(maxOriginal, maxGenerated)
originalHist = np.histogram(original, range=(minHist, maxHist))
hist_dist1 = st.rv_histogram(originalHist)
generatedHist = np.histogram(synthetic, range=(minHist, maxHist))
hist_dist2 = st.rv_histogram(generatedHist)
x = np.linspace(minHist, maxHist, 45000)
summation += max(abs(hist_dist1.pdf(x)-hist_dist2.pdf(x)))
Run Code Online (Sandbox Code Playgroud) 在这里,我尝试从 python 代码调用 R 函数。
import numpy as np
import pandas as pd
import rpy2.robjects as ro
import rpy2.robjects.numpy2ri
rpy2.robjects.numpy2ri.activate()
time_series_data = pd.read_csv(daily_file_path, sep=",", header=None).values
nr,nc = time_series_data.shape
r_time_series_data = ro.r.matrix(time_series_data, nrow=nr, ncol=nc)
ro.r.assign("r_time_series_data", r_time_series_data)
Run Code Online (Sandbox Code Playgroud)
当我导入 R 库时,它会引发以下错误:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Edu 4.0\helpers\pydev\pydevd.py", line 1596, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Edu 4.0\helpers\pydev\pydevd.py", line 1023, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Edu 4.0\helpers\pydev\_pydev_imps\_pydev_execfile.py", line …Run Code Online (Sandbox Code Playgroud) 我需要从数据集中为回归任务选择一些特征。但是数值来自不同的范围。
from sklearn.datasets import load_boston
from sklearn.feature_selection import SelectKBest, f_regression
X, y = load_boston(return_X_y=True)
X_new = SelectKBest(f_regression, k=2).fit_transform(X, y)
Run Code Online (Sandbox Code Playgroud)
为了提高回归模型的性能,我是否需要在SelectKBest方法之前对 X 进行归一化?
我对时间序列分析有疑问。我有一个包含 5 个特征的数据集。以下是我的输入数据集的子集:
date,price,year,day,totaltx
1/1/2016 0:00,434.46,2016,1,126762
1/2/2016 0:00,433.59,2016,2,147449
1/3/2016 0:00,430.36,2016,3,148661
1/4/2016 0:00,433.49,2016,4,185279
1/5/2016 0:00,432.25,2016,5,178723
1/6/2016 0:00,429.46,2016,6,184207
Run Code Online (Sandbox Code Playgroud)
我的内源数据是价格列,外源数据是totaltx价格。
这是我正在运行并收到错误的代码:
import statsmodels.api as sm
import pandas as pd
import numpy as np
from numpy.linalg import LinAlgError
def arima(filteredData, coinOutput, window, horizon, trainLength):
start_index = 0
end_index = 0
inputNumber = filteredData.shape[0]
predictions = np.array([], dtype=np.float32)
prices = np.array([], dtype=np.float32)
# sliding on time series data with 1 day step
while ((end_index) < inputNumber - 1):
end_index = start_index + trainLength
trainFeatures = …Run Code Online (Sandbox Code Playgroud) 我有一段代码使用Sigmoid激活函数进行分类,以输出[0,1]。但是我需要一个激活函数来输出0或1的二进制值。
x = tf.placeholder("float", [None, COLUMN])
Wh = tf.Variable(tf.random_normal([COLUMN, UNITS_OF_HIDDEN_LAYER], mean=0.0, stddev=0.05))
h = tf.nn.sigmoid(tf.matmul(x, Wh))
Wo = tf.Variable(tf.random_normal([UNITS_OF_HIDDEN_LAYER, COLUMN], mean=0.0, stddev=0.05))
y = tf.nn.sigmoid(tf.matmul(h, Wo))
# Objective functions
y_ = tf.placeholder("float", [None, COLUMN])
correct_prediction = tf.equal(tf.argmax(y, 1),tf.argmax(y, 1))
cost = tf.reduce_sum(tf.cast(correct_prediction, "float"))/BATCH_SIZE
Run Code Online (Sandbox Code Playgroud)
您能告诉我如何用二进制第一步代替Sigmoid函数吗?
python ×5
tensorflow ×2
arima ×1
database ×1
distribution ×1
gradient ×1
neo4j ×1
probability ×1
python-3.x ×1
rpy2 ×1
statistics ×1
time-series ×1