ValueError: Unknown activation function:m7_user_activation_bigquant_run?

策略分享
标签: #<Tag:0x00007f73ee6ea780>

(ljj13802239795) #1
克隆策略

    {"Description":"实验创建于2020/5/9","Summary":"","Graph":{"EdgesInternal":[{"DestinationInputPortId":"-3887:input_1","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8:data"},{"DestinationInputPortId":"-3887:input_2","SourceOutputPortId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24:data"},{"DestinationInputPortId":"-3880:inputs","SourceOutputPortId":"-160:data"},{"DestinationInputPortId":"-356:inputs","SourceOutputPortId":"-160:data"},{"DestinationInputPortId":"-1540:trained_model","SourceOutputPortId":"-1098:data"},{"DestinationInputPortId":"-1098:input_model","SourceOutputPortId":"-3880:data"},{"DestinationInputPortId":"-2605:inputs","SourceOutputPortId":"-356:data"},{"DestinationInputPortId":"-8666:input_data","SourceOutputPortId":"-3887:data_1"},{"DestinationInputPortId":"-1098:training_data","SourceOutputPortId":"-7764:data_1"},{"DestinationInputPortId":"-1540:input_data","SourceOutputPortId":"-7764:data_2"},{"DestinationInputPortId":"-7764:input_2","SourceOutputPortId":"-8666:data"},{"DestinationInputPortId":"-3880:outputs","SourceOutputPortId":"-2605:data"}],"ModuleNodes":[{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","ModuleId":"BigQuantSpace.instruments.instruments-v2","ModuleParameters":[{"Name":"start_date","Value":"2010-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"end_date","Value":"2011-01-01","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"market","Value":"CN_STOCK_A","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"instrument_list","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"max_count","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"rolling_conf","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-8","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":1,"Comment":"","CommentCollapsed":true},{"Id":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","ModuleId":"BigQuantSpace.input_features.input_features-v1","ModuleParameters":[{"Name":"features","Value":"bm_close=close\nbm_open=open\nbm_high=high\nbm_low=low\nbm_amount=amount\nbm_volume=volume\nbm_label=shift(close, -5) / shift(open, -1)-1","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"features_ds","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24"}],"OutputPortsInternal":[{"Name":"data","NodeId":"287d2cb0-f53c-4101-bdf8-104b137c8601-24","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":2,"Comment":"","CommentCollapsed":true},{"Id":"-160","ModuleId":"BigQuantSpace.dl_layer_input.dl_layer_input-v1","ModuleParameters":[{"Name":"shape","Value":"4,6","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"batch_shape","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"dtype","Value":"float32","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"sparse","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"name","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"inputs","NodeId":"-160"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-160","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":3,"Comment":"","CommentCollapsed":true},{"Id":"-1098","ModuleId":"BigQuantSpace.dl_model_train.dl_model_train-v1","ModuleParameters":[{"Name":"optimizer","Value":"RMSprop","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_optimizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"loss","Value":"mean_squared_error","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_loss","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"metrics","Value":"mae","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"batch_size","Value":"100","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"epochs","Value":"7","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"n_gpus","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"verbose","Value":"2:每个epoch输出一行记录","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_model","NodeId":"-1098"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"training_data","NodeId":"-1098"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"validation_data","NodeId":"-1098"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1098","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":4,"Comment":"","CommentCollapsed":true},{"Id":"-1540","ModuleId":"BigQuantSpace.dl_model_predict.dl_model_predict-v1","ModuleParameters":[{"Name":"batch_size","Value":"100","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"n_gpus","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"verbose","Value":"2:每个epoch输出一行记录","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"trained_model","NodeId":"-1540"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-1540"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-1540","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":5,"Comment":"","CommentCollapsed":true},{"Id":"-3880","ModuleId":"BigQuantSpace.dl_model_init.dl_model_init-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"inputs","NodeId":"-3880"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"outputs","NodeId":"-3880"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-3880","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":6,"Comment":"","CommentCollapsed":true},{"Id":"-356","ModuleId":"BigQuantSpace.dl_layer_lstm.dl_layer_lstm-v1","ModuleParameters":[{"Name":"units","Value":"32","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activation","Value":"自定义","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_activation","Value":"import tensorflow as tf\n \ndef bigquant_run(x):\n return tf.atan(x)\n \n \n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_activation","Value":"hard_sigmoid","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_recurrent_activation","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"use_bias","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_initializer","Value":"glorot_uniform","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_kernel_initializer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_initializer","Value":"Orthogonal","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_recurrent_initializer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_initializer","Value":"Zeros","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_bias_initializer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"unit_forget_bias","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_regularizer","Value":"L1L2","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_regularizer_l1","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_regularizer_l2","Value":"0.00001","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_kernel_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_regularizer","Value":"L1L2","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_regularizer_l1","Value":"0.00001","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_regularizer_l2","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_recurrent_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_regularizer","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_regularizer_l1","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_regularizer_l2","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_bias_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activity_regularizer","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activity_regularizer_l1","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activity_regularizer_l2","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_activity_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_constraint","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_kernel_constraint","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_constraint","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_recurrent_constraint","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_constraint","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_bias_constraint","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"dropout","Value":"0","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"recurrent_dropout","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"return_sequences","Value":"False","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"implementation","Value":"2","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"name","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"inputs","NodeId":"-356"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-356","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":7,"Comment":"","CommentCollapsed":true},{"Id":"-3887","ModuleId":"BigQuantSpace.index_feature_extract.index_feature_extract-v3","ModuleParameters":[{"Name":"before_days","Value":100,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"index","Value":"000300.HIX","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-3887"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-3887"}],"OutputPortsInternal":[{"Name":"data_1","NodeId":"-3887","OutputType":null},{"Name":"data_2","NodeId":"-3887","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":11,"Comment":"","CommentCollapsed":true},{"Id":"-7764","ModuleId":"BigQuantSpace.cached.cached-v3","ModuleParameters":[{"Name":"run","Value":"# Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端\n# 参数:\n# window:每个input的长度\n# train_length:以window为单位的训练长度\ndef bigquant_run(input_1, input_2, input_3, window=4,train_length=20):\n # 示例代码如下。在这里编写您的代码\n df = input_2.read_df()\n cols = df.columns\n \n df.columns = [(col.partition('bm_')[2] if col.startswith('b') else col) for col in cols ]\n x = df[df.columns.difference(['date','instrument','label'] )]\n y = df['label']\n train_len = window*train_length # 以行为单位的训练长度\n train_x = x.head(train_len)\n train_y = y.head(train_len)\n test_x = x.tail(len(x)-train_len)\n \n # 数据处理:设定每个input(window×len(fields))以及数据标准化\n from sklearn.preprocessing import scale\n train_x = [scale(train_x[i:i+window]) for i in range(len(train_x)-window)] # x 元素形状:(window,len(fields))\n train_y = [train_y[i] for i in range(len(train_y)-window)]\n test_x = [scale(test_x[i:i+window]) for i in range(len(test_x)-window)] # x 元素形状:(window,len(fields))\n# train_x = [scale(train_x[i:i+window]) for i in range(len(train_x))] # x 元素形状:(window,len(fields))\n# train_y = [train_y[i] for i in range(len(train_y))]\n# test_x = [scale(test_x[i:i+window]) for i in range(len(test_x))] # x 元素形状:(window,len(fields))\n\n # LSTM训练和预测模块接受数组类型字典的输入\n train = {'x':np.array(train_x),'y':np.array(train_y)}\n test = {'x':np.array(test_x)}\n \n data_1 = DataSource.write_pickle(train)\n data_2 = DataSource.write_pickle(test)\n# data_3 = DataSource.write_pickle(df.columns.difference(['date','instrument','label'] ))\n data_3 = DataSource.write_df(df.tail(len(df)-train_len)) \n return Outputs(data_1=data_1, data_2=data_2, data_3=data_3)\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"post_run","Value":"# 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。\ndef bigquant_run(outputs):\n return outputs\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"input_ports","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"params","Value":"{\n 'window':4,\n 'train_length':20\n}","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"output_ports","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_1","NodeId":"-7764"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_2","NodeId":"-7764"},{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_3","NodeId":"-7764"}],"OutputPortsInternal":[{"Name":"data_1","NodeId":"-7764","OutputType":null},{"Name":"data_2","NodeId":"-7764","OutputType":null},{"Name":"data_3","NodeId":"-7764","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":12,"Comment":"","CommentCollapsed":true},{"Id":"-8666","ModuleId":"BigQuantSpace.dropnan.dropnan-v1","ModuleParameters":[],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"input_data","NodeId":"-8666"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-8666","OutputType":null}],"UsePreviousResults":true,"moduleIdForCode":13,"Comment":"","CommentCollapsed":true},{"Id":"-2605","ModuleId":"BigQuantSpace.dl_layer_dense.dl_layer_dense-v1","ModuleParameters":[{"Name":"units","Value":"1","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activation","Value":"自定义","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_activation","Value":"import tensorflow as tf\n\ndef bigquant_run(x):\n return tf.atan(x)\n\n","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"use_bias","Value":"True","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_initializer","Value":"glorot_uniform","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_kernel_initializer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_initializer","Value":"Zeros","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_bias_initializer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_regularizer","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_regularizer_l1","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_regularizer_l2","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_kernel_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_regularizer","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_regularizer_l1","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_regularizer_l2","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_bias_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activity_regularizer","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activity_regularizer_l1","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"activity_regularizer_l2","Value":0,"ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_activity_regularizer","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"kernel_constraint","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_kernel_constraint","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"bias_constraint","Value":"None","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"user_bias_constraint","Value":"","ValueType":"Literal","LinkedGlobalParameter":null},{"Name":"name","Value":"","ValueType":"Literal","LinkedGlobalParameter":null}],"InputPortsInternal":[{"DataSourceId":null,"TrainedModelId":null,"TransformModuleId":null,"Name":"inputs","NodeId":"-2605"}],"OutputPortsInternal":[{"Name":"data","NodeId":"-2605","OutputType":null}],"UsePreviousResults":false,"moduleIdForCode":10,"Comment":"","CommentCollapsed":true}],"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-8' Position='380,43,200,200'/><NodePosition Node='287d2cb0-f53c-4101-bdf8-104b137c8601-24' Position='434,-63,200,200'/><NodePosition Node='-160' Position='42,-58,200,200'/><NodePosition Node='-1098' Position='77.17588806152344,415.0867004394531,200,200'/><NodePosition Node='-1540' Position='186.29397583007812,513.2826538085938,200,200'/><NodePosition Node='-3880' Position='61.559051513671875,317.5276184082031,200,200'/><NodePosition Node='-356' Position='51,62,200,200'/><NodePosition Node='-3887' Position='399,140,200,200'/><NodePosition Node='-7764' Position='411,328,200,200'/><NodePosition Node='-8666' Position='389,212,200,200'/><NodePosition Node='-2605' Position='54.4610595703125,194.1155548095703,200,200'/></NodePositions><NodeGroups /></DataV1>"},"IsDraft":true,"ParentExperimentId":null,"WebService":{"IsWebServiceExperiment":false,"Inputs":[],"Outputs":[],"Parameters":[{"Name":"交易日期","Value":"","ParameterDefinition":{"Name":"交易日期","FriendlyName":"交易日期","DefaultValue":"","ParameterType":"String","HasDefaultValue":true,"IsOptional":true,"ParameterRules":[],"HasRules":false,"MarkupType":0,"CredentialDescriptor":null}}],"WebServiceGroupId":null,"SerializedClientData":"<?xml version='1.0' encoding='utf-16'?><DataV1 xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Meta /><NodePositions></NodePositions><NodeGroups /></DataV1>"},"DisableNodesUpdate":false,"Category":"user","Tags":[],"IsPartialRun":true}
    In [3]:
    # 本代码由可视化策略环境自动生成 2020年5月9日 16:06
    # 本代码单元只能在可视化模式下编辑。您也可以拷贝代码,粘贴到新建的代码单元或者策略,然后修改。
    
    
    # Python 代码入口函数,input_1/2/3 对应三个输入端,data_1/2/3 对应三个输出端
    # 参数:
    # window:每个input的长度
    # train_length:以window为单位的训练长度
    def m12_run_bigquant_run(input_1, input_2, input_3, window=4,train_length=20):
        # 示例代码如下。在这里编写您的代码
        df = input_2.read_df()
        cols = df.columns
        
        df.columns = [(col.partition('bm_')[2] if col.startswith('b') else col) for col in cols ]
        x = df[df.columns.difference(['date','instrument','label'] )]
        y = df['label']
        train_len = window*train_length  # 以行为单位的训练长度
        train_x = x.head(train_len)
        train_y = y.head(train_len)
        test_x = x.tail(len(x)-train_len)
        
        # 数据处理:设定每个input(window×len(fields))以及数据标准化
        from sklearn.preprocessing import scale
        train_x = [scale(train_x[i:i+window]) for i in range(len(train_x)-window)]  # x 元素形状:(window,len(fields))
        train_y = [train_y[i] for i in range(len(train_y)-window)]
        test_x = [scale(test_x[i:i+window]) for i in range(len(test_x)-window)]  # x 元素形状:(window,len(fields))
    #    train_x = [scale(train_x[i:i+window]) for i in range(len(train_x))]  # x 元素形状:(window,len(fields))
    #    train_y = [train_y[i] for i in range(len(train_y))]
    #    test_x = [scale(test_x[i:i+window]) for i in range(len(test_x))]  # x 元素形状:(window,len(fields))
    
        # LSTM训练和预测模块接受数组类型字典的输入
        train = {'x':np.array(train_x),'y':np.array(train_y)}
        test  = {'x':np.array(test_x)}
        
        data_1 = DataSource.write_pickle(train)
        data_2 = DataSource.write_pickle(test)
    #    data_3 = DataSource.write_pickle(df.columns.difference(['date','instrument','label'] ))
        data_3 = DataSource.write_df(df.tail(len(df)-train_len))    
        return Outputs(data_1=data_1, data_2=data_2, data_3=data_3)
    
    # 后处理函数,可选。输入是主函数的输出,可以在这里对数据做处理,或者返回更友好的outputs数据格式。此函数输出不会被缓存。
    def m12_post_run_bigquant_run(outputs):
        return outputs
    
    import tensorflow as tf
        
    def m7_user_activation_bigquant_run(x):
        return tf.atan(x)
        
     
    
    import tensorflow as tf
    
    def m10_user_activation_bigquant_run(x):
        return tf.atan(x)
    
    
    
    m1 = M.instruments.v2(
        start_date='2010-01-01',
        end_date='2011-01-01',
        market='CN_STOCK_A',
        instrument_list='',
        max_count=0
    )
    
    m2 = M.input_features.v1(
        features="""bm_close=close
    bm_open=open
    bm_high=high
    bm_low=low
    bm_amount=amount
    bm_volume=volume
    bm_label=shift(close, -5) / shift(open, -1)-1"""
    )
    
    m11 = M.index_feature_extract.v3(
        input_1=m1.data,
        input_2=m2.data,
        before_days=100,
        index='000300.HIX'
    )
    
    m13 = M.dropnan.v1(
        input_data=m11.data_1
    )
    
    m12 = M.cached.v3(
        input_2=m13.data,
        run=m12_run_bigquant_run,
        post_run=m12_post_run_bigquant_run,
        input_ports='',
        params="""{
        'window':4,
        'train_length':20
    }""",
        output_ports=''
    )
    
    m3 = M.dl_layer_input.v1(
        shape='4,6',
        batch_shape='',
        dtype='float32',
        sparse=False,
        name=''
    )
    
    m7 = M.dl_layer_lstm.v1(
        inputs=m3.data,
        units=32,
        activation='自定义',
        user_activation=m7_user_activation_bigquant_run,
        recurrent_activation='hard_sigmoid',
        use_bias=True,
        kernel_initializer='glorot_uniform',
        recurrent_initializer='Orthogonal',
        bias_initializer='Zeros',
        unit_forget_bias=True,
        kernel_regularizer='L1L2',
        kernel_regularizer_l1=0,
        kernel_regularizer_l2=0.00001,
        recurrent_regularizer='L1L2',
        recurrent_regularizer_l1=0.00001,
        recurrent_regularizer_l2=0,
        bias_regularizer='None',
        bias_regularizer_l1=0,
        bias_regularizer_l2=0,
        activity_regularizer='None',
        activity_regularizer_l1=0,
        activity_regularizer_l2=0,
        kernel_constraint='None',
        recurrent_constraint='None',
        bias_constraint='None',
        dropout=0,
        recurrent_dropout=0,
        return_sequences=False,
        implementation='2',
        name=''
    )
    
    m10 = M.dl_layer_dense.v1(
        inputs=m7.data,
        units=1,
        activation='自定义',
        user_activation=m10_user_activation_bigquant_run,
        use_bias=True,
        kernel_initializer='glorot_uniform',
        bias_initializer='Zeros',
        kernel_regularizer='None',
        kernel_regularizer_l1=0,
        kernel_regularizer_l2=0,
        bias_regularizer='None',
        bias_regularizer_l1=0,
        bias_regularizer_l2=0,
        activity_regularizer='None',
        activity_regularizer_l1=0,
        activity_regularizer_l2=0,
        kernel_constraint='None',
        bias_constraint='None',
        name=''
    )
    
    m6 = M.dl_model_init.v1(
        inputs=m3.data,
        outputs=m10.data
    )
    
    m4 = M.dl_model_train.v1(
        input_model=m6.data,
        training_data=m12.data_1,
        optimizer='RMSprop',
        loss='mean_squared_error',
        metrics='mae',
        batch_size=100,
        epochs=7,
        n_gpus=0,
        verbose='2:每个epoch输出一行记录'
    )
    
    m5 = M.dl_model_predict.v1(
        trained_model=m4.data,
        input_data=m12.data_2,
        batch_size=100,
        n_gpus=0,
        verbose='2:每个epoch输出一行记录'
    )
    
    ---------------------------------------------------------------------------
    ValueError                                Traceback (most recent call last)
    <ipython-input-3-48e5f5fce327> in <module>()
        175     epochs=7,
        176     n_gpus=0,
    --> 177     verbose='2:每个epoch输出一行记录'
        178 )
        179 
    
    ValueError: Unknown activation function:m7_user_activation_bigquant_run