numpy

How to downgrade numpy?

泄露秘密 提交于 2021-02-18 11:10:19
问题 I got error TypeError: slice indices must be integers or None or have an __index__ method and searched for a solution and got that i need to downgrade the version of numpy , then tried to use this command python import numpy numpy.__version__ and got >>> numpy.__version__ '1.14.5' but when i used pip show numpy Name: numpy Version: 1.11.0 Summary: NumPy: array processing for numbers, strings, records, and objects. Home-page: http://www.numpy.org Author: NumPy Developers Author-email: numpy

How to downgrade numpy?

夙愿已清 提交于 2021-02-18 11:05:09
问题 I got error TypeError: slice indices must be integers or None or have an __index__ method and searched for a solution and got that i need to downgrade the version of numpy , then tried to use this command python import numpy numpy.__version__ and got >>> numpy.__version__ '1.14.5' but when i used pip show numpy Name: numpy Version: 1.11.0 Summary: NumPy: array processing for numbers, strings, records, and objects. Home-page: http://www.numpy.org Author: NumPy Developers Author-email: numpy

How to print full (not truncated) tensor in tensorflow?

狂风中的少年 提交于 2021-02-18 10:29:09
问题 Whenever I try printing I always get truncated results import tensorflow as tf import numpy as np np.set_printoptions(threshold=np.nan) tensor = tf.constant(np.ones(999)) tensor = tf.Print(tensor, [tensor]) sess = tf.Session() sess.run(tensor) As you can see I've followed a guide I found on Print full value of tensor into console or write to file in tensorflow But the output is simply ...\core\kernels\logging_ops.cc:79] [1 1 1...] I want to see the full tensor, thanks. 回答1: This is solved

Efficient pairwise DTW calculation using numpy or cython

好久不见. 提交于 2021-02-18 10:11:33
问题 I am trying to calculate the pairwise distances between multiple time-series contained in a numpy array. Please see the code below print(type(sales)) print(sales.shape) <class 'numpy.ndarray'> (687, 157) So, sales contains 687 time series of length 157. Using pdist to calculate the DTW distances between the time series. import fastdtw import scipy.spatial.distance as sd def my_fastdtw(sales1, sales2): return fastdtw.fastdtw(sales1,sales2)[0] distance_matrix = sd.pdist(sales, my_fastdtw) --

Efficient pairwise DTW calculation using numpy or cython

断了今生、忘了曾经 提交于 2021-02-18 10:10:54
问题 I am trying to calculate the pairwise distances between multiple time-series contained in a numpy array. Please see the code below print(type(sales)) print(sales.shape) <class 'numpy.ndarray'> (687, 157) So, sales contains 687 time series of length 157. Using pdist to calculate the DTW distances between the time series. import fastdtw import scipy.spatial.distance as sd def my_fastdtw(sales1, sales2): return fastdtw.fastdtw(sales1,sales2)[0] distance_matrix = sd.pdist(sales, my_fastdtw) --

科大讯飞工程机械核心部件寿命预测挑战赛冠军方案分享

狂风中的少年 提交于 2021-02-18 08:50:48
本次分享从以下几个方面展开,尽可能做到有理有据,希望对读者有所帮助:赛题简介、赛题难点、数据预处理、特征工程、数据增强、模型构建、其他、总结。 1.赛题简介 预测性维护是工业互联网应用“皇冠上的明珠”,实现预测性维护的关键是对设备系统或核心部件的寿命进行有效预测。对工程机械设备的核心耗损性部件的剩余寿命进行预测,可以据此对于相关部件的进行提前维护或者更换,从而减少整个设备非计划停机时间,避免因计划外停机而带来的经济损失,比如导致整个生产现场其他配套设备等待故障设备部件的修复。本赛题由中科云谷科技有限公司提供某类工程机械设备的核心耗损性部件的工作数据,包括部件工作时长、转速、温度、电压、电流等多类工况数据。希望参赛者利用大数据分析、机器学习、深度学习等方法,提取合适的特征、建立合适的寿命预测模型,预测核心耗损性部件的剩余寿命。 2.赛题难点 针对数据量以及划分构造训练集的问题采用以下方案解决: 训练集与测试集的构造: a.一个训练样本按照寿命的一定比例进行构造多个小样本; 这里有两种方法,一是采用固定的比例列表,例如[0.45,0.55,0.63,0.75,0.85]。 二是采用多次选取随机比例构造。 b.测试集不变。 (队友周杰曾尝试过测试集也进行比例划分,有提升) 比如说一个样本的寿命为1000,我们截取450前的数据作为一个训练样本,其剩余寿命为550; 然后截取550前的数据

matplotlib plot csv file of all columns

你离开我真会死。 提交于 2021-02-18 08:45:40
问题 I have a csv file which contains 20 columns. Right now I can plot using this code taking first column as x axis and rest of them as y axis. import numpy as np import matplotlib.pyplot as plt data = np.genfromtxt('cs.csv',delimiter=',', dtype = float) a = [row[0] for row in data] b = [row[1] for row in data] c = [row[2] for row in data] fig = plt.figure() ax = fig.add_subplot(111, axisbg = 'w') ax.plot(a,b,'g',lw=1.3) ax.plot(a,c,'r',lw=1.3) plt.show() The problem is here I have to define all

matplotlib plot csv file of all columns

耗尽温柔 提交于 2021-02-18 08:45:28
问题 I have a csv file which contains 20 columns. Right now I can plot using this code taking first column as x axis and rest of them as y axis. import numpy as np import matplotlib.pyplot as plt data = np.genfromtxt('cs.csv',delimiter=',', dtype = float) a = [row[0] for row in data] b = [row[1] for row in data] c = [row[2] for row in data] fig = plt.figure() ax = fig.add_subplot(111, axisbg = 'w') ax.plot(a,b,'g',lw=1.3) ax.plot(a,c,'r',lw=1.3) plt.show() The problem is here I have to define all

matplotlib plot csv file of all columns

本秂侑毒 提交于 2021-02-18 08:45:21
问题 I have a csv file which contains 20 columns. Right now I can plot using this code taking first column as x axis and rest of them as y axis. import numpy as np import matplotlib.pyplot as plt data = np.genfromtxt('cs.csv',delimiter=',', dtype = float) a = [row[0] for row in data] b = [row[1] for row in data] c = [row[2] for row in data] fig = plt.figure() ax = fig.add_subplot(111, axisbg = 'w') ax.plot(a,b,'g',lw=1.3) ax.plot(a,c,'r',lw=1.3) plt.show() The problem is here I have to define all

ValueError: matrix must be 2-dimensional when passing two arrays to the function

跟風遠走 提交于 2021-02-18 08:17:30
问题 I have a function which is written entirely in numpy functions and takes two input values. The function consists of some matrix operations and when I pass two large arrays It gives me an ValueError: matrix must be 2-dimensional. Using loops and numpy.apply_along_axis will fix the problem but these methods with make the code very slow. The following is the code I have written import numpy as np import random data = np.random.normal(size=600*600*2) data = data.reshape(600*600,2) def fun(x,y):