我试着跑掉这个教程
我想用Python分割三维断层图像。
刚开始的时候,我一直在努力重塑形象。
这是代码:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import time as time
data = np.fromfile('/data/data_l67/dalladas/Python3/Daten/Al8Cu_1000_g13_t4_200_250.vol', dtype=np.float32)
data.shape
(60940800,)
data.res
我想从具有以下格式的CSV文件中绘制一个条形图:
#Number of Occurrences, Occurrences of A, Occurrences of B, Occurrences of C
30,1,3,26
...
我对Matplotlib完全陌生,我正在努力了解如何做到这一点。我希望y轴有出现的#值(所提供的示例为30),以及三条:标杆A、B和C,它们各自的值。
我怎么能做到呢?
我的守则:
#!/usr/bin python
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
i
我想使用Conv1D使扩展卷积网络成为序列数据集。
所以我尝试了波士顿数据集的Conv1D。
from tensorflow.python.keras.layers import Conv1D, MaxPooling2D
from tensorflow.python.keras.layers import Activation, Dropout, Flatten, Input, Dense
from tensorflow.python.keras.models import Model
from sklearn.datasets import load_boston
from sklearn.
我有一个包含浮动的2列的数据文件。我首先排除列包含零的行,然后希望检查每一行的元素是否相等。
我试过:
df.loc[(df['col1'] != 0.0) & (df['col2'] != 0.0), 'Error'] = np.where(assert_almost_equal(df['col1'], df['col2']), 'Not equal', '')
结果是:
ValueError: The truth value of a Series is ambiguou
我收到了来自Keras的非常混乱的错误消息。我使用以下模型,并将其传递给形状(num_examples, n, 1)的输入。
def create_model():
model = Sequential()
model.add(LSTM(64, input_shape=(n,1), return_sequences=False))
model.add(Dense(units=n, activation='linear'))
return model
我收到一条错误消息:ValueError: Error when checking target:
当涉及到keras ad tensorflow时,我是一个新手,所以我真的需要一些帮助来尝试解决我在代码中遇到的这个问题。我正在尝试运行一个自动编码器程序。然而,当我尝试运行程序时,我得到了如下错误: ValueError: error when checking input:期望input_1具有2维,但得到了具有形状(32,256,256,3)的数组。我非常确定程序在从我的数据库中提取图像时遇到了问题,该数据库位于一个名为train的目录中。我在raspberry pi上破坏了这段代码,这是我的代码:
from keras.layers import Input, Dense
from
我定义了一个二维数组如下:
predict_result = np.zeros((69,1000))
在循环中,我试图将一个预测的一维数组注入其中。
for ij in range(0,1000):
# # some code to generate Ypredict
predict_result[:,ij]=Ypredict
Ypredict总是(69,1)的形状。但是,运行该程序会出现以下错误
predict_result:,ij=Ypredict ValueError:无法广播输入数组从形状(69,1)到形状(69)
如何纠正此错误?
我正在尝试keras.layers.LSTM,下面的代码可以工作。
#!/usr/bin/python3
import tensorflow as tf
import numpy as np
from tensorflow import keras
data = np.array([1, 2, 3]).reshape((1, 3, 1))
x = keras.layers.Input(shape=(3, 1))
y = keras.layers.LSTM(10)(x)
model = keras.Model(inputs=x, outputs=y)
print (model.predi
我正在流数据,数据被保存到json文件中,如下所示
with open('filename.json', 'a') as f:
f.write(data)
现在我想看一下这些数据,以便进一步分析。简单地在另一个程序中使用json文件,我能做的最简单的事情就是。
import json
with open('D:\Devotion of time\Data\paralympics.json') as f:
data= json.load(f)
or
data= json.loads(f.read())
在这两种情况下,我都会得到以下错
我想编写一个简单的函数来从json加载一个keras模型并运行一个预测。但是,每次运行它时,我都会得到以下错误:
ValueError: Error when checking : expected input_2 to have shape (28,) but got array with shape (1,)
下面的代码显示了numpy数组的形状,它返回(28,),如果我将它作为python列表保存,仍然会发生这种情况。
def doit():
# load json and create model
json_file = open('model.json'
我有一个大的4D数据集,需要从它创建一个较小的4D数组。我对python相当陌生,并且使用IDL或matlab。我读取我的值,然后使用where函数,从较小的一维数组中找到每个维度所需的索引号。我正在尝试从这些索引数字创建一个新的数组,但是我不断地得到形状不匹配的错误(不能对单个形状进行溴化)。
import numpy as n
import matplotlib.pyplot as plt
import Scientific.IO.NetCDF as S
file=S.NetCDFFile('wspd.mon.mean.nc',mode='r') #Ope
错误:ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 1 is different from 2) 我正在使用csv数据帧进行线性回归。在重塑和拟合x和y值之后,我遇到了这个错误,突出显示了model.predict部分。 我的代码: import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from
class DataGenerator(Sequence):
def __getitem__(self, index):
indexes = self.indexes[index * self.batch_size:(index + 1) * self.batch_size]
list_IDs_temp = [self.list_IDs[k] for k in indexes]
X,y= self.__data_generation(list_IDs_temp)
return X, y
def on
当我在numpy多维数组中进行索引时,我有一个奇怪的问题。所以,我有一个形状数组(4,882)。我有另一个名为形状匹配(276,2)的数组。此匹配数组包含原始多维数组中有效条目的索引。我要做的是选择前2行和匹配匹配数组中的索引的所有列。因此,我所做的事情如下:
import numpy as np
k = get_array() # This has shape (4, 882)
m = get_match() # This has shape (276, 2)
s = k[[1, 0], m[:, 0]]
这会引发错误:
ValueError: shape mismatch: obje