我正在尝试运行此代码,最后2个点产品显示错误,如标题中所示.我检查了矩阵的大小,两者都是(3,1),那么为什么在做dot产品时它会显示错误?
coordinate1 = [-7.173, -2.314, 2.811]
coordinate2 = [-5.204, -3.598, 3.323]
coordinate3 = [-3.922, -3.881, 4.044]
coordinate4 = [-2.734, -3.794, 3.085]
import numpy as np
from numpy import matrix
coordinate1i=matrix(coordinate1)
coordinate2i=matrix(coordinate2)
coordinate3i=matrix(coordinate3)
coordinate4i=matrix(coordinate4)
b0 = coordinate1i - coordinate2i
b1 = coordinate3i - coordinate2i
b2 = coordinate4i - coordinate3i
n1 = np.cross(b0, b1)
n2 = np.cross(b2, b1)
n12cross = np.cross(n1,n2)
x1= np.cross(n1,b1)/np.linalg.norm(b1)
print np.shape(x1)
print np.shape(n2)
np.asarray(x1)
np.asarray(n2)
y = np.dot(x1,n2)
x = np.dot(n1,n2)
return np.degrees(np.arctan2(y, x))
Run Code Online (Sandbox Code Playgroud) 我读取数据并使用以下代码处理它:
data = pd.read_csv('Step1_output.csv')
data = data.sample(frac=1).reset_index(drop=True)
data1 = pd.DataFrame(data, columns=['Res_pair'])
# creating instance of labelencoder
labelencoder = LabelEncoder()
# Assigning numerical values and storing in another column
data1['Res_pair_ID'] = labelencoder.fit_transform(data1['Res_pair'])
data['Res_pair'] = data1['Res_pair_ID']
data = data.to_numpy()
train_X = data[0:data.shape[0],0:566]
train_y = data[0:data.shape[0],566:data.shape[1]]
train_X = train_X.reshape((train_X.shape[0], train_X.shape[1], 1))
Run Code Online (Sandbox Code Playgroud)
我使用以下代码构建模型,其中我尝试使用 Tensorflow 的镜像策略分发数据集:
print("Hyper-parameter values:\n")
print('Momentum Rate =',momentum_rate,'\n')
print('learning rate =',learning_rate,'\n')
print('Number of neurons =',neurons,'\n')
strategy = tensorflow.distribute.MirroredStrategy()
with strategy.scope():
model = tf.keras.Sequential([
tf.keras.layers.Conv1D(64,kernel_size = 3,activation='relu',input_shape=train_X.shape[1:]),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(neurons,activation='relu'),
tf.keras.layers.Dense(neurons,activation='relu'),
tf.keras.layers.Dense(neurons,activation='relu'),
tf.keras.layers.Dense(neurons,activation='relu'),
tf.keras.layers.Dense(10, …Run Code Online (Sandbox Code Playgroud) 我有如下数据框:
S A B C D E
1 N N N N N
2 N Y Y N N
3 Y N Y N N
4 Y N Y Y Y
Run Code Online (Sandbox Code Playgroud)
我在哪里需要创建一个新列F,其中包含来自A,B,C,D和E多个列的出现次数最多的字符?
输出应如下所示:
S A B C D E F
1 N N N N N N
2 N Y Y N N N
3 Y N Y N N N
4 Y N Y Y Y Y
Run Code Online (Sandbox Code Playgroud)