public override JObject ToJObject() { var jobj = new JObject(); jobj["units"] = _units; if (_inputShape != null) { jobj["input_shape"] = new JArray(_inputShape); } KerasUtils.AddActivation(jobj, _activation); if (_kernelInitializer.GetType() == typeof(string)) { jobj["kernel_initializer"] = (string)_kernelInitializer; } else { jobj["kernel_initializer"] = (_kernelInitializer as GraphOp).ToJObject(); } jobj["op"] = "Dense"; return(jobj); }
public override JObject ToJObject() { var jobj = new JObject(); jobj["units"] = _units; if (_inputShape != null) { jobj["input_shape"] = new JArray(_inputShape); } jobj["use_bias"] = _useBias; KerasUtils.AddActivation(jobj, _activation); KerasUtils.AddActivation(jobj, "recurrent_activation", _recurrentActivation); KerasUtils.AddStringOrObject(jobj, "kernel_initializer", _kernelInitializer); KerasUtils.AddStringOrObject(jobj, "recurrent_initializer", _recurrentInitializer); KerasUtils.AddStringOrObject(jobj, "bias_initializer", _biasInitializer); jobj["unit_forget_bias"] = _unitForgetBias; KerasUtils.AddStringOrObject(jobj, "kernel_regularizer", _kernelRegularizer); KerasUtils.AddStringOrObject(jobj, "recurrent_regularizer", _recurrentRegularizer); KerasUtils.AddStringOrObject(jobj, "bias_regularizer", _biasRegularizer); KerasUtils.AddStringOrObject(jobj, "activity_regularizer", _activityRegularizer); jobj["dropout"] = _dropout; jobj["recurrent_dropout"] = _recurrentDropout; jobj["op"] = "LSTM"; return(jobj); }
public override JObject ToJObject() { var jobj = new JObject() { ["input_dim"] = _inputDim, ["output_dim"] = _outputDim, ["mask_zero"] = _maskZero }; KerasUtils.AddStringOrObject(jobj, "embedding_initializer", _embeddingInitializer); KerasUtils.AddStringOrObject(jobj, "embedding_regularizer", _embeddingRegularizer); if (_inputLength.HasValue) { jobj.Add("input_length", _inputLength.Value); } if (_inputShape != null) { jobj["input_shape"] = new JArray(_inputShape); } jobj["op"] = "Embedding"; return(jobj); }
public AveragePooling2D(object poolSize = null, object strides = null, string padding = "valid", string dataFormat = null, int[] inputShape = null) { _poolSize = poolSize == null ? new int[] { 2, 2 } : KerasUtils.GetArray(poolSize, 2); _strides = strides == null ? _poolSize : KerasUtils.GetArray(strides, 2); _padding = padding; _dataFormat = dataFormat == null ? Globals.DataFormat : dataFormat; _inputShape = inputShape; }
public override JObject ToJObject() { var jobj = new JObject(); jobj["filters"] = _filters; jobj["kernel_size"] = new JArray(_kernelSize); jobj["strides"] = new JArray(_strides); jobj["use_bias"] = _useBias; if (_inputShape != null) { jobj["input_shape"] = new JArray(_inputShape); } KerasUtils.AddActivation(jobj, _activation); jobj["bias_initializer"] = "zeros"; jobj.Add("op", "Conv2D"); return(jobj); }
public Conv2D(int filters, object kernelSize, object strides = null, object activation = null, bool useBias = true, int [] inputShape = null) { _inputShape = inputShape; _kernelSize = KerasUtils.GetArray(kernelSize, 2); if (_kernelSize == null) { throw new ArgumentException("The kernelSize parameter type is not supported."); } _filters = filters; _activation = activation; _useBias = useBias; if (strides == null) { _strides = new int[] { 1, 1 } } ; else { _strides = KerasUtils.GetArray(strides, 2); } _op = "Conv2D"; }