<bdo id='QOrOo'></bdo><ul id='QOrOo'></ul>
    <i id='QOrOo'><tr id='QOrOo'><dt id='QOrOo'><q id='QOrOo'><span id='QOrOo'><b id='QOrOo'><form id='QOrOo'><ins id='QOrOo'></ins><ul id='QOrOo'></ul><sub id='QOrOo'></sub></form><legend id='QOrOo'></legend><bdo id='QOrOo'><pre id='QOrOo'><center id='QOrOo'></center></pre></bdo></b><th id='QOrOo'></th></span></q></dt></tr></i><div id='QOrOo'><tfoot id='QOrOo'></tfoot><dl id='QOrOo'><fieldset id='QOrOo'></fieldset></dl></div>

  1. <small id='QOrOo'></small><noframes id='QOrOo'>

    <legend id='QOrOo'><style id='QOrOo'><dir id='QOrOo'><q id='QOrOo'></q></dir></style></legend>

      <tfoot id='QOrOo'></tfoot>
    1. 如何将神经网络的输出限制在特定的范围内?

      How to restrict output of a neural net to a specific range?(如何将神经网络的输出限制在特定的范围内?)

        <i id='Q0N6x'><tr id='Q0N6x'><dt id='Q0N6x'><q id='Q0N6x'><span id='Q0N6x'><b id='Q0N6x'><form id='Q0N6x'><ins id='Q0N6x'></ins><ul id='Q0N6x'></ul><sub id='Q0N6x'></sub></form><legend id='Q0N6x'></legend><bdo id='Q0N6x'><pre id='Q0N6x'><center id='Q0N6x'></center></pre></bdo></b><th id='Q0N6x'></th></span></q></dt></tr></i><div id='Q0N6x'><tfoot id='Q0N6x'></tfoot><dl id='Q0N6x'><fieldset id='Q0N6x'></fieldset></dl></div>
      1. <legend id='Q0N6x'><style id='Q0N6x'><dir id='Q0N6x'><q id='Q0N6x'></q></dir></style></legend>
        <tfoot id='Q0N6x'></tfoot>
            <tbody id='Q0N6x'></tbody>

          • <bdo id='Q0N6x'></bdo><ul id='Q0N6x'></ul>

            <small id='Q0N6x'></small><noframes id='Q0N6x'>

                本文介绍了如何将神经网络的输出限制在特定的范围内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用Kera执行回归任务,并希望将输出限制在一个范围内(例如介于1和10之间)

                有没有办法确保这一点?

                推荐答案

                编写自定义激活函数,如下所示

                # a simple custom activation
                from keras import backend as BK
                def mapping_to_target_range( x, target_min=1, target_max=10 ) :
                    x02 = BK.tanh(x) + 1 # x in range(0,2)
                    scale = ( target_max-target_min )/2.
                    return  x02 * scale + target_min
                
                # create a simple model
                from keras.layers import Input, Dense
                from keras.models import Model
                x = Input(shape=(1000,))
                y = Dense(4, activation=mapping_to_target_range )(x)
                model = Model(inputs=x, outputs=y)
                
                # testing
                import numpy as np 
                a = np.random.randn(10,1000)
                b = model.predict(a)
                print b.min(), b.max()
                

                ,您会看到bminmax值分别非常接近110

                这篇关于如何将神经网络的输出限制在特定的范围内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <tbody id='hAFWd'></tbody>
                  <i id='hAFWd'><tr id='hAFWd'><dt id='hAFWd'><q id='hAFWd'><span id='hAFWd'><b id='hAFWd'><form id='hAFWd'><ins id='hAFWd'></ins><ul id='hAFWd'></ul><sub id='hAFWd'></sub></form><legend id='hAFWd'></legend><bdo id='hAFWd'><pre id='hAFWd'><center id='hAFWd'></center></pre></bdo></b><th id='hAFWd'></th></span></q></dt></tr></i><div id='hAFWd'><tfoot id='hAFWd'></tfoot><dl id='hAFWd'><fieldset id='hAFWd'></fieldset></dl></div>
                • <tfoot id='hAFWd'></tfoot>
                    <bdo id='hAFWd'></bdo><ul id='hAFWd'></ul>
                  • <legend id='hAFWd'><style id='hAFWd'><dir id='hAFWd'><q id='hAFWd'></q></dir></style></legend>

                    <small id='hAFWd'></small><noframes id='hAFWd'>