小编bio*_*ent的帖子

OneHot 编码蛋白质序列

我有一个下面列出的序列的原始数据帧,我尝试使用 one-hot 编码,然后将它们存储在一个新的数据帧中,我尝试使用以下代码执行此操作,但无法存储,因为我之后得到以下输出:

代码:

onehot_encoder = OneHotEncoder()
sequence = np.array(list(x_train['sequence'])).reshape(-1, 1)
encoded_sequence = onehot_encoder.fit_transform(sequence).toarray()
encoded_sequence
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

但出现错误

ValueError: Wrong number of items passed 12755, placement implies 1
Run Code Online (Sandbox Code Playgroud)

python bioinformatics scikit-learn one-hot-encoding

4
推荐指数
1
解决办法
3655
查看次数

创建多通道网络:“连接”对象没有“形状”属性

我正在尝试按如下方式制作多输入模型,但在定义以下内容时遇到问题:

  1. 每个单独输入的实际输入形状
  2. 什么时候应该使用 flatten
  3. 将我的两个独立模型连接在一起

我想建立这样的东西:

-First Dense Layer-      - First Dense layer -
         |                        |
         |                        |
Second Dense layer          Second Dense layer
                      |
                      |
            Final Dense layer (Single Output)
Run Code Online (Sandbox Code Playgroud)

但是,在运行模型时出现以下错误:

AttributeError: 'Concatenate' object has no attribute 'shape'
Run Code Online (Sandbox Code Playgroud)

我的代码

def build_nn_model(x_input1_train, x_input2_train):
    
    """
    Creates the a multi-channel ANN, capable of accepting multiple inputs.

    :param: none
    :return: the model of the ANN with a single output given
    """

    x_input1= np.expand_dims(x_input1,1)

    # define two sets of inputs for models
    input1= Input(shape …
Run Code Online (Sandbox Code Playgroud)

python neural-network deep-learning keras tensorflow

4
推荐指数
1
解决办法
1417
查看次数